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!

*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.

Jobs

Attachmate Comparation

Attachmate Comparation

(OP)
Hi!!!

I was able to search for a String named "T628100", but I can not figure out how to make a comparison if it does not find the text.

Example: If you did not find this information, it would look on the bottom line and if it did not find it again press F8

CODE --> vba

Set System = CreateObject("EXTRA.System")
    Set Sessions = System.Sessions
    Set Sess0 = System.ActiveSession
    Set MyScreen = Sess0.Screen

    MyScreen.MoveTo 2, 2
    Set MyArea = MyScreen.Search("T628100")
    MyScreen.MoveTo MyArea.Bottom, MyArea.Right + 1
    MyScreen.SendKeys ("<Up>")

if .........

MyScreen.SendKeys ("<PF8>")

end if 

Sorry, I do not speak fluent English and I'm a beginner in programming.

Help me please

RE: Attachmate Comparation

Hi,

CODE

‘
   Set MyArea = MyScreen.Search("T628100")

   If MyArea Is Nothing Then
      ‘Could not find search string on this screen
      MyScreen.SendKeys (“<PF8>”)
   Else
      ‘ found search string on this page at...
      MsgBox MyArea.Value & “ found at row “ & _ 
             MyArea.Row & “ column “ & MyArea.Column
   End If 

Skip,

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

RE: Attachmate Comparation

(OP)
Hello SkipVought,

Thanks for answering!

That's fine, but I need just one more info: when pressing F8, it should do the search again and if it does not find that it exits the loop

The code above was just an example, follow my true code:

CODE --> VBA

i = 2
    
    While Sheet1.Cells(i, "A") <> ""

	Sess0.Screen.SendKeys ("<Home>ATK8<Enter>")
        
        MyScreen.area(2, 22, 2, 27).Value = Trim(Left(Sheet1.Cells(i, "A"), 6))
        MyScreen.area(2, 29, 2, 38).Value = Trim(Mid(Sheet1.Cells(i, "A"), 7, 10))
        MyScreen.SendKeys ("<Enter>")
	Sleep (500)        

	Set MyArea = MyScreen.Search(Sheet1.Cells(i, "B"))        

	If MyArea Is Nothing Then
	MyScreen.SendKeys ("<PF8>")
	'here it would search again and if it did not find it would return to Sess0.Screen.SendKeys ("<Home>ATK8<Enter>")
	
	Else 

          MyScreen.MoveTo MyArea.Bottom, MyArea.Right + 2
          MyScreen.SendKeys ("S<Enter>")
	  Sleep(500)
	  MyScreen.SendKeys ("R<Enter><Enter>")
          Sleep(500)
 
   i = i + 1
   Wend
  
    MsgBox "Finished!" 

RE: Attachmate Comparation

BTW, any time you Send a command to the mainframe, which processes asynchronously from your application, you must WAIT until the mainframe process is complete. That might be less than a millisecond or many milliseconds or seconds or minutes. No one knows!

Wait(500) is like saying, “when I get to a STOP sign, I’ll just wait for exactly 5 seconds and then proceed into the intersection.” That would be silly and dangerous. You might be able to proceed immediately after stoping, or you might need to wait a long time due to traffic on the through street.

You will notice that when you issue a command to the mainframe that the cursor disappears until the mainframe is done, at which time the curor reappears at that screen’s rest coordinates. These coordinates an be different for various screens. DON’T USE WAIT(SomeDuration)

CODE

‘ a command has been sent to the mainframe
    Do Until Screen.WaitForCursor(r, c)   ‘ where r, c are the screen rest coordinates
       DoEvents
    Loop 

I’ll have more to say about your question when I get back from church.

Skip,

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

RE: Attachmate Comparation

(OP)
Thank you again for responding

I did some testing and it really is not necessary to wait, even more the way I did.

Ok, thanks

RE: Attachmate Comparation

Quote:

I did some testing and it really is not necessary to wait

You say that now, but there WILL be times when the mainframe will not respond “immediately.”

Skip,

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

RE: Attachmate Comparation

Hope you're coding and running this from Excel.

CODE

Dim i As Integer, j As Integer

    i = 2
    
    While Sheet1.Cells(i, "A") <> ""

        Sess0.Screen.SendKeys ("<Home>ATK8<Enter>")
        
        MyScreen.area(2, 22, 2, 27).Value = Trim(Left(Sheet1.Cells(i, "A"), 6))
        MyScreen.area(2, 29, 2, 38).Value = Trim(Mid(Sheet1.Cells(i, "A"), 7, 10))
        MyScreen.SendKeys ("<Enter>")
        Sleep (500)
'
        For j = 0 To 1      'loop twice if not found
            Set MyArea = MyScreen.Search(Sheet1.Cells(i, "B"))
            
            Select Case j
                Case 0
                    If MyArea Is Nothing Then
                        MyScreen.SendKeys ("<PF8>")
                        'here it would search again
                        'so do nothing else here
                    Else
                
                        MyScreen.MoveTo MyArea.Bottom, MyArea.Right + 2
                        MyScreen.SendKeys ("S<Enter>")
                        Sleep (500)
                        MyScreen.SendKeys ("R<Enter><Enter>")
                        Sleep (500)
                    
                        Exit For
                    End If
                Case 1
                    If MyArea Is Nothing Then
                        'if it did not find it would return to Sess0.Screen.SendKeys ("<Home>ATK8<Enter>")
                        Sess0.Screen.SendKeys ("<Home>ATK8<Enter>")
                    Else
                
                        MyScreen.MoveTo MyArea.Bottom, MyArea.Right + 2
                        MyScreen.SendKeys ("S<Enter>")
                        Sleep (500)
                        MyScreen.SendKeys ("R<Enter><Enter>")
                        Sleep (500)
                        
                    End If
            End Select
            
        Next
'     
       i = i + 1
   Wend 

Skip,

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

RE: Attachmate Comparation

(OP)
it's at the same excel

As soon as I test, I'll let you know.

RE: Attachmate Comparation

👍

Skip,

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

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!

Resources

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