Code: Select all
set "@forç=for /f "usebackq tokens=1-26 delims= " %%a in"
Code: Select all
%@forç% ( '$var, 0, 999' ) %@GetRandom%
Code: Select all
>> Pre Define @GetRandom
$var : 205 [ok] Kan bestand ☺
♠☺??↨??$error = 7 niet vinden.
<< Post Define @GetRandom [OK]
Why would the macro fail at the end ?, it just don't make sense !
My god, it look like it's shifting parameters
Code: Select all
for /f "usebackq tokens=1-26 delims= " %%a in ( '$var, 0, 999' ) %@GetRandom%
%@forç% ( '$var, 0, 999' ) %@GetRandom%
$var : 229 [ok]
'$var : 0 [ok]
0 : 0 [ok]
999' : 0 [ok]
<< Post Define @GetRandom [OK]
And it gets weirder:
Code: Select all
for /f "usebackq tokens=1-26 delims=' " %%a in ( '$var, 0, 999' ) %@GetRandom%
for /f "usebackq tokens=1-26 delims=' " %%a in ( '$var, 0, 999' ) %@GetRandom%
$var : 917 [ok]
$var : 253 [ok] Kan bestand ☺?♥♠a♀???☻?☻ niet vinden.
<< Post Define @GetRandom [OK]
endoftest Druk op een toets om door te gaan. . .
Replace the comma and delims with ¦ and everything works
Code: Select all
%@Pre% @GetRandom
::
:: Retrieve a random number
::
::(
set "$Defines=@GetRandom"
::
set ^"$Usage.%$Defines%=^
% % Usage : %%@forA%% ( '"r#StoreVAR"¦"r?Mininmum"¦"r?Maximum"' ) %%%$Defines%%% %$n1c%
% % input: %$n1c%
% % r#StoreVAR: name of return variable %$n1c%
% % r?Mininmum: Lower boundary %$n1c%
% % r?Maximum : Upper boundary %$n1c%
% % ToConsole: %$n1c%
% % Contents of $StoreVAR %$n1c%
% % The output can be redirected. %$n1c%
% % Return: %$n1c%
% % $error: 0 for succes, panic otherwise "
::
set ^"%$Defines%=do ( %$n1c%
!@forTF! ( '"%$Defines%"¦"r#StoreVAR=%%~a"¦"r?Mininmum=%%~b"¦"r?Maximum=%%~c"' ) !@LeadIn! %$n1c%
rem !@forTS! ( "@DebugIn" ) !@CallMacro! %$n1c%
Setlocal EnableDelayedExpansion %$n1c%
call set /a $StdOut = %%Random%% %%%% ^^^^^^^( $Maximum - $Minimum + 1 ^^^^^^^) + $Minimum %$n1c%
!@forTS! ( %$n1c%
"^!$StoreVAR^!=^!$StdOut^!" %$n1c%
) !@PassOverEndlocal! %$n1c%
) ^&( %$n1c%
!@necho! %%~a : ^^^!%%~a^^^! [^^^!$0.error^^^!] %$n1c%
rem !@forTS! ( "@DebugOut" ) !@CallMacro! %$n1c%
!@LeadOut! %$n1c%
)"
::
%@forç% ( '$var, 0, 999' ) %@GetRandom%
::)
%@Post% @GetRandom [OK]
I can simply supress the error, the macro is unaffected:
Code: Select all
( for /f "usebackq tokens=1-26 delims=' " %%a in ( '$var, 0, 999' ) %@GetRandom% ) 2>nul
( for /f "usebackq tokens=1-26 delims=' " %%a in ( '$var, 0, 999' ) %@GetRandom% ) 2>nul
( for /f "usebackq tokens=1-26 delims=' " %%a in ( '$var, 0, 999' ) %@GetRandom% ) 2>nul
$var : 26 [ok]
$var : 120 [ok]
$var : 510 [ok]
<< Post Define @GetRandom [OK]
endoftest Druk op een toets om door te gaan. . .
Any expert wants to tell me what's going on ?