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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get argument of the command line

Status
Not open for further replies.

polluxtech

Programmer
Dec 14, 2009
15
CN
when a execute the script using command line below:
PW4 script.wax arg0 arg1 arg2 arg3

How to get the values of arg2 arg1 arg2 arg3 in the main proc.

 
I couldn't find this immediately in the help file, but I believe the number of passed arguments will be in the global predefined integer variable i0 with each argument being the global predefined string variables, starting at s0 and moving up through s9.

 
yes, you are right. Rock!
Thanks knob.

But i have another question.
How to interact with the term? for example: i have to write a script that get user input from term and then decide what to do next.
how to do this? thanks
 
There are a couple different ways you can get the input (and in this case I'm presuming you mean information sent from the remote system and not the user sitting at the computer with Procomm) depending on how involved the text you are trying to capture.

Probably the simplest method is using the rget command to grab incoming input. One potential downside of this command is that it "steals" data from Procomm and keeeps it from appearing on the screen. You might also have to use multiple rget commands to get all of the data or the right string of data, or use the set aspect rgetchar command to tweak some of the rget settings (usually not required though).

What I usually prefer to do is save the current screen using the snapshot command, then open that text file and search for the data I need using the strfind command. I think there is code here or on my website that shows how to open a text file, read through it line by line, then close it, but let me know if you can't find that.

 
hi knob,
thanks for you help!
please show me the file link. I can not find this source code on your website.
 
Here's the script (chopped a few extraneous bits out):

proc main
string sNum

if fopen 0 "numbers.txt" READ TEXT ;Open text file
while not feof 0 ;While data remains in the file
fgets 0 sNum ;Get entry from file
if not nullstr sNum ;If entry is not blank
;perform operations here...
endif
endwhile
endif
fclose 0 ;Close data file
endproc

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top