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

Looping a script

Status
Not open for further replies.

Meah1

Programmer
Mar 26, 2007
7
US
I have written a simple script that removes key 0 from a set. this script is a manual script which will require manual input of TN and set type. The problem I am having is that I need this script to loop back around to the beginning after a set has been changed. Is there a command that restarts the script without the user restarting?
 
ops, my two attempts.
without a loop or restart.
proc main
transmit "chg^M"
waitfor "TYPE: "
transmit ""
waitfor "TN "
transmit ""
waitfor "ECHG "
transmit "yes^M"
waitfor "ITEM "
transmit "key 0 nul^M"
waitfor " KEY "
transmit "^M"
waitfor "ITEM "
transmit "^M"
endproc

attempt at looping or restarting the script
proc main
Set txpace 500
#define TRUE 1


transmit "chg^M"
waitfor "TYPE: "
transmit ""
waitfor "TN "
transmit ""
waitfor "ECHG "
transmit "yes^M"
waitfor "ITEM "
transmit "key 0 nul^M"
waitfor " KEY "
transmit "^M"
waitfor "ITEM "
transmit "^M"
transmit "chg^M"
while TRUE
endwhile
endproc

 
Aspect has both for-loops and while-loops that you can use
to repeat an operation a set number of times.
Here's an example of how you could change KEY 0 on
all sets in loop 3, 4 and 5
Code:
 ;Changes all 3903 sets in spesified loops and units.         
proc main
string loopunittxt
integer loopnr, unitnr

; Turn on Capture so we have a record of what we'v done.
capture on

; Lets make sure were in the right load.
transmit "****"
pause 2
transmit "LD 20^M"
waitfor "REQ: "

for loopnr=3 upto 5       ; loop 3 - 4 and 5
  for unitnr=0 upto 15    ; unit 0 to 15
   transmit "chg^M"
    waitfor "TYPE: "
    transmit "3903^M"
    waitfor "TN   "
    strfmt loopunittxt "%d %d^M" loopnr unitnr
    transmit loopunittxt
    waitfor "ECHG "
    transmit "yes^M"
    waitfor "ITEM "
    transmit "key 0 nul^M"
    waitfor "     KEY "
    transmit "^M"
    waitfor "ITEM "
    transmit "^M"
    waitfor "REQ: "
  endfor
endfor

; Turn Capture off.
capture off

endproc

(typed, not tested as I'm not on a Windows-maschine right now)

Check the Procomm buildt-in help function and the
PDF-files on the install-CD for details and examples
on how to use Aspects many commands.
There are lots of commands in Aspect, and you can build quite advanced scripts with them when you learn how to use them.
Procomm can even read the TN-pos from an excel-sheet,
and write e.g. the new DN back into that same sheet.

HTH
:)
 
Not sure I understand your response. I am trying to repeat a string of commands. My first script needs to restart so that the user does not have to restart the script manually for every phone. They need to be able to enter manually the TN and set type, everything else just needs "loop" around to the top of the script.
 
OK, then just remove the lines that transmit those values:
transmit "3903^M"
and
strfmt loopunittxt "%d %d^M" loopnr unitnr
transmit loopunittxt

the script will stop at those lines then allowing the user
to manualy enter the values.
Remove one of the for-loops and adjust the values so you get
the number of loops you need.
You can also terminate the script with the "Running man-key" on the toolbar.
 
heres what I found that works great. Thanks for all the input

#define TRUE 1
proc main

Set txpace 200
while TRUE
transmit "chg^M"
waitfor "TYPE: "
transmit ""
waitfor "TN "
transmit ""
waitfor "ECHG "
transmit "yes^M"
waitfor "ITEM "
transmit "key 0 nul^M"
waitfor " KEY "
transmit "^M"
waitfor "ITEM "
transmit "^M"
pause 2
endwhile
endproc
 
Yepp, that should work.

Tip 1: You can simply use
while 1
---
---
endwhile

to make a loop, no need to use a variable.

Tip 2: You dont need the
transmit ""
lines. Your not sending anything anyway.

 
awesome, I will slim it down. Thanks again for all your help/input,
 
Code:
 transmit "chg^M"
   waitfor "TYPE: "
   transmit ""
   waitfor "TN   "
   transmit ""
   waitfor "ECHG "
   transmit "yes^M"
   waitfor "ITEM "
   transmit "key 0 nul^M"
   waitfor "     KEY "
   transmit "^M"
   waitfor "ITEM "
   transmit "^M"
   transmit "chg^M"
 while TRUE      
   endwhile

i tend to use this one if i am manually adding the tn and set type

Code:
proc main

transmit "****^M"
mspause 1
transmit "ld 11^M

 waitfor "REQ: "

loop:
   transmit "chg^M"
  
   waitfor "ECHG "
   transmit "yep^M"
   waitfor "ITEM "
   transmit "key 0 nuk^M"
   waitfor "KEY "
   transmit "^M"
   waitfor "ITEM "
   transmit "^M"
   waitfor "NACT "
   
   transmit "^M"
   
   waitfor "REQ: "
   
   goto loop
   
endproc

for larger changes i usually pull data from a comma delimited..


john poole
bellsouth business
columbia,sc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top