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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attachmate Comparation

Status
Not open for further replies.

DougExtra21

Programmer
Oct 26, 2017
11
BR
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:
    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
 
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,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
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:
    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!"
 
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,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
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
 
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,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
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)
'[b]
        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
'[/b]     
       i = i + 1
   Wend

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
it's at the same excel

As soon as I test, I'll let you know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top