×
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

Select text
2

Select text

Select text

(OP)
I have written a simple macro that searces for a string based on the user's input.  If it's not found on the first page it moves to the next.  It cycles through all pages until found.  Sends a messages if it's found and stops on that page. It works perfectly, but I would like to have the string highlighted when it is found.  I have seen this done with other macros, but I can't replicate it.  I have attempted Sess0.Screen.userInput.Select and Sess0.Screen.stringFind.Select where the variables are exactly what they say they are.  I get an error stating that is not such property or method.  I know it's a simple snipet.  Any suggestions??

RE: Select text



Look for the Search Method in Extra HELP.

Skip,

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

RE: Select text

CODE

found = sess0.screen.select(9,15,9,20)

from the help screen

RE: Select text

(OP)
Thanks vz.  This works for selecting certain coordinates.  Now that I have the correct syntax I need to be able to turn the coordinates of the found string into a variable so it will be in the right place each time it's found. Is that possible?
 

RE: Select text

you would need to get the coordinates of the found string, where it begins and where it ends.

how are you performing the search?

RE: Select text

(OP)
I'm using the serach function.  

CODE

'Declare Variables
    Dim stringFind As String
    Dim userInput As String
        
'Set the user input to the string entered in the InputBox
    userInput = InputBox("What are you searching for?", "Search")
   
'Make sure that the search is started at page one
    If Sess0.Screen.GetString(3, 70, 3) <> "001" Then
        MsgBox "Please start from Page 1 "
        GoTo theend
    End If
            
'Start the search for the string
    While stringFind <> userInput
        stringFind = Sess0.Screen.Search(userInput)
        
        If stringFind = userInput Then
        'This is where the select will go
            GoTo done:
        Else
            Sess0.Screen.SendKeys ("<ENTER>")
            Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
        End If
        
        If Sess0.Screen.GetString(3, 70, 3) = "001" Then
            GoTo NotFound
        End If
                    
    Wend
        
    MsgBox ("Fine! I didn't feel like searching through all that code anyway!")
    Exit Sub
    
NotFound:
    MsgBox ("Not Found!")
    Exit Sub

done:
    MsgBox ("Found It!")
    Exit Sub

theend:
End Sub

RE: Select text

i guess you didn't look at the help file as Skip suggested.
 

RE: Select text

(OP)
Don't respond if your gonna be rude about it.  

RE: Select text

i'm sorry if you felt i was rude. you can hire a professional to help you then.

RE: Select text

(OP)
I did look at the help file Skip suggested.  There is nothing there.  The search fnction isn't referenced.  And, in case you didn't look at the code I posted, I have the search portion of the code working fine.

RE: Select text


Quote (ExtraHELP):

Applies To Objects

Screen

Description

Returns an Area object with the text specified in the search.

Syntax

Set rc = object.Search(Text[,Row][,Col][,Page])

Element    Description
Set    The Set statement, required for assigning an object reference to a variable.
rc    The object variable for referencing the returned object.
object    The Screen object.
Row    The row where the search begins.
Col    The column where the search begins.
Page    VT session only -- the screen page where the search begins.Note: This parameter is ignored for release 6.0 of EXTRA!o.
Comments

If the optional parameters are used, Screen is searched from the specified starting position. Otherwise, the entire Screen object is searched.
If Search finds the specified text, the coordinate properties (Left, Top, Right, Bottom) of the returned Area object are set to the starting and ending row and column positions of the text. The Value property of the Area object is set to the text located at those coordinates. If the Screen changes at those coordinates, the Value property of the Area changes.

If Search does not find the specified text, the Area object's Value property is set to an empty string, its Type property is set to xNONE, and its coordinate properties are set to -1.

Copyright 1996 - 1999, Attachmate Corporation. All rights reserved.

Skip,

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

RE: Select text

(OP)
Awesome Skip!  Thank you!  How do I retur the coordinates rather that the text at those coordinates?

RE: Select text



Quote:

Returns an Area object with the text specified in the search.
The Area object contains the properties that you want.

Skip,

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

RE: Select text

(OP)
I have tried Sess0.Screen.Select, Sess0.Screen.Area.Select, Sess0.Screen.Select(Sess0.Screen.Area) and they have all given me errors stating theat they are not valid arguments.  Am I not understanding the hint?

RE: Select text



Did you LOOK in Extra VB Help for the Area Object?

You seem to be GUESSING at syntax, when Extra VB Help has specific information regarding syntax.

Skip,

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

RE: Select text

(OP)
Where is the "VB" Help?  I'm not looking for you to post the answer to your previous post, I just can't find anything but Extra Help.  And it contains nothing regarding VB.  I'll check out the syntax online in the meantime.  Thanks Skip.

RE: Select text



Open the Macro Editor.

Type in Area in your code.

Select Area and hit F1.

Skip,

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

RE: Select text

(OP)
That just takes me to the Windows Help and Support.  The same as when I choose help in the session.   

RE: Select text

(OP)
It's because the help file is not compatible with my computer.  And I don't have access to update that at work.  I'm looking online for the help.   

RE: Select text



In the Macro Editor, don't you have a HELP in the Menu Items across the top of the window?

Skip,

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

RE: Select text

(OP)
I do, yes. However, this is the message that pops up when I try to access it:

Quote:

The Help for this program was created in Windows Help format, which depends on a feature that isn't included in this version of Windows. However, you can download a program that will allow you to view Help created in the Windows Help format.


And I cannot download the program that will allow me to view the correct format.

RE: Select text



You need to contact your IT dept and have them install the help system for your application.

Short of that, reload Extra!Attachmate, INCLUDING help files.

Skip,

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

RE: Select text

Hey Dizzy.  I read through the posts and thought I would jump in and help you out.  I can't understand why no one is giving you information on how this works.

When you use the search function in EB, it returns you an area object.  That area object has some properties to it that you can access.  These include such properties as bottom, left, right, top, page, parent, type, value, copy, cut, and a few others.  The Area object can be created with the Area method or the Search method.  In your case, when you perform a Sess0.Screen.Search(userInput) what it does is return an area object.  In your code however, you are asking it to place the value of the search into a variable.

stringFind = Sess0.Screen.Search(userInput)

While this is a fine, it does limit what you can do as you stop referencing the area object created by the search.

What you may want to do instead is to make an object called MyArea and set your search to that area so that you can then reference the methods and properties within the area.

I use this extensively and here is a bit of the code I use.

Dim oMyArea as Object

If MyScreen.Search(userInput) = userInput (check to see if you found the string you were looking for.)
Set oMyArea = MyScreen.Search(userInput)

Now you can reference the methods and properties in the area object.

In your case, bottom and left are the two properties you are gonna be interested in.  Bottom tells you the row in which the text was found and left is going to tell you the column in which the very first letter of the text string was found.  You can then use this information to highlight the area, or to cut and paste.. or whatever you feel you would like to do to that area.  Here are a few examples.

MyArea.Select (since you set the area with the Search method, then this will highlight the entire area you searched for)

MyScreen.MoveTo MyArea.Bottom, MyArea.Left (this will move the cursor to first position on the screen where the field was found.)

Basically, anything that requires a column or row you can substitute the area properties Bottom and Left.

I don't mean to be critical, and I hope you will forgive me if I seem presumptious but not knowing about the Area object has caused you to write a bunch of code which can be accomplished in much fewer lines.

Do

If Sess0.Screen.Search(userInput) = userInput then
  Set MyArea = MyScreen.Search(userInput)
  MyArea.Select
  *do more stuff here*
  MsgBox "Screen Found"
  Stop
Else
  Sess0.Screen.SendKeys ("<ENTER>")
  Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
End If

Loop Until (*you go through all the screen*)

One last piece of advice concerning the WaitHostQuiet method.  I see that you have the g_HostSettleTime as the variable there.. and while that seems to be ok I have to warn you that if you are using the default setup for a session then the system TimeoutValue is usually set to the g_HostSettleTime.  What that means is that regardless of what's going on, your macro will resume it's processing after that amount of time.. wether the Host is quiet or not.  WaitHostQuiet is a time which the macro should wait after it recieves a "quiet" response from the server.  The TimeoutValue is the length of time your macro will wait for the host to be quiet.  Mixing them can be dangerous if you have busy times.  For example.  If you default the timeoutvalue to 30 seconds (30000) and also set your WaitHostQuiet to the same time, you have the potential of your macro starting back up before the quiet response is issued from the system.  I tend to make my WaitHostQuiet a considerably shorter time frame (around 0100 or 0200) and my TimeoutValue much longer (30-45 seconds).  That way if the host returns a quiet response, my macro picks up zooms off much faster.  It will also wait a much longer time for the quiet response.

Please let me know if you have any more questions or need anything else.


 

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