Skip to main content

Hello Gang,

   I am trying to understand what and how the Methods "SearchText, SearchText2, SearchText3, SearchText4" work.

In a previous attempt to learn about different methods, I was able to figure out the  **LINE2 = ThisScreen.GetText(5, 1, 79)**  where the variable LINE2 was holding the string value for the item.   

How do I use the SearchText methods?  I can't use

LINE2 = ThisScreen.SearchText("Select Accessioning menu Option", 1, 1, FindOptions_Forward)

because the item returned is not a string..  Being a novice, I don't always understand the online help prompts.

Thanks for any help .

Butch


#Reflection

Hello Gang,

   I am trying to understand what and how the Methods "SearchText, SearchText2, SearchText3, SearchText4" work.

In a previous attempt to learn about different methods, I was able to figure out the  **LINE2 = ThisScreen.GetText(5, 1, 79)**  where the variable LINE2 was holding the string value for the item.   

How do I use the SearchText methods?  I can't use

LINE2 = ThisScreen.SearchText("Select Accessioning menu Option", 1, 1, FindOptions_Forward)

because the item returned is not a string..  Being a novice, I don't always understand the online help prompts.

Thanks for any help .

Butch


#Reflection

so if i had a screen with the following lines of text on it,  how would I utilize 

mary had a little lamb
its fleece was white as snow
and everywhere that Mary went
the lamb sure did NOT want to go
The End.
ThisScreen.SearchText3("did NOT",1,2,5,79,FindOptions_Backward)
"did NOT" = test I am search
1 = beginning row
2 = beginning column
5 = end row
79 = end column
backwards = search direction

What is being fed back to me ?? a true/false or string ??



expression.SearchText3( _
   ByVal text As String, _
   ByVal startRow As Integer, _
   ByVal startColumn As Integer, _
   ByVal endRow As Integer, _
   ByVal endColumn As Integer, _
   ByVal findOption As FindOptions _
) As ScreenPoint object 

so if i had a screen with the following lines of text on it,  how would I utilize 

mary had a little lamb
its fleece was white as snow
and everywhere that Mary went
the lamb sure did NOT want to go
The End.
ThisScreen.SearchText3("did NOT",1,2,5,79,FindOptions_Backward)
"did NOT" = test I am search
1 = beginning row
2 = beginning column
5 = end row
79 = end column
backwards = search direction

What is being fed back to me ?? a true/false or string ??



expression.SearchText3( _
   ByVal text As String, _
   ByVal startRow As Integer, _
   ByVal startColumn As Integer, _
   ByVal endRow As Integer, _
   ByVal endColumn As Integer, _
   ByVal findOption As FindOptions _
) As ScreenPoint object 

Hi Marshallgrads,

To directly answer you last question what is being fed back:

A ScreenPoint object that contains the coordinate of the located text or null if the text is not found.

So you should use ThisScreen.SearchText3 to find the location of the text then you would use ThisScreen.GetText to capture the actual text that you found if that is what you want to do.

Sub ExampleForScreenPoint()
 
    Dim sPoint As ScreenPoint
    Dim text As String
    Dim row, column As Integer
    
    'Get the maximum rows for the screen
    row = ThisScreen.DisplayRows
    column = ThisScreen.DisplayColumns
    
    'Find the row
    Set sPoint = ThisScreen.SearchText4("Profit", 1, 1, row, column, FindOptions_Forward, TextComparisonOption_IgnoreCase)
    
    'Get the Text
    text = ThisScreen.GetText(sPoint.row, sPoint.column, 8)
    
    Debug.Print text; " is at row " & sPoint.row & " and column " & sPoint.column

An important note is that this Method is from the Open Systems library and I am pretty sure it does not exist in the ibm host library.  So this will only work in VT session types.

For IBM Host information look here:

https://www.microfocus.com/documentation/reflection-desktop/17-0/vba-guide/Attachmate.Reflection.Objects.Emulation.IbmHosts~Attachmate.Reflection.Objects.Emulation.IbmHosts_namespace.html

Regards,

Jeff B


Hi Marshallgrads,

To directly answer you last question what is being fed back:

A ScreenPoint object that contains the coordinate of the located text or null if the text is not found.

So you should use ThisScreen.SearchText3 to find the location of the text then you would use ThisScreen.GetText to capture the actual text that you found if that is what you want to do.

Sub ExampleForScreenPoint()
 
    Dim sPoint As ScreenPoint
    Dim text As String
    Dim row, column As Integer
    
    'Get the maximum rows for the screen
    row = ThisScreen.DisplayRows
    column = ThisScreen.DisplayColumns
    
    'Find the row
    Set sPoint = ThisScreen.SearchText4("Profit", 1, 1, row, column, FindOptions_Forward, TextComparisonOption_IgnoreCase)
    
    'Get the Text
    text = ThisScreen.GetText(sPoint.row, sPoint.column, 8)
    
    Debug.Print text; " is at row " & sPoint.row & " and column " & sPoint.column

An important note is that this Method is from the Open Systems library and I am pretty sure it does not exist in the ibm host library.  So this will only work in VT session types.

For IBM Host information look here:

https://www.microfocus.com/documentation/reflection-desktop/17-0/vba-guide/Attachmate.Reflection.Objects.Emulation.IbmHosts~Attachmate.Reflection.Objects.Emulation.IbmHosts_namespace.html

Regards,

Jeff B

Jeff,

   Thanks for taking a moment to explain about this method.   Being a novice, I have not been able to work out what the "Set sPoint" is feeding back.  

I believe I understand the concept that it should be feeding back a coordinate  (ex: Row = 1, Column = 6).

Is the actual value/variable being set in a specific form:   sPoint = 1,6 ??

I was able to understand the row/column thing.  This is something I didn't know about for properties so it will be a great thing to use in the future;  TY..

MsgBox "LINES: " & ThisScreen.DisplayRows
MsgBox "COLUMNS: " & ThisScreen.DisplayColumns

When I attempted to play with it, I simply copied your general format, but changed the "Profit" to be something that was present on my screen but when I tried to put this in a messagebox it didn't work..

Set sPoint = ThisScreen.SearchText4("disciplinary", 1, 1, row, column, FindOptions_Forward, TextComparisonOption_IgnoreCase)

msgbox sPoint

I get an error that says "Run-time error 91, Object variable or With block variable not set"

my full code is this:

Sub BUTCH_TIMESCRAPE()

MsgBox "LINES: " & ThisScreen.DisplayRows
MsgBox "COLUMNS: " & ThisScreen.DisplayColumns

    'Find the row
    'Set sPoint = ThisScreen.SearchText4("Profit", 1, 1, row, Column, FindOptions_Forward, TextComparisonOption_IgnoreCase)
    Set sPoint = ThisScreen.SearchText4("disciplinary", 1, 1, row, Column, FindOptions_Forward, TextComparisonOption_IgnoreCase)
    
    'Get the Text
    text = ThisScreen.GetText(sPoint.row, sPoint.Column, 80)
    
MsgBox sPoint
MsgBox text

End Sub


Hello Gang,

   I am trying to understand what and how the Methods "SearchText, SearchText2, SearchText3, SearchText4" work.

In a previous attempt to learn about different methods, I was able to figure out the  **LINE2 = ThisScreen.GetText(5, 1, 79)**  where the variable LINE2 was holding the string value for the item.   

How do I use the SearchText methods?  I can't use

LINE2 = ThisScreen.SearchText("Select Accessioning menu Option", 1, 1, FindOptions_Forward)

because the item returned is not a string..  Being a novice, I don't always understand the online help prompts.

Thanks for any help .

Butch


#Reflection

Jeff,

   I want to extend a hardy THANK YOU for providing me a hint on how to use the "SearchText" method.  Although the specific example you posted did not work on my initial attempt, I was able to take the concept that you provided and experiment.  My experimentation has resulted in a working code which I believe will allow me to do what I hope to given time to sit down and code it all.

Here is what I now have.  

What I have is an entire paragraph on my screen, starting with Row 1 and continuing to Row 24.  In my code below, I am now able to successfully capture what line the word "disciplinary" is found on.  Then using the row number identified and its column position, I can now use the "GetText" method to extract the number of characters following this keyword.  HURRAY !!!..

The entire line is - "and disciplinary, adverse, or other appropriate action."  I then use my method to extract the next 20 characters and it brings back - "disciplinary, advers".  Perfect...

Sub BUTCH_TIMESCRAPE()
' as of 11/18/21 this works !!!!

Dim Point As ScreenPoint

MsgBox "LINES: " & ThisScreen.DisplayRows
MsgBox "COLUMNS: " & ThisScreen.DisplayColumns


    Set Point = ThisScreen.SearchText("disciplinary", 1, 1, FindOptions_Backward)                                                      'this works !!
    'Set Point = ThisScreen.SearchText4("disciplinary", 1, 1, row, Column, FindOptions_Backward, TextComparisonOption_IgnoreCase)        'this DOES NOT work
    
    
    'Get the Text
   text = ThisScreen.GetText(Point.row, Point.Column, 20)
   
   
MsgBox text

End Sub

As you can see, I was not able to use the "SearchText4" method, but I am able to successfully use the basic "SearchText" method to retrieve exactly what I was striving for.


Hello Gang,

   I am trying to understand what and how the Methods "SearchText, SearchText2, SearchText3, SearchText4" work.

In a previous attempt to learn about different methods, I was able to figure out the  **LINE2 = ThisScreen.GetText(5, 1, 79)**  where the variable LINE2 was holding the string value for the item.   

How do I use the SearchText methods?  I can't use

LINE2 = ThisScreen.SearchText("Select Accessioning menu Option", 1, 1, FindOptions_Forward)

because the item returned is not a string..  Being a novice, I don't always understand the online help prompts.

Thanks for any help .

Butch


#Reflection

Just wanted to give another example of code.  Just variations on the theme..  But might help others in the future.

Sub BUTCH_FINDTEXTONSCREEN()
' as of 11/18/21 this works !!!!

Dim Point As ScreenPoint
Dim text As String


'MsgBox "LINES: " & ThisScreen.DisplayRows
'MsgBox "COLUMNS: " & ThisScreen.DisplayColumns

    'Set Point = ThisScreen.SearchText("data", 1, 1, FindOptions_Backward)                                                               'this works !!
    Set Point = ThisScreen.SearchText("ACCESSION:", 1, 1, FindOptions_Forward)
    'Set Point = ThisScreen.SearchText4("disciplinary", 1, 1, row, Column, FindOptions_Backward, TextComparisonOption_IgnoreCase)       'this DOES NOT work
    
    
    'Get the Text
   text = ThisScreen.GetText(Point.row, Point.Column, 80)                      ' THIS WORKS
   'text = ThisScreen.GetText(Point.row + 1, Point.Column, 80)                  ' THIS WORKS
   'text = ThisScreen.GetText(Point.row + 1, Point.Column + 1, 100)              ' THIS WORKS
  
MsgBox text
MsgBox "The specified text was found on ROW: " & Point.row & " Column: " & Point.Column
'MsgBox Point.Column
'MsgBox Point.row

MsgBox "LENGTH OF TEXT IS: " & Len(text)

End Sub

Jeff,

   I want to extend a hardy THANK YOU for providing me a hint on how to use the "SearchText" method.  Although the specific example you posted did not work on my initial attempt, I was able to take the concept that you provided and experiment.  My experimentation has resulted in a working code which I believe will allow me to do what I hope to given time to sit down and code it all.

Here is what I now have.  

What I have is an entire paragraph on my screen, starting with Row 1 and continuing to Row 24.  In my code below, I am now able to successfully capture what line the word "disciplinary" is found on.  Then using the row number identified and its column position, I can now use the "GetText" method to extract the number of characters following this keyword.  HURRAY !!!..

The entire line is - "and disciplinary, adverse, or other appropriate action."  I then use my method to extract the next 20 characters and it brings back - "disciplinary, advers".  Perfect...

Sub BUTCH_TIMESCRAPE()
' as of 11/18/21 this works !!!!

Dim Point As ScreenPoint

MsgBox "LINES: " & ThisScreen.DisplayRows
MsgBox "COLUMNS: " & ThisScreen.DisplayColumns


    Set Point = ThisScreen.SearchText("disciplinary", 1, 1, FindOptions_Backward)                                                      'this works !!
    'Set Point = ThisScreen.SearchText4("disciplinary", 1, 1, row, Column, FindOptions_Backward, TextComparisonOption_IgnoreCase)        'this DOES NOT work
    
    
    'Get the Text
   text = ThisScreen.GetText(Point.row, Point.Column, 20)
   
   
MsgBox text

End Sub

As you can see, I was not able to use the "SearchText4" method, but I am able to successfully use the basic "SearchText" method to retrieve exactly what I was striving for.

Excellent marshallgrads.  Thanks for sticking with it and sharing examples that worked for you.  This will help the community get better.

Regards,

Jeff B.


Hello Gang,

   I am trying to understand what and how the Methods "SearchText, SearchText2, SearchText3, SearchText4" work.

In a previous attempt to learn about different methods, I was able to figure out the  **LINE2 = ThisScreen.GetText(5, 1, 79)**  where the variable LINE2 was holding the string value for the item.   

How do I use the SearchText methods?  I can't use

LINE2 = ThisScreen.SearchText("Select Accessioning menu Option", 1, 1, FindOptions_Forward)

because the item returned is not a string..  Being a novice, I don't always understand the online help prompts.

Thanks for any help .

Butch


#Reflection

Here is a new question about this.  

I have been successful, as noted below, in being able to search my screen for text and then scrape this data.  The suggestion provided by Jeff was instrumental in being able to do this.  As I understand the mechanism, the "sPoint" is returning a coordinate of (Row, Column).  Is there a way to use this coordinate to evaluate a True/False so that I could then use an If/Then statement to branch off and execute different segments of code?

Do I Dim the Point as a different entity?

Dim Point As Boolean

Thanks in advance,

Butch


Hello Gang,

   I am trying to understand what and how the Methods "SearchText, SearchText2, SearchText3, SearchText4" work.

In a previous attempt to learn about different methods, I was able to figure out the  **LINE2 = ThisScreen.GetText(5, 1, 79)**  where the variable LINE2 was holding the string value for the item.   

How do I use the SearchText methods?  I can't use

LINE2 = ThisScreen.SearchText("Select Accessioning menu Option", 1, 1, FindOptions_Forward)

because the item returned is not a string..  Being a novice, I don't always understand the online help prompts.

Thanks for any help .

Butch


#Reflection

Ok,  I have been trying lately to figure a way to use the SearchText Method.   What I have been able to deduce is this.

  • If the string of text that I am searching for IS present on my computer screen, then I have no problems.
  • If the string of text IS NOT present, then I receive an error code.

In my code, I am using the SearchText method which feeds back a ScreenPoint object.  This ScreenPoint object holds two values if the text is present - Row and Column of found text starting point.

Sub BUTCH_FINDTEXTONSCREEN()
' as of 11/18/21 this works !!!!
' THE ACCESSION NUMBER IS AT COLUMN=45
'

Dim Point As ScreenPoint
Dim text As String

    
    Set Point = ThisScreen.SearchText("ACCESSION:", 1, 1, FindOptions_Forward)                                                          'THIS WORKS
    'Set Point = ThisScreen.SearchText("data", 1, 1, FindOptions_Backward)                                                              'this works !!
    'Set Point = ThisScreen.SearchText4("disciplinary", 1, 1, row, Column, FindOptions_Backward, TextComparisonOption_IgnoreCase)       'this DOES NOT work
    
    If IsNull(Point) = True Then
        'The ISNULL function returns TRUE if the expression is a NULL value.
        'The ISNULL function returns FALSE if the expression is not a NULL value.
    
            MsgBox "The phrase/word *ACCESSION:* WAS NOT FOUND on the screen"
            
                       
        Else
            MsgBox "The phrase/word *ACCESSION:* was FOUND on the screen"
            MsgBox "Row position is: " & Point.row
            MsgBox "Column position is: " & Point.column
           
            
    End If
    
    Exit Sub
    
    End Sub

The code below only works if the string "ACCESSION:" is present.  If it is not present, then the Point variable is null and throws an error.

Sub BUTCH_FINDTEXTONSCREEN()
' as of 11/18/21 this works !!!!
' THE ACCESSION NUMBER IS AT COLUMN=45
'

Dim Point As ScreenPoint
Dim text As String

    
    Set Point = ThisScreen.SearchText("ACCESSION:", 1, 1, FindOptions_Forward)                                                          'THIS WORKS
    'Set Point = ThisScreen.SearchText("data", 1, 1, FindOptions_Backward)                                                              'this works !!
    'Set Point = ThisScreen.SearchText4("disciplinary", 1, 1, row, Column, FindOptions_Backward, TextComparisonOption_IgnoreCase)       'this DOES NOT work
    
    If Point.row  > 0 Then
    
            MsgBox "The phrase/word *ACCESSION:* WAS FOUND on the screen"
             MsgBox "Row position is: " & Point.row
            MsgBox "Column position is: " & Point.column
                       
        Else
            MsgBox "The phrase/word *ACCESSION:* was NOT on the screen"
           
            
    End If
    
    Exit Sub

My problem is that I was attempting to use the IsNull(expression) to evaluate the instances of where I had NO matching text appearing on my screen.  But unfortunately if doesn't seem to work as I had expected.    Is there anyone that has an idea of how I can evaluate for the empty or Null ScreenPoint object?  I can't seem to find a way to do it..


Hello Gang,

   I am trying to understand what and how the Methods "SearchText, SearchText2, SearchText3, SearchText4" work.

In a previous attempt to learn about different methods, I was able to figure out the  **LINE2 = ThisScreen.GetText(5, 1, 79)**  where the variable LINE2 was holding the string value for the item.   

How do I use the SearchText methods?  I can't use

LINE2 = ThisScreen.SearchText("Select Accessioning menu Option", 1, 1, FindOptions_Forward)

because the item returned is not a string..  Being a novice, I don't always understand the online help prompts.

Thanks for any help .

Butch


#Reflection

I have also tried this variation of my code.  Whether or not the Strings of "ACCESSION:" is present my equation evaluates it and uses the ELSE branch.

What am I doing wrong??

Sub BUTCH_FINDTEXTONSCREEN()
' as of 11/18/21 this works !!!!
' THE ACCESSION NUMBER IS AT COLUMN=45
'

Dim Point As ScreenPoint
Dim text As String

    
    Set Point = ThisScreen.SearchText("ACCESSION:", 1, 1, FindOptions_Forward)                                                          'THIS WORKS
    'Set Point = ThisScreen.SearchText("data", 1, 1, FindOptions_Backward)                                                              'this works !!
    'Set Point = ThisScreen.SearchText4("disciplinary", 1, 1, row, Column, FindOptions_Backward, TextComparisonOption_IgnoreCase)       'this DOES NOT work
    
    If IsNull(Point) Then
        'The ISNULL function returns TRUE if the expression is a NULL value.
        'The ISNULL function returns FALSE if the expression is not a NULL value.
    
            MsgBox "The phrase/word *ACCESSION:* WAS NOT FOUND on the screen"
                    
        Else
            MsgBox "The phrase/word *ACCESSION:* was FOUND on the screen"
            MsgBox "Row position is: " & Point.row
            MsgBox "Column position is: " & Point.column
           
            
    End If
    
    Exit Sub