Command GroupingCommand grouping allows one or more commands to be specified in place where only a single command is allowed. To group command together enclose all the commands in brackets (ie. ( and ) ) and separate them with the default multiple command character. There are three situations where command grouping is allowed, as follows :-
D:\WINDOWS> IF "%VAR%"=="" ( When a command in a batch program contains unbalanced brackets, WinOne® will simply continue to concatenate the next command line(s) in the batch program, until the complete command contains balanced brackets. A command line can contain a maximum of 1023 characters. This includes any command lines that have been concatenated together. When using environment variables with command grouping, they are instanciated as soon as the complete command is determined. This has a very undesirable effect. Consider the following batch program :- SET VAR=1 Running the above batch program displays 1 on the first line and then displays 2 on the next line. This occurs since the first ECHO %VAR% is instanciated before the SET VAR=2 command is executed. This appears to be the standard behaviour when using brackets for command grouping (eg. CMD.EXE). WinOne® extends command grouping to allow for delayed environment variable instanciation, by grouping commands in braces (ie. { and } ), instead of brackets. When braces are used in a command line, then any environment variables that are specified inside the braces are not instanciated, until a command, inside the braces, is about to be executed. Consider the following batch program :- SET VAR=1 Running this batch program, produces the desired effect. That is, 2 is displays on both lines. Note:
|
|
|
|
|
|
|
Copyright © 1995-2005 Lucien Cinc, All Rights Reserved
WinOne is an Australian registered trademark of Lucien Cinc