npocmaka
this does not work:
Code: Select all
@echo off
for /l %%c in (1=1=5) do (
echo --%1--
shift
)
echo --%1--
Code: Select all
C:\>shift_test.bat ich ni san shi go roku
--ich--
--ich--
--ich--
--ich--
--ich--
--roku--
The only that I've found so far that workarounds this is:
Code: Select all
@echo off
for /l %%c in (1=1=5) do (
call echo --%%1--
shift
)
echo --%1--
Code: Select all
C:\>shift_test.bat ich ni san shi go roku
--ich--
--ni--
--san--
--shi--
--go--
--roku--
Any other ideas?
edit:
call %%1 works in similar way as call %%%nested_variable%%% .I have not tested this with for loop yet but I will...
additional ~ accessing arguments without shift:
Code: Select all
setlocal enableDelayedExpansion
set /a counter=0
for /l %%x in (1, 1, 9) do (
set /a counter=!counter!+1
call echo %%!counter!
)
endlocal
----------------------------
#2 22 May 2013 20:22
npocmaka
And a test with call and one side enclosed variables (can I call them in this way?) :
Code: Select all
@echo off
set nested=Matryoshka
call echo %%%1%%
for %%N in (nested) do (
call echo %%%%N%%
)
Code: Select all
C:\>test.bat nested
Matryoshka
Matryoshka
Code: Select all
@echo off
call call echo %%%%%1
output:
Code: Select all
C:\>test.bat 2 Matryoshka
Matryoshka

Last edited by npocmaka (23 May 2013 09:30)
----------------------------
#3 23 May 2013 14:39
jeb
It's the normal behaviour, as percent variables and parameters are expanded while the block is parsed.
Your second sample could be smaller
Code: Select all
@echo off
call echo %%%1
Output
Code: Select all
hatchi
#5 15 Jul 2013 21:38
npocmaka
'tunneling' is working also with shift (which was expected):
Code: Select all
@echo off
shift & echo %1
goto :eof
C:\test>test.bat Eins zwei
Eins
----------------------------
#6 15 Jul 2013 22:14
jeb
That would be unexpected!npocmaka wrote:
2.SHIFT /n is good at math yikes
BUT I can't reproduce it.
And even your sample seems not to be prove it.
The "zwei" is missing, not the "vier".
It seems that the SHIFT takes only the first number after the slash.
Btw. Warum verwendest du deutsche Zahlen wenn du aus Bulgarien kommst?
Why are you using german numbers when you are from bulgaria?
----------------------------
#7 15 Jul 2013 22:42
npocmaka
My mistake.Every thing after the first number is ignored.But didn't delete my post fast enough.jeb wrote:
npocmaka wrote:
2.SHIFT /n is good at math yikes
That would be unexpected!
BUT I can't reproduce it.
And even your sample seems not to be prove it.
The "zwei" is missing, not the "vier".
It seems that the SHIFT takes only the first number after the slash.
Btw. Warum verwendest du deutsche Zahlen wenn du aus Bulgarien kommst?
Why are you using german numbers when you are from bulgaria?
Last edited by npocmaka (25 Oct 2013 12:41)
----------------------------
#8 15 Jul 2013 23:02
npocmaka
I don't know...For diversity I supposejeb wrote:
Btw. Warum verwendest du deutsche Zahlen wenn du aus Bulgarien kommst?
Why are you using german numbers when you are from bulgaria?
Last edited by npocmaka (25 Oct 2013 12:41)