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

copy files frm a text file 1

Status
Not open for further replies.

lagba

Programmer
Nov 8, 2001
3
US
Im trying to get the script to read from a txt file named friends.txt. The problem is that when it finishes reading the first line of Friend.txt it goes to the next line of friends file without finishing executing the rest of the code. The code stops at waitfor "SARC" and loops back to the next line of the txt.file.I am basically tring to copy the text file into a meridian switch. The text file has like 4000 line items which needs to be imported into the switch. Help!
This is my script below.....................................
............................................................

proc main
string Fname = "c:\friends.txt" ;filename
string authcode[100] ;Get up to 100 entries
string Line ;Place entries in the Line buffer
;string szSpace="'r'n"
integer Counter=0 ;Place pointer to the first line
if fopen 0 Fname READ TEXT ;Open file as read-only
while not feof 0 ;continue loop until the end of file
fgets 0 Line
Authcode[Counter]=Line ;Counter reacts on Line Buffer
Counter++ ;Counter will Loop 1 Line at a time
transmit "^M" ;Sends carriage return
waitfor "REQ " ;Waits for the REQ prompt from the system
transmit "NEW^M" ;Send "NEW"
waitfor "TYPE " ;Waits for the TYPE prompt from the system
transmit "AUT^M" ;Send "AUT"
waitfor "CUST " ;Waits for the CUST prompt from the system
transmit "0^M" ;Send 0
waitfor "SPWD " ;Waits for the SPWD prompt from the system
transmit "RED^M" ;Send FORD [Needs to be change to 0000 ]
waitfor "CODE " ;Waits for the CODE prompt from the system

transmit "^M" ;Sends Carriage Return
termwrites Line RAW ;Prints Line from Bu

waitfor "SARC "
transmit "^M"
waitfor "CLASS "
transmit "1^M"

endwhile ;Begins loop
else
transmit "^M"
endif

endproc
 
Are you saying that none of the transmit or waitfor command between the fgets command and the waitfor "SARC " command are executing? Your script looks just fine to me. I assume you are making a connection to the switch and then running your script?

One thing you might want to try is adding a breakpoint command after the fgets command, compiling a debug script, and then stepping through your script using the run-time debugger to see if your script is hanging up in some spot. To do this, bring up the ASPECT Editor, select the Tools | Compiler Options menu item, and check the Compile for debug checkbox. When you run your script, you should get the ASPECT Run-Time Debugger window. You can execute your script line-by-line by clicking on the Step button. You might also want to check the value of the different variables in your script, specifically Line, during the execution of your script.
 
Thanks for your help.
The scripts runs fine up to "termwrite line Raw". The problem is it does not "waitfor "SARC" and "CLASS" before lopping to the next line in the text file. I really need all the help I can get. Thanks
 
It looks to me that you should to replace the termwrites command with transmit. Termwrites just displays the string in your local Procomm window, but does not send it to the remote system. If your intention was to send the contents of Line to the switch, then changing termwrites to transmit will hopefully do the trick.
 
Thanks very much. You just saved my life. It worked !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top