Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Just a Question

Status
Not open for further replies.

JGoudie

Programmer
Jun 17, 2002
16
0
0
CA
Is it possible to send parameters to a script? I mean, if i hook up a script to execute from say a Meta Key button. can i send parameters that i can then use inside my script to determine what it should do?
 
Yep, when you start a script from the command line, you can pass values to the predefined global string variables (s0-s9). The format is:

pw5.exe [file.wax | file.was [argument list]]

(from the help file):
This optional argument specifies an ASPECT script file for Procomm Plus to execute. If a .was file is specified, the ASPECT Compiler first compiles the script and upon successful compilation, the associated .wax file is executed. Any arguments following the script name are passed to the script in the predefined variables.

Here's a snippet from elsewhere in the help file (took me a while to dig this up as it's hidden pretty well):

Predefined variables have several uses. If Procomm Plus is executed with a command-line in which the first parameter is a script file name, with either a .was or .wax extension, the information following the filename will be parsed into individual options. Each option will be loaded into a predefined string variable, beginning with S0. Up to 10 options can be passed to the requested script in this manner. The predefined integer variable I0 will contain a count of the parsed options. The script can use the system variable $SCRIPTMODE to determine whether it was run from the command-line, and reference I0 for the number of options provided.

After your script has the values in s0-s9, you can then use commands like atof, atoi, and atol to convert the string to a float, integer, or long value.
 
knob, how do you test the value of $SCRIPTMODE? The following code does not compile:

if $SCRIPTMODE = 3
bla bla
else
bla bla
endif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top