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!

Getting a line skipped in text file

Status
Not open for further replies.

Agnes2k

Technical User
Jul 7, 2002
2
AU
Greetings all,

I'm still a beginner to Aspect scripting and am trying to grasp how I can skip a line in a text file. I have the following script below and am slowing trying to grasp opening a text file but cannot find how I skip lines in the text file when I encounter a target condition. Your help will be greatly appreciated.

the text file is in this format
902101,7
902103,7
902104,7


the script that i have is listed below.

proc main
fopen 1 "C:\Program Files\Procomm Plus\Capture\authcode.txt" READ

if failure
usermsg "could not open the file."
else
transmit "****"
transmit "ld 88^M"
waitfor "REQ"
transmit "new^M"
waitfor "TYPE "
transmit "aut^M"
waitfor "CUST "
transmit "0^M"
waitfor "SPWD "
transmit "^M"

;pause 1
fseek 1 0 0
while not feof 1
fgets 1 s0
strtok s1 s0 "," 1
strtok s2 s0 "," 1
DelLineFeed (&s2)
strlen s1 i0
if (i0 > 1)
ld88auth()
else
Transmit "****^M"
halt
endif
endwhile
endif
endproc

proc ld88auth
when TARGET 1 "AUTH009" call skipline
when TARGET 2 "AUTH005" call skipline

waitfor "CODE "
transmit s1
transmit "^M"
waitfor "SARC "
transmit "^M"
waitfor "CLAS "
transmit s2
;transmit "^M"
endproc


PROC DelLineFeed
param string szStr
integer Pos
strlen szStr Pos
if (Pos > 2)
strDelete szStr (Pos-1) 1
endif
endproc


PROC skipline
???????

 
A when target command is only valid for data that is received by Procomm, not on data that is read from a file. If you want to skip a line that matches a particular pattern, you can use an if strfind clause after you have read that line.


aspect@aspectscripting.com
 
Knob,

Sorry I did not explain my problem correctly, what I mean is that I want to write 902101,7 as s1 and s2 but if the PABX already has s1 in there it will come back with the "AUTH009" and "AUTH005" error. If this event takes place I want the script to skip the line in the text file and go to 902103,7 and use that as s1 and s2.

Thanks for your response.

 
Does the system return a different message if the value read from the file should be processed? If so, you could merge a script that another user sent to me a while back that waits for three possible strings to arrive (using a procedure that sets three when target commands), and then the main script would act accordingly based on the value contained in a global integer. You can find that script here:


I've used it in a couple different projects and think it would work well in your situation (better than the separate when targets you have now) since the script would be looking for all three possible strings (AUTH009, AUTH005, and the string returned by the system when it is OK to process the values from the file) at the same possible time. All you would need to do after calling the WaitList procedure in the above script is check the value of WaitListStat after the procedure call with an if/elseif/elseif structure and act accordingly.


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top