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

Select text 2

Status
Not open for further replies.

DizzyP

Technical User
Feb 27, 2012
26
US
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??
 
I do, yes. However, this is the message that pops up when I try to access it:
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.
 


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,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
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.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top