Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


waitforstring (test for error)

waitforstring (test for error)

waitforstring (test for error)

I have a spreadsheet with 100 account#s. The vba code goes thru each record and puts the account# on the attachmate screen. Then press enter. If account# exists, it goes to next screen. If account# doesn't exist, it stays on the current screen and displays error message. It then captures the error message and puts into Excel and goes to the next record.

This works. But is this the best way to do this?

Sess0.screen.PutString strAcct, 7, 22
Sess0.screen.MoveTo 12, 26
Sess0.screen.SendKeys ("<Enter>")

blnFound = Sess0.screen.waitforstring("_ MAIN MENU")
If blnFound = False Then
'capture error
ActiveCell.Offset(0, 12) = Trim(Sess0.screen.getstring(43, 2, 40))
GoTo MoveToNextRecord
End If

RE: waitforstring (test for error)


If it works, then run with it. There is almost always a marginally better way.

However, I'd advise you of one extremely important concept when dealing with a terminal emulator. Once you issue a Command via SendKeys(), it's like arriving at a STOP sign at an intersection in the road. The only way that you know that it's TIME to enter the intersection, is when you observe that no other vehicles will coincide with your vehicle's space as you proceed through the intersection. That is observational feedback. In a similar way, when you send a command to the mainframe from your emulator, the mainframe asynchronously processes the command and then returns the result to the emulator. That might take 1 ms, 1 min, never or anything between. Your code must observe the feedback and WAIT before executing the next statement in your code. Maybe something like...


Do Until oScrn.WaitForCursor(r, c)
...where r,c are the Rest Coordinates for that screen transaction.


glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: waitforstring (test for error)

The problem is I don't know where the cursor will land after [Enter].
Let's say cursor is currently at 27, 10 and it has to be here.
Then Enter.
If account is not found, cursor will stay at the same spot and a message will appear at the bottom of the screen.
If account is found, cursor will go to 1,3 on next screen.

I cannot use the below because it might never get there if account doesn't exist.
Do Until oScrn.WaitForCursor(1, 3)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close