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!

repeat a waitfor command? 1

Status
Not open for further replies.

newmem

Programmer
Jul 23, 2002
35
US
Hi,

We have a situation here - The remote system is performing daily batch updates. During this process, the system prompts for "Do you want to print batch # (N)?" for all the OPEN batches in the system. where N = batch no.
When all the batches (this range can differ daily) are done, the screen would display
"Enter Printer #". The user then enters the priner # and the process is over.

My problem is, I don't know upfront how many times the waitfor "Do you want to print batch # (N)?" comand needs ro be repeated. That is, if I use a for loop or a while loop.
My questions are:
1. How do I set the counter to repeat the command &quot;Do you want..&quot;, alongwith the argument for the batch no. (batch no can start from 1 or any high number but < 100)
2. How to exit out of the loop to transmit the command &quot;Enter Printer #&quot; when step 1 is completed.

I would appreciate for any help or advice.

Thanks in advance.
newmem


 
You could use the when target command to do this. This command can look for a certain piece of text, then call a procedure when it is received. Here is some sample code that may work for you:

proc main
when target 0 &quot;Do you want to print batch&quot; call press_enter
when target 1 &quot;Enter Printer #&quot; call print_file

while 1
yield
endwhile
endproc

proc press_enter
transmit &quot;^M&quot;
endproc

proc print_file
transmit &quot;^M&quot;
pwexit
endproc

I don't know what you press when the &quot;Do you want to print batch # (N)?&quot; and &quot;Enter Printer #&quot; messages are displayed, so I assumed a carriage return (^M) in those procedures. Finally, I added a pwexit command to the print_file procedure so that the script has a way to exit (I assumed the script would be complete when you send the file to the printer, so this may need to be modified by yourself).
aspect@aspectscripting.com
 
Thanks knob. It worked like a charm.

This forum has been very helpful & hosts some great experts who are willing to share thier knowledge.

Good Job!

newmem
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top