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!

question on waitfor command

Status
Not open for further replies.

newmem

Programmer
Jul 23, 2002
35
US
Hi everybody!

I am a newbie for the ProComm/ASPECT script programming. And there is not much documentation available for ASPECT so I am totally stuck with this issue. -

I need to feed some line items to an ERP system thru screen scraping. These line items are stored in a comma delimited file. So far I have been able to connect/Logon to the remote system, open and read the file data.
The problem is the "waitfor" commands in the script to jump from the column1 to column 2 etc. I need to perform this column-to-column cursor jump in a loop (for each line in the file) and hence the parameters in the waitfor command should be dynamic. IS this possble to do? if not, what's the best way to accomplish this task?

===============
here's my sample script:

; variable declartion
string fileNm = "C:\myappln\test.req"

;Login to the remote system
connect TELNET "remote machineA"
waitfor "login: "
transmit "uid^M"
waitfor "password: "
transmit "pwd^M"

if fopen 0 fileNm READ TEXT ; Open file for read only
while not feof 0 ; Loop while not end of file
; get data from the file
fgets 0 LineBuffer ; Get line from file
strtok LineNum LineBuffer "," 1 ; Get the Line #
strtok EmpNum LineBuffer "," 1 ; Get EmployeeID
strtok Dept LineBuffer "," 1 ; Get Dept#
strtok phoneNo LineBuffer "," 1 ; Get phone#

; REM -- Strip out the quotes
strreplace LineNum "`"" ""
strreplace EmpNum "`"" ""
strreplace Dept "`"" ""
strreplace phoneNo "`"" ""

transmit EmpNum
transmit "^M"
waitfor "^[[4;16H"
transmit Dept
transmit "^M"
waitfor "^[[4;22H"
transmit phoneNo
transmit "^M"

endwhile
endif

endproc
===============
As you can see in the above script, the waitfor command has the following cursor's co-ordinates which would vary per each line. (in partcular the line posn i.e for the next line it shud be: waitfor "^[[5;16H" )
When I run this script, the after reading the first line, on the next line the command goes into the default wait period and then reads the string. This is way slow; for the input file has 100s of lines to be fed into the remote system.

Any help would be greatly appreciated.

Thanks so much for reading this long mail:)

newmem
 
When the remote system moves from field to field on the screen, does the cursor move as well? If so, you could use the getcur command to see which row and column you are in and then perform the necessary commands based on that information. I'm not certain if this method will be much faster, but it may be a little easier to automate that waiting for the screen positioning escape sequences.
 
thanks for the info. appreciate it.

I haven't tried the getcur command yet but meanwhile I attempted to take out the waitfor "^[[4;16H" commands from the script and it worked. The script now loops thru the file and transmits the data.

But here's another issue i am struggling:
After reading the dept value and before continuing on the phNo field, i have a waitfor commnd for a system prompt. Once the waitfor is completed the script would send the next field i.e phNo. Then the script would write the success/failure status to an output file and then continue with the next line feed of the file.

What's happening is while the system waits for the system prompt, the ASPECT script continues to run in the background and omits some records and transmits the current records its working on, to the remote system.
I used the "yield" command in the while loop but still no luck!

I desparately need to get over this issue:(
If anyone has come across a similar situation , pls let me know.

hanks.


 
I'm not quite sure what's going on, so could you please post the relevant portion of your script? That would let me get a better picture of what's happening I think.
 
sorry if I confused u. here's the script:
===========
; variable declartion
string fileNm = "C:\myappln\test.txt"
string resultFile = "C:\myappln\result.txt"
string outputline
integer len
string status = "Y"

;Login to the remote system
connect TELNET "remote machineA"
waitfor "login: "
transmit "uid^M"
waitfor "password: "
transmit "pwd^M"

if fopen 0 fileNm READ TEXT ; Open file for read only
fopen 1 rspfname write text ;Open result file

while not feof 0 ; Loop while not end of file

; get data from the file
fgets 0 LineBuffer ; Get line from file

if feof 0
fclose 0
fclose 1
endif

strtok LineNum LineBuffer "," 1 ; Get the Line #
strtok EmpNum LineBuffer "," 1 ; Get EmployeeID
strtok Dept LineBuffer "," 1 ; Get Dept#
strtok phoneNo LineBuffer "," 1 ; Get phone#
strtok UserType LineBuffer "," 1 ; Get UserType

; REM -- Strip out the quotes
strreplace LineNum "`"" ""
strreplace EmpNum "`"" ""
strreplace Dept "`"" ""
strreplace phoneNo "`"" ""
strreplace UserType "`"" ""

outputline = LineNum
strcat outputline ","
strcat outputline EmpNum

transmit EmpNum
transmit "^M"

transmit Dept
transmit "^M"

transmit phoneNo
transmit "^M"

waitfor "^[[KA'CCEPT OR R'EJECT: " 1
if SUCCESS
transmit "A^M"
endif

transmit UserType
transmit "^M"

;REM -- line read done, then set the status
if SUCCESS
status = "Y"
else
status = "N"
endif

strcat outputline status

;write the result
strlen outputline len
fputs 1 outputline

endwhile
endif

fclose 0
fclose 1
endproc

===========
 
actually I am having similar situation described in an earlier thread in this forum. ref. thread448-161693

thanks.
 
By default, the waitfor command will wait 30 seconds before continuing on with the rest of the commands in your script. If this is not long enough, you can specify the number of seconds that the waitfor command should pause by adding that number of seconds at the end of the waitfor command. Does that seem like it may be your problem?

Also, does it seems like you are getting the expected data in the LineNum, EmpNum, and so forth strings? One way you could check this would be to add these two lines to your script:

strfmt s0 "%s %s %s %s %s" LineNum EmpNum Dept phoneNo UserType
usermsg "%s" s0

This will display the values of these five strings so you can make sure the data was read and separated as you expect it to be. Add these two lines somewhere after the various strreplace lines.
 
Hi!

I verified that the data is being read and separated as expected.
While the screen cursor was waiting prior to the UserType string, the script prompted with the next 2 lines of the file. So when the cursor moved to the new line, the file position was moved to the 4th record in the source file.

Is there anyway to stop the script from looping to the next record before its done with the previous one?

 
I only see one waitfor command in your script and it waits only one second before continuing execution of your script. Is this a long enough delay for this portion? As for keeping the script looping, you would want to use a waitfor command at the end of the while loop to look for a message prompting for the next string of data or something similar - this will keep your script from reading and sending more data before the other side is ready.

Depending on how quick the application returns its results, you may want to use either the pause command or additional waitfor commands before each transmit command, just to make sure that you are not sending data faster than the remote system can process it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top