I thought so, too. I recall the aggravation of interpreting arguments while using SHIFT, which intrudes on the order of things, by definition. Here is a non-intrusive quick check for a keyword in up to the first nine arguments:In Topic, Re: Passing batch argument to Choice command, Sponge Belly wrote:Aacini wrote:Code: Select all
set "vars=apl1=2,apl2=,apl3=kup,aplN=etc"
set "%vars:,=" & set "%"
Brilliant!
Code: Select all
:: KeywordArg.bat version 0.0 posted by TheFeDuke
::
:KeywordArg arguments[Opt] - only the first nine are checked
@Echo Off&SetLocal EnableDelayedExpansion
:: This technique is based on:
::
:: Post subject: Re: Passing batch argument to Choice command
:: Posted: Sun Apr 24, 2016 11:39 am by Aacini
:: http://www.dostips.com/forum/viewtopic.php?p=46412#p46412
Set "vars=arg1=%~1,arg2=%~2,arg3=%~3,arg4=%~4,arg5=%~5,arg6=%~6,arg7=%~7,arg8=%~8,arg9=%~9"
Set "%vars:,=" & set "%"
For /L %%I In (1 1 9) do (
set "arg=!arg%%I!"
Rem.In this particular example the rightmost argument takes effect.
If /I "!arg!" EQU "/?" (Set "HelpSw=1"&Echo()
If /I "!arg!" EQU "/??" (Set "HelpSw=2"&Echo()
)
If /I "%HelpSw%" EQU "1" Echo(Arguments include '/?' to indicate a desire for syntax Help.
If /I "%HelpSw%" EQU "2" Echo(Arguments include '/??' to indicate a desire for detailed Help.
Exit /B
Code: Select all
@Echo Off&SetLocal EnableDelayedExpansion
Set "KeyWordSw=0"&Set "KeyWord=/?"
Set "vars=arg1=%~1,arg2=%~2,arg3=%~3,arg4=%~4,arg5=%~5,arg6=%~6,arg7=%~7,arg8=%~8,arg9=%~9"
Set "%vars:,=" & set "%"
For /L %%I In (1 1 9) do (Set "arg=!arg%%I!"
If /I "!arg!" EQU "%KeyWord%" Set "KeyWordSw=1")
If /I "%KeyWordSw%" EQU "1" Call :aKeyWordRoutine
John A.