The WinBatch Console supports a special form of user-defined procedure called a user-defined command (UDC) . A #DefineCommand user-defined procedure is similar to a WIL user-defined subroutine because it has the same 'caller' scope as #DefineSubroutine user-defined subroutine . However, UDC's can only be called from WinBatch Console. Calls are ignored in scripts executed with regular WinBatch. The #DefineCommand syntax also differs because it does not need opening and closing parentheses and it uses spaces instead of comas as parameter separators. Also note that parameters can be any legal WIL expression but not WIL statements like a structured if, immediate if, any loop structures, an exit, or a goto.
(WinBatch Console only) A #DefineCommand UDP is defined as follows:
#DefineCommand functname param1 param2 param3 param4 …param16 <code> Return retval #EndCommand
Example:#DefineCommand ls _path ; Default to current directory. If _path=='' Then tmp=DirGet():'*.*' Else tmp=_path delim=IntControl(29,@lf,0,0,0) files=FileItemize(tmp) IntControl(29,delim,0,0,0) Cout files Return 1 #EndCommand
See Also:
WARNING: Use at your own risk. The variables used within a #DefineCommand have 'caller' scope, which means the Variables are shared with the calling routine. We suggest using a special naming convention on the variables inside a #DefineCommand. The Drop and DropWild functions, can be used to dispose of any unwanted variables at the end of the routine. UDC Special Notes:
|
|