Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

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

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I just wanted to say THANKS for the forum. The knowledge I gain from your site is invaluable..."

Geography

Where in the world do Tek-Tips members come from?
finitesimian (Programmer)
14 Sep 06 13:43
I am trying to make a script that executes keystrokes/actions based on data visible to a progression of screens, unfortunately my script will not execute some of the actions whenever it progresses to the next screen. I'm probably missing something relatively simple- can you tell me where I'm going wrong?

CODE

Sub Main()
' Get the main system object
  Dim Sessions As Object
  Dim System As Object
  Set System = CreateObject("EXTRA.System")
  Set Sessions = System.Sessions

' Get the necessary Session Object
  Dim Sess0 As Object
  Set Sess0 = System.ActiveSession
  If (Sess0 is Nothing) Then
  STOP
  End If
  If Not Sess0.Visible Then Sess0.Visible = TRUE
  Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

'---------------------------------------------------

'obtains data from the first screen and takes action based on data

  Dim variable1 As Object
  Set variable1 = Sess0.Screen.area(row1,col1,row2,col2)
  Select case variable1
      case "something"
         'sends a keystroke which makes it go to the next screen
         Sess0.Screen.Sendkeys("<pf6>")
         'gets data from next screen....this is where my code doesn't want to work
         Dim screen2variable As Object
         Set screen2variable = Sess0.Screen.area(row1,col1,row2,col2)
         'takes action based on data from screen 2
         Select Case screen2variable
         case "something2"
           Sess0.Screen.MoveTo row1,col1
           Sess0,screen.SendKeys("writesomething<Enter>")
           Stop
         Case "alternative"
           Stop"   
         End Select

      Case "something_else"  
         'takes a different action  
         Sess0.screen.Sendkeys("<pf8>")
         Stop
  
  End Select
End Sub
Ebenezum (Programmer)
14 Sep 06 14:55
Try taking the row and col out and just leave 1,1,2,2 and then check your variable. It should then have a value.

Set variable1 = Sess0.Screen.area(row1,col1,row2,col2)
finitesimian (Programmer)
14 Sep 06 16:07
I wrote it that way just to demonstrate what my code is doing. In reality, it doesn't literally say "row1" and so on.
Helpful Member!  Skie (Programmer)
14 Sep 06 16:22

CODE

Sess0.Screen.Sendkeys("<pf6>")
Do you need a wait here? I would guess your code is proceeding before the new screen loads and running into the the case with "Stop".
Dim screen2variable As Object
finitesimian (Programmer)
15 Sep 06 14:27
Can you give me a tip for creating a wait?
calculus (Programmer)
15 Sep 06 16:02
Use a wait to determine when Extra has finished the last request.

For instance, if the user knows that the word "done" appears at location 2,3 then:
rc% = sess0.screen.waitforstring "done",2,3

You can also leave off the Row/Col and it will look over the whole screen.

calculus
Skie (Programmer)
15 Sep 06 19:05
One thing you can do if you don't know what data will appear next is something like this:

CODE

Function WaitForScreenChange
    strOld=objScreen.area(1,1,24,80,,3)
    strNew = strOld
    objScreen.SendKeys("<pf6>")
    For i = 0 to 500
        strNew=objScreen.area(1,1,24,80,,3)
        if strOld<>strNew then Exit For
        Do Events
    Next
    If i > 499 then
        objScreen.WaitHostQuiet(1000)
        strNew=objScreen.area(1,1,24,80,,3)
    End If
    WaitForScreenChange = strNew
End Function

This is some code I wrote awhile ago and I'd probably eliminate the for loop and use a timer (for like 5-10 seconds total) using the system time instead.  That way faster machines wouldn't hit the WaitHostQuiet as quickly.

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!

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