INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS
Come Join Us!
Are you a Computer / IT professional? Join Tek-Tips now!
- 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.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site

(Download This Button Today!)
Feedback
"...Dudes! Great site. You've saved me hours and hours...and I have just started using your site. I've already passed your URL onto my entire company. Keep up the awesome work. Bingo-bango..."
Geography
Where in the world do Tek-Tips members come from?
|
Need to scrape text from Extra (Object) and compare it to a string
|
|
|
jonesy1 (TechnicalUser) |
11 Apr 12 19:41 |
Hello World!
I need to compare what's in 'Set MyArea = MyScreen.Area(6, 43, 6, 52)' to 'paper copy' a string. I can't seem to figure out as MyArea is an Object and 'paper copy' is a string. HELP!!! Please. I just want to do a simple compare of a value I scrape off an Extra screen to a particular string.
I know I said that twice, but I'm trying to be clear.
Thanks World. |
|
|
remy988 (TechnicalUser) |
11 Apr 12 21:20 |
i generally do something like this when i compare fields but i'm not sure if that's what you are asking for CODE field1 = sess.getstring (1,1,10) field2 = sess.getstring (24,8,10) if field1 = field2 then match = "Y" end if rem |
|
|
jonesy1 (TechnicalUser) |
13 Apr 12 11:58 |
Well that worked! But now there some weirdness happening with double printing. When I step through the code it works just fine - I get page one and two in one instance, then page 1 in another instance and then 1 & 2 etc.. but when I run it, I get page 1 & 2 in all three instances. Grrrrr! I set up separate labels and still it's not working when I run it. Part of the problem, I think, is that I have two For loops and both are being executed even if it appears that only one of the lables was Stepped through. |
|
you are dealing with an asynchronous process. You send a key to another system and it goes off and at some point, returns data to the emulator. Could be "instantaneous" or it could be minutes -- KNOW BODY KNOWS! One way that I like is to MOVE the cursor away from the screen rest point, then issue the SendKeys, then WaitForCursor at the rest point in a loop... CODEoScrn.MoveRelative 1,1
oScrn.SendKeys "<WHATEVER>"
do DoEvents loop until oScrn.WaitForCursor r,c where r, c are the coordinates of the rest point for the screen. Skip,
Just traded in my old subtlety... for a NUANCE! |
|
|
jonesy1 (TechnicalUser) |
13 Apr 12 13:40 |
Thanks for understanding my question. However, I'm not really certain as to how to stick that code in my code! and you're right-on with this being a asynchronous (problem - my word) process.
are you saying to replace the For loop with a Do loop? Or just add your code in between steps?
|
|
|
jonesy1 (TechnicalUser) |
13 Apr 12 18:56 |
I've still no clue how to use this code. should it go before or after the For loop? I've been trying 100 other ways and still same problem print dups. |
|
I have no inkling what your code looks like, unless you POST IT! This code is for where you send keys to process your screen. It waits for your system to respond before grabbing any data that is returned to the screen from the system. Skip,
Just traded in my old subtlety... for a NUANCE! |
|
|
jonesy1 (TechnicalUser) |
16 Apr 12 17:19 |
Here's my code: I added a Do Loop that works just fine when I step through, but when I run it, it only executes labelB: I can't figure out how to slow it down enough to process properly at its run speed.
' Determine the size of the Presentation Space MaxRows% = Session.Screen.Rows() MaxColumns% = Session.Screen.Cols() ' Initialize variables to hold screen information Screenbuf$ = "" linebuf$ = Space$ (MaxColumns%) '--------------------------------------------------------------------------------------------------' Do Until Field2 <> "T" MyString$ = MyScreen.GetString(6, 52, 1) Field2 = MyString$ Sess0.Screen.Sendkeys("<Clear>") Sess0.Screen.WaitHostQuiet(g_HostSettleTime) Sess0.Screen.Sendkeys("idsr<Enter>") Sess0.Screen.WaitHostQuiet(g_HostSettleTime) Sess0.Screen.Sendkeys("4") Sess0.Screen.WaitHostQuiet(g_HostSettleTime) Sess0.Screen.Sendkeys("<Enter>") Sess0.Screen.WaitHostQuiet(g_HostSettleTime) MyString$ = MyScreen.GetString(6, 52, 1) Field2 = MyString$ if (counter = 1) Then Sess0.Screen.Sendkeys ("1<NewLine>VDA0682800<EraseEOF><Enter>") ElseIf (counter = 2) Then Sess0.Screen.Sendkeys ("1<NewLine>VDA0682872<EraseEOF><Enter>") ElseIf (counter = 3) Then Sess0.Screen.Sendkeys ("1<NewLine>VDA0682810<EraseEOF><Enter>") ElseIf (counter = 4) Then Sess0.Screen.Sendkeys ("1<NewLine>VDA0682872<EraseEOF><Enter>") End If MyString$ = MyScreen.GetString(6, 52, 1) Field2 = MyString$ Sess0.Screen.WaitHostQuiet(g_HostSettleTime) Sess0.Screen.Sendkeys("<Pf8>") '---------------------------------------------------------------------------------------------' MyString$ = MyScreen.GetString(6, 52, 1) Field2 = MyString$ Sess0.Screen.WaitHostQuiet(g_HostSettleTime) Sess0.Screen.Sendkeys("<Pf7>") ' MyString$ = MyScreen.GetString(6, 52, 1) ' Field2 = MyString$ Sess0.Screen.WaitHostQuiet(g_HostSettleTime) Sess0.Screen.Sendkeys("<Pf8>") Loop ' MyString$ = MyScreen.GetString(6, 52, 1) ' Field2 = MyString$ If Field2 = "2" then goto labelA else goto labelB end if
' MyString$ = MyScreen.GetString(6, 52, 1) ' Field2 = MyString$ labelA: Do Until Field2 = "T"
Sess0.Screen.Sendkeys("<Pf7>") Sess0.Screen.WaitHostQuiet(g_HostSettleTime) For row% = 1 to MaxRows% linebuf$ = Session.Screen.Area(row%, 1, row%, MaxColumns%, , xBlock) screenbuf$ = screenbuf$ + linebuf$ + Chr$ (13) + Chr$ (10) Next Sess0.Screen.Sendkeys("<Pf8>") Sess0.Screen.WaitHostQuiet(g_HostSettleTime) For row% = 1 to MaxRows% linebuf$ = Session.Screen.Area(row%, 1, row%, MaxColumns%, , xBlock) screenbuf$ = screenbuf$ + linebuf$ + Chr$ (13) + Chr$ (10) Next filenum% = FreeFile FileName$ = "H:\TextFiles\whatsinthtfld2.txt" Open FileName$ For Append as filenum% Print # filenum%, screenbuf$; Chr$ (12) Close filenum% Screenbuf$ = "" linebuf$ = Space$ (MaxColumns%) Field2 = "T" goto label2 Loop
labelB: If Field2 = "2" then goto labelA else end if Do Until Field2 = "T" For row% = 1 to MaxRows% linebuf$ = Session.Screen.Area(row%, 1, row%, MaxColumns%, , xBlock) screenbuf$ = screenbuf$ + linebuf$ + Chr$ (13) + Chr$ (10) Next filenum% = FreeFile FileName$ = "H:\Testing\Text Files\whatsinthtfld2.txt" Open FileName$ For Append as filenum% Print # filenum%, screenbuf$; Chr$ (12) Close filenum% Screenbuf$ = "" linebuf$ = Space$ (MaxColumns%)
Field2 = "T" goto label2 Loop label2: if (counter >= 4) Then System.TimeoutValue = OldSystemTimeout counter = 0 else counter = counter + 1 goto label1 End If End Sub |
|
EVERY place that you have Sendkeys, except the CLEAR command. For instance... CODESess0.Screen.MoveRelative 1,1
Sess0.Screen.Sendkeys("<Clear>") Sess0.Screen.Sendkeys("idsr<Enter>") do DoEvents Loop Until Sess0.Screen.WaitForCursor(r, c) 'r,c are the rest coordinates for this screen
Sess0.Screen.MoveRelative 1,1
Sess0.Screen.Screen.Sendkeys("4") do DoEvents Loop Until Sess0.Screen.WaitForCursor(r, c) 'r,c are the rest coordinates for this screen '... Skip,
Just traded in my old subtlety... for a NUANCE! |
|
|
jonesy1 (TechnicalUser) |
17 Apr 12 12:38 |
Wellllllll, that seems to be WORKING!!! OMG!!! Thank you, thank you!!! I was just about to give up and "Walla!" it's working! I added the movecursor and waitforcursor and that seems to be doing the trick. the only thing (sorry - I don't mean to be an ingrate) it's processing very, very slowly. it's waiting a very long time to proceed. Here's my code now:
Do While Field2 = "T" Sess0.Screen.Sendkeys("<Clear>") Sess0.Screen.WaitHostQuiet(g_HostSettleTime) Sess0.Screen.Sendkeys("idsr<Enter>") Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("4") Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Enter>") Sess0.Screen.WaitHostQuiet(g_HostSettleTime) if (counter = 1) Then Sess0.Screen.Sendkeys ("1<NewLine>DA706820<EraseEOF><Enter>") ElseIf (counter = 2) Then Sess0.Screen.Sendkeys ("1<NewLine>DA706872<EraseEOF><Enter>") ElseIf (counter = 3) Then Sess0.Screen.Sendkeys ("1<NewLine>D7068210<EraseEOF><Enter>") ElseIf (counter = 4) Then Sess0.Screen.Sendkeys ("1<NewLine>DD72872<EraseEOF><Enter>") End If Sess0.Screen.WaitHostQuiet(g_HostSettleTime) Sess0.Screen.Sendkeys("<Pf8>") Sess0.Screen.MoveRelative 6,52 Sess0.Screen.WaitForCursorMove 6, 52
MyString$ = MyScreen.GetString(6, 52, 1) Field2 = MyString$ Sess0.Screen.WaitHostQuiet(g_HostSettleTime) Sess0.Screen.Sendkeys("<Pf7>") DoEvents Loop If Field2 = "2" then goto labelA else goto labelB end if labelA: Do While Field2 = "2" Sess0.Screen.Sendkeys("<Pf7>") Sess0.Screen.WaitHostQuiet(g_HostSettleTime) For row% = 1 to MaxRows% linebuf$ = Session.Screen.Area(row%, 1, row%, MaxColumns%, , xBlock) screenbuf$ = screenbuf$ + linebuf$ + Chr$ (13) + Chr$ (10) Next Sess0.Screen.Sendkeys("<Pf8>") Sess0.Screen.WaitHostQuiet(g_HostSettleTime) For row% = 1 to MaxRows% linebuf$ = Session.Screen.Area(row%, 1, row%, MaxColumns%, , xBlock) screenbuf$ = screenbuf$ + linebuf$ + Chr$ (13) + Chr$ (10) Next filenum% = FreeFile FileName$ = "H:\Testing\Text Files\whatsinthtfld3.txt" 'CHOOSE ANY PATH AND FILE NAME Open FileName$ For Append as filenum% Print # filenum%, screenbuf$; Chr$ (12) Close filenum% Screenbuf$ = "" linebuf$ = Space$ (MaxColumns%) Field2 = "T" goto label2 DoEvents Loop
labelB: If Field2 = "2" then goto labelA else end if Do While Field2 <> "T" For row% = 1 to MaxRows% linebuf$ = Session.Screen.Area(row%, 1, row%, MaxColumns%, , xBlock) screenbuf$ = screenbuf$ + linebuf$ + Chr$ (13) + Chr$ (10) Next filenum% = FreeFile FileName$ = "H:\Testing\Text Files\whatsinthtfld3.txt" Open FileName$ For Append as filenum% Print # filenum%, screenbuf$; Chr$ (12) Close filenum% Screenbuf$ = "" linebuf$ = Space$ (MaxColumns%)
Field2 = "T" goto label2 DoEvents Loop label2: if (counter >= 4) Then System.TimeoutValue = OldSystemTimeout counter = 0 else counter = counter + 1 goto label1 End If End Sub |
|
I would remove ALL references to HostSettleTime and WaitHostQuiet. Skip,
Just traded in my old subtlety... for a NUANCE! |
|
You need the WaitHostQuiet after every <enter> as this prevents your app from continuing to run before the screen has finished refreshing.
g_HostSettleTime is set to a default value of 3000ms. You could change it to 250 and your app will run much faster.
John |
|
Sorry John, that is NOT correct, IF you use a loop as I have posted! I NEVER EVER assign WaitHostQuiet or g_HostSettleTime!!!!! Skip,
Just traded in my old subtlety... for a NUANCE! |
|
|
jonesy1 (TechnicalUser) |
23 Apr 12 11:42 |
I did take out all reference to WaitHostQuiet or g_HostSettleTime and that still did not sync up the process. The only thing that's working still is the WaitForCursorMove and MoveRelative, but it takes almost 5 minutes for 4 interations. I've tried many combination with and without, speeding up and slowing down the time. It just gets to the WaitFor and slooooooooooooooows down almost to a stal.
and thanks for chiming in.
Should anyone have any other suggestions for syncing this up, it would be most appreciated. |
|
Here are your choices. 1. ENTER a wait period and HOPE that your system will have responded within that period. Trouble is, it might be that the system responds more quickly, in which case you have wasted the time difference or, even worse, it might at times be LONGER, in which case, you will have MISSED data that might have been returned, but your process has passed on. 2. WAIT until the system give you an indication that the data has been returned, using methods like Quote:Tip: WaitForString, WaitForStream, WaitForCursor, and WaitForCursorMove are other possible options for determining when the host has finished processing. Press the Related Topics button above to access these method descriptions.
Copyright 1996 - 1999, Attachmate Corporation. All rights reserved.
Personally, I prefer NOT to make a time guesstimate, but to have positive evidence that the system is ready. Maybe you ought to set the System TimeoutValue to something relatively small like 100... CODESys.TimeoutValue = 100 prior to using the WiatForCursor method. Skip,
Just traded in my old subtlety... for a NUANCE! |
|
|
jonesy1 (TechnicalUser) |
23 Apr 12 13:04 |
Oooooooooh sheet! THAT FRIGGIN WORKED!!! Ooooh sheeet! You're a genius!!! A genius I tell ya!
Muuuuuuuuuuuwah!!!! kisses and hugs for you man! MuuuuuuuuwaH! |
|
|
jonesy1 (TechnicalUser) |
23 Apr 12 13:04 |
Oh yeah, and Thank you very much! |
|
Sorry. Stuff that I automatically assume and tucked away in a login routine I use. <wiping slobber off face> Skip,
Just traded in my old subtlety... for a NUANCE! |
|
|
jonesy1 (TechnicalUser) |
23 Apr 12 13:11 |
Slobber away baby! You put a smile on a human's face today! Take the rest of the day off! :)
and ask your boss to kiss you on the mouth for me! hahahahah |
|
I only kiss my wife! Skip,
Just traded in my old subtlety... for a NUANCE! |
|
|
 |
|