Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: passing parameters variable substitution command line
You can pass parameters to WinBatch when you run the program with the following command line:
"c:\program files\winbatch\system\winbatch.exe" "c:\xxx\myfile.wbt" "\\dept-9 fred 3456"Will launch the myfile.wbt and set special internal values in myfile.wbt to:
param1="\\dept-9" param2="fred" param3=3456param0 tells you how many you have. 9 parameters max:
WINBATCH.EXE filename.wbt p1 p2 ... p[n]
"filename.wbt" is any valid WBT file, and is a required parameter. "p1 p2 ... p[n]" are optional parameters to be passed to the WBT file on startup, delimited by spaces. (note: versions previous to 2003G are limited to maximum of nine)
Parameters passed to a WBT file are automatically parsed into variables named: param1, param2, etc. An additional variable, param0, is the total number of command-line parameters.
To display the total number of command line parameters, use param0 as a variable in a message box.
Passing Parameters From the Command Line
If you "run" a WBT file directly, using the file association capability of Windows, it will not receive any command line parameters. In order to pass parameters to a WinBatch file, you must run the WinBatch Executable, followed by the name of the WBT file and any other desired parameters.
WBT files which are launched from the Program Manager as icons must have the complete path in the Properties dialog box in order for command line parameters to be received. The command line for "SOL.WBT" generally reads, "C:\WINBATCH\SOL.WBT". However, it is necessary to add the WinBatch executable to complete the path, so in this case it would read: "C:\WINBATCH\WINBATCH.EXE SOL.WBT".
Passing Parameters Between WBT's
To pass command line parameters from one WBT to a called WBT, place % signs around the variables (as in %variable%) when you're inside quoted strings. But watch out! Read "Important Note on Variable Substitution" below on correct way to do it in your file.
For Example:
The first WBT calls a second WBT then passes three parameters.
Call("test.wbt", "Fred Becky June")
TEST.WBT contains the following line:
Message("Names are", "%param3% %param2% %param1%")
Example: start winbatch.exe proc.wbt 70141180.34
The problem is that once inside the program the last character of the filename is being truncated. Any ideas?
Here is a code snippet:
;proc.wbt infile = %param1% tstring = StrSub(infile,1,8) message(infile,infile) ;<=== This outputs 70141180.3 ; === instead of 70141180.34 ==
infile = param1 tstring = StrSub(infile,1,8) message(infile,infile); <============= This outputs 70141180.34 ==What was happening was that because of %substitution% the
infile = %param1%line became:
infile = 70141180.34So then it decided that infile must be a floating point number. But we only keep 9 digits of precision for floating point numbers, so it lost the last digit.
If you just do:
infile = param1then this is a normal variable assignment, and the value held in the param1 variable is passed unmolested into the infile variable
The rule is that you do not generally need (or want) to use %substitution% EXCEPT as a quick and dirty shortcut inside quoted strings.
Article ID: W13915
Filename: Passing Parameters on Command Line.txt
File Created: 2003:04:24:12:26:20
Last Updated: 2003:04:24:12:26:20