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

Scripting error

Status
Not open for further replies.

icetea

Technical User
Nov 28, 2002
45
US
Can someone help? I have written a script to change which node of phonemail someone is on. But when I run it it will only do line one of the text file.
File Strarts here.

proc main
string sLine ;Line read from text file
integer iLen ;Integer to hold length of read string
string sExtOne ;First extension from line read from text file
string sExtTwo ;Second extension

transmit "pro^M"
waitfor "Action: "
transmit "mov^M"
if fopen 0 "A:\sale1.txt" READ ;Open text file" if fopen 0 FnameRead"
while not feof 0 ;While there is data to be read from the text file
fgets 0 sLine ;Get line of data
strlen sLine iLen ;Find length of line
if iLen == 0 ;If zero, then we have read a blank line and are at the end
exitwhile ;Exit while loop
endif
strtok sExtOne sLine "," ;Get data before the comma
strreplace sExtOne "`"" "" ;Delete quotes from the string
sExtTwo = sLine
strreplace sExtTwo "`"" "" ;Delete quotes from remaining data
strreplace sExtTwo "," "" ;Get rid of extra comma
strreplace sExtTwo ";" "" ;Get rid of extra semi-colon too
waitfor "Subscriber Name or Extension: "
transmit sExtOne
transmit "^M"
waitfor "Do you want to move this profile (Y/N)? "
transmit "y^M"
waitfor "Enter destination node number: "
transmit sExtTwo
transmit "^M"
waitfor "move profile complete. "

endwhile
endif
fclose 0
endproc

Text file it reads.
"872460","1"
"872461","1"
"872462","1"
"872463","1"


Error received.

Subscriber Name or Extension: 872460

Node: 3
Name: Training one
Extn[1]: 872460

Do you want to move this profile (Y/N)? y
Enter destination node number: 1pro
Moving profile to node 1
Moving name header ... Complete.
Moving personal greetings ... Complete.
Moving user messages ... .Complete.
Moving profile data ... Complete.
Move profile complete.
Subscriber Name or Extension:

Cannot find this form.

Subscriber Name or Extension:


 
Try changing your fopen command to read:

if fopen 0 "A:\sale1.txt" READ TEXT ;Open text file" if fopen 0 FnameRead"

You might also try adding this line as a troubleshooting guide after the fgets command:

usermsg "%s" sLine

This will display the current line read from the file and you can see if the value looks correct or not.

Also, this error at the end of the capture you posted causes me some concern:

Cannot find this form.

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

Part and Inventory Search

Sponsor

Back
Top