×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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

Jobs

Attachmate Macro - Using varieble in IF/THEN

Attachmate Macro - Using varieble in IF/THEN

Attachmate Macro - Using varieble in IF/THEN

(OP)
I'm trying to edit a condition in to an existing Attachmate macro I've created. I need the macro to check a certain location on the screen for the character that is there. If the character is an "L", the macro needs to kick back the dialog box for Location = L. Otherwise, it needs to carry on as normal.

I'm pretty inexperienced with VB, and haven't been able to find a way to 1) Pull the character at that location.(GetString?) 2) Create a check to see if it is an L, and perform the IF/Then statement.

CODE

If Location = L

Then

Begin Dialog userdialog1 80, 41, "800L ALERT"
   Text  15, 5, 55, 10, "LOCATION = L!"
   CancelButton  15, 20, 50, 14
End Dialog
dim mydialog1 as userdialog1
dialog mydialog1



Else


Begin Dialog userdialog2 115, 44, "800L ALERT"
   Text  40, 5, 35, 10, "Set alert?"
   OkButton  5, 20, 50, 14
   CancelButton  60, 20, 50, 14
End Dialog
dim mydialog2 as userdialog2
dialog mydialog2


    Sess0.Screen.PutString "narr", 3,12
        Sess0.Screen.Sendkeys("<Enter>")
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
 
Date1 = Sess0.Screen.GetString (08,11,02)
Date2 = Sess0.Screen.GetString (08,14,02)
Date3 = Sess0.Screen.GetString (08,17,04)
HWFS  = Sess0.Screen.GetString (24,08,07)
 
        Sess0.Screen.MoveTo 7,39
        Sess0.Screen.Sendkeys("<Pf6>")
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
    Sess0.Screen.PutString Date1,18,24
        Sess0.Screen.PutString Date2,18,27
        Sess0.Screen.PutString Date3,18,30
        Sess0.Screen.PutString "CR",18,41        
    Sess0.Screen.PutString Date1,18,50
        Sess0.Screen.PutString Date2,18,53
        Sess0.Screen.PutString Date3,18,56
        Sess0.Screen.Sendkeys("<Enter>")    
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime2)
        Sess0.Screen.MoveTo 20,17
        Sess0.Screen.Sendkeys("800L: see narr ")
        Sess0.Screen.PutString Date1,20,32
        Sess0.Screen.PutString "/",20,34
        Sess0.Screen.PutString Date2,20,35
        Sess0.Screen.PutString "/",20,37
        Sess0.Screen.PutString Date3,20,38
        Sess0.Screen.PutString " ",20,42
        Sess0.Screen.PutString HWFS,20,43
        Sess0.Screen.Sendkeys("<Enter>")
        
    System.TimeoutValue = OldSystemTimeout

End If

End Sub

RE: Attachmate Macro - Using varieble in IF/THEN



hi,

the syntax for If...Then...Else is...

CODE

IF expression Then
'  stuff to do when expression is TRUE
Else
'  stuff to do when expression is FALSE
End If
You have Then on a separate line, which is interpreted as a different statement.

 

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Attachmate Macro - Using varieble in IF/THEN

(OP)
Yar. I think that's just a formatting error from when I pulled it over. It's correct in my code. The issue I am having is how do I capture the information at that location, recognize if it is an "L" or not, and then finish out the macro based on which one it is?

RE: Attachmate Macro - Using varieble in IF/THEN



Quote:

how do I capture the information at that location
Use GetString.  But you must know the row,col coordinates.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Attachmate Macro - Using varieble in IF/THEN

(OP)
Thanks for the quick replies. It seems like I am close with what I have, but it's still not working. Even when there is an L in the location I've pointed it at, it still runs the macro as though it wasn't.

Here's the full code

CODE

Location = Sess0.Screen.GetString (04,74)

        
If Location = "L" Then

Begin Dialog userdialog1 80, 41, "800L ALERT"
   Text  15, 5, 55, 10, "LOCATION = L!"
   CancelButton  15, 20, 50, 14
End Dialog
dim mydialog1 as userdialog1
dialog mydialog1



Else


Begin Dialog userdialog2 115, 44, "800L ALERT"
   Text  40, 5, 35, 10, "Set alert?"
   OkButton  5, 20, 50, 14
   CancelButton  60, 20, 50, 14
End Dialog
dim mydialog2 as userdialog2
dialog mydialog2


    Sess0.Screen.PutString "narr", 3,12
        Sess0.Screen.Sendkeys("<Enter>")
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
 
Date1 = Sess0.Screen.GetString (08,11,02)
Date2 = Sess0.Screen.GetString (08,14,02)
Date3 = Sess0.Screen.GetString (08,17,04)
HWFS  = Sess0.Screen.GetString (24,08,07)
 
        Sess0.Screen.MoveTo 7,39
        Sess0.Screen.Sendkeys("<Pf6>")
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
    Sess0.Screen.PutString Date1,18,24
        Sess0.Screen.PutString Date2,18,27
        Sess0.Screen.PutString Date3,18,30
        Sess0.Screen.PutString "CR",18,41        
    Sess0.Screen.PutString Date1,18,50
        Sess0.Screen.PutString Date2,18,53
        Sess0.Screen.PutString Date3,18,56
        Sess0.Screen.Sendkeys("<Enter>")    
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime2)
        Sess0.Screen.MoveTo 20,17
        Sess0.Screen.Sendkeys("800L: see narr ")
        Sess0.Screen.PutString Date1,20,32
        Sess0.Screen.PutString "/",20,34
        Sess0.Screen.PutString Date2,20,35
        Sess0.Screen.PutString "/",20,37
        Sess0.Screen.PutString Date3,20,38
        Sess0.Screen.PutString " ",20,42
        Sess0.Screen.PutString HWFS,20,43
        Sess0.Screen.Sendkeys("<Enter>")
        
    System.TimeoutValue = OldSystemTimeout

End If
End Sub

RE: Attachmate Macro - Using varieble in IF/THEN



CODE

Location = Sess0.Screen.GetString (04,74,1)
I usually make it a practice when scraping a screen to Trim the result...

CODE

Location = Trim(Sess0.Screen.GetString (04,74,1))
 

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Attachmate Macro - Using varieble in IF/THEN

If I'm debugging, I'll find out what the macro is reading so after

CODE

Location = Sess0.Screen.GetString (04,74,1)
(adding the extra ",1" as Skipvought says)

I would temporarily bung in

CODE

msgbox Location
so you can see what it's actually picking up

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!

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