×
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

Need to scrape text from Extra (Object) and compare it to a string

Need to scrape text from Extra (Object) and compare it to a string

Need to scrape text from Extra (Object) and compare it to a string

(OP)
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.

RE: Need to scrape text from Extra (Object) and compare it to a string

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

RE: Need to scrape text from Extra (Object) and compare it to a string

(OP)
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.

RE: Need to scrape text from Extra (Object) and compare it to a string




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...

CODE

oScrn.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,

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

RE: Need to scrape text from Extra (Object) and compare it to a string

(OP)
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?

 

RE: Need to scrape text from Extra (Object) and compare it to a string

(OP)
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.

RE: Need to scrape text from Extra (Object) and compare it to a string



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,

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

RE: Need to scrape text from Extra (Object) and compare it to a string

(OP)
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
 

RE: Need to scrape text from Extra (Object) and compare it to a string

EVERY place that you have Sendkeys, except the CLEAR command.

For instance...

CODE

Sess0.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,

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

RE: Need to scrape text from Extra (Object) and compare it to a string

(OP)
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
 

RE: Need to scrape text from Extra (Object) and compare it to a string




I would remove ALL references to HostSettleTime and WaitHostQuiet.

Skip,

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

RE: Need to scrape text from Extra (Object) and compare it to a string

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

RE: Need to scrape text from Extra (Object) and compare it to a string



Sorry John, that is NOT correct, IF you use a loop as I have posted!

I NEVER EVER assign WaitHostQuiet or g_HostSettleTime!!!!!

Skip,

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

RE: Need to scrape text from Extra (Object) and compare it to a string

(OP)
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.

RE: Need to scrape text from Extra (Object) and compare it to a string



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...

CODE

Sys.TimeoutValue = 100
prior to using the WiatForCursor method.

Skip,

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

RE: Need to scrape text from Extra (Object) and compare it to a string

(OP)
Oooooooooh sheet!  THAT FRIGGIN WORKED!!! Ooooh sheeet!  You're a genius!!!  A genius I tell ya!

Muuuuuuuuuuuwah!!!!  kisses and hugs for you man!  MuuuuuuuuwaH!

RE: Need to scrape text from Extra (Object) and compare it to a string

(OP)
Oh yeah, and Thank you very much!

RE: Need to scrape text from Extra (Object) and compare it to a string


Sorry.  Stuff that I automatically assume and tucked away in a login routine I use.

<wiping slobber off face> winky smile

Skip,

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

RE: Need to scrape text from Extra (Object) and compare it to a string

(OP)
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

RE: Need to scrape text from Extra (Object) and compare it to a string



I only kiss my wife!

Skip,

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

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