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

DoLoop & GetString Help 1

Status
Not open for further replies.

vzachin

Technical User
Feb 10, 2006
305
0
0
US
I have a file which can have more than one page.
After doing a successful find on the file, I use the GetString to store data from a particular field.
As I do a page advance <PA2>,
I can use the GetString on subsequent pages for the same field.
How can I put this in a LOOP until I reach the last page, where I would see a message "Foward Completed?
The file can have 1 or more pages. I don't know the maximum number of pages.

I am currently using Attachmate Enterprise 2000.

thanks
 
Do

'getstring your info and turn page here

Loop While YourScreenObj.getstring(WhereRow,WhereCloumn,16)<>"Foward Completed
 
thanks mgwils,
what I meant to ask was how do I differentiate the GetString from page1,page2 etc..
on each subsequent page that exists, i need a GetString.

i would normally do the following:
A1=Sess2.screen.GETstring(5,62,5) 'Field1 B1=Sess2.screen.GETstring(8,62,5) 'Field2
if the data was on the same page, but I can't figure out how to do this as it does the DO/Loop.

thanks again
 
simple array stuff this should get you started but leaves room for improvement. Think of count as your page.

Code:
Dim A1(),B1() as string
Dim count as integer

Do
  count = count + 1
  redim preserve A1(count)
  redim preserve B1(count)
  A1(count)=Sess2.screen.GETstring(5,62,5)
  B1(count)=Sess2.screen.GETstring(8,62,5) 
Loop While Sess2.screen.GETstring(where?,where?,16)<>"Foward Completed"
  'add the coords your expecting Foward Completed to be at in place of where?

for count = 1 to count
  'how to read the info back out of your array
  msgbox "A1 "+str(count)+" ="+A1(count)
  msgbox "B1 "+str(count)+" ="+B1(count)
next
 
Oh yeah don't forget your <PA2> at the bottom of the Do loop to move to the next page.
Code:
Dim A1(),B1() as string
Dim count as integer

Do
  count = count + 1
  redim preserve A1(count)
  redim preserve B1(count)
  A1(count)=Sess2.screen.GETstring(5,62,5)
  B1(count)=Sess2.screen.GETstring(8,62,5) 
  [COLOR=red]Sess2.screen.sendkeys ("<PA2>")[/color]
Loop While Sess2.screen.GETstring(where?,where?,16)<>"Foward Completed"
  'add the coords your expecting Foward Completed to be at in place of where?

for count = 1 to count
  'how to read the info back out of your array
  msgbox "A1 "+str(count)+" ="+A1(count)
  msgbox "B1 "+str(count)+" ="+B1(count)
next

 
Thanks mqwils. I can't figure out how to use the PutString to input the data onto another file.
If I have 10 pages from
A1(count)=Sess2.screen.GETstring(5,62,5),
what is the syntax I would use to imput these 10 GetStrings into another file? Each one of these 10 GetStrings will need to be input on a separate page.
Thanks again
 
what is the syntax I would use to imput these 10 GetStrings into another file ? Each one of these 10 GetStrings will need to be input on a separate page.
Confused, File as in File outside of Attachmate (.txt .xls ect)? Or to another page/pages inside your session? I need more info to be specific with help.

What type of format does the input page have?
Are all ten or more responses going to the same column on subsequent rows?

first value
second value
third value

and if so how many can be input per page?
or do they move around

first value
second value
third value

Here's an example to handle the first situation described.
Code:
for count = 1 to count
  Sess2.screen.PutString A1(count),count,1 'starts at row 1
next

if your talking multiple pages you would need to add some navagation after the putstring to get you to the next page. Again with more information you'll probably get better responses than this one.
 
Here is a sample of some code I use which loops, it may help you,

Code:
For polroutine = 0 To 4
            PolNo = polarray(polroutine)
            If PolNo = "" Then GoTo polcont2
           
        'enter policy no
            backoutchk = MyScreen.getstring(2, 3, 7)
            If backoutchk = "BRPEIMA" Then Sess0.Screen.SendKeys ("<Pf3>")
            Sess0.Screen.WaitHostQuiet (g_hostsettletime)
            If backoutchk = "BRPEBMD" Then Sess0.Screen.SendKeys ("<Pf3>")
            Sess0.Screen.WaitHostQuiet (g_hostsettletime)
            If backoutchk = "BRPEDMA" Then Sess0.Screen.SendKeys ("<Pf3>")
            Sess0.Screen.WaitHostQuiet (g_hostsettletime)
            Sess0.Screen.SendKeys ("<EraseEOF>")
            MyScreen.Putstring PolNo, 21, 9
            MyScreen.Moveto 21, 68
            Sess0.Screen.SendKeys ("PEB")
            Sess0.Screen.SendKeys ("<Enter>")
            Sess0.Screen.WaitHostQuiet (g_hostsettletime)
            ioforcechk = MyScreen.getstring(4, 22, 12)
            If ioforcechk = "OUT OF FORCE" Then MsgBox ("OUT OF FORCE POLICY"): End 'used to be GoTo inputs1 '???????
            GoTo Infoscrape
        
                'Gets the information to input on the policy details
Infoscrape:
                
                
                premium1 = MyScreen.getstring(15, 55, 10)
                premium1 = Val(premium1)
                premium = premium + premium1
                  
                Sess0.Screen.SendKeys ("<Enter>")
                Sess0.Screen.WaitHostQuiet (g_hostsettletime)
                specdate = MyScreen.getstring(8, 38, 10)
                specdate = Format(specdate, "d mmmm yyyy")
                                
                commdate = MyScreen.getstring(7, 38, 10)
                Termdate = MyScreen.getstring(8, 38, 10)
                If PolNo = Pol1 Then CommDate1 = MyScreen.getstring(7, 38, 10)
                
        'Search the screen for any life cover groups
                Sess0.Screen.WaitHostQuiet (g_hostsettletime)
                Nam3 = MyScreen.getstring(5, 25, 3)
 
nxtstep:
            'searches for waiver of premium
                wopchk = MyScreen.getstring(5, 55, 11)
                If wopchk = "EYP ABSENT " Then
                    wopchk = False
                    Else
                    wopchk = True
                End If
                GoTo spchk
            
spchk:
          
                PageVal = MyScreen.getstring(3, 80, 1)
                PageVal = Val(PageVal)
                PUPCheck = MyScreen.getstring(10, 9, 2)
                If PUPCheck = "SP" Then SPStatus = True
                
                For PolRoute = 1 To PageVal
    
                    figrow = 9
                    FigRow2 = figrow - 2
                    figrow3 = figrow - 2
                    For figroutine = 1 To 3
                    
                    Sess0.Screen.WaitHostQuiet (g_hostsettletime)
firstchk:
               'Check group is active - move onto next group if it isn't
                        figChk = MyScreen.getstring(figrow - 1, 74, 1)
                        If figChk = " " Then
                            GoTo nextchk
                        Else
                            figrow = figrow + 5
                            FigRow2 = figrow - 2
                            figrow3 = figrow - 2
                            GoTo firstchk
                        End If
nextchk:
            'Check for single premiums
            
                        figComChk = MyScreen.getstring(figrow - 2, 38, 10)
                        figTermChk = MyScreen.getstring(figrow + 1, 38, 10)
                        If figComChk = figTermChk Then
                            figrow = figrow + 5
                            FigRow2 = figrow - 2
                            figrow3 = figrow - 2
                            GoTo nextfig
                        End If
                        spchk = MyScreen.getstring(figrow, 13, 2)
                        Widowsben = MyScreen.getstring(FigRow2, 19, 1)
                        LifeCover = MyScreen.getstring(figrow3, 19, 1)
                        If Widowsben = "2" Then
                                WB_Present = True
                                widowsbenTermDate = MyScreen.getstring(FigRow2, 38, 10)
                                WidowsPrem = MyScreen.getstring(9, 17, 10)
                                WidowsPrem = Val(WidowsPrem)
                                figrow = figrow + 5
                                FigRow2 = FigRow2 + 5
                                figrow3 = figrow3 + 5
                                GoTo nextfig
                        End If
                        If LifeCover = "3" Then
                                LC_Present = True
                                lcstopcode = MyScreen.getstring(figrow - 1, 74, 1)
                                LifeCoverTermDate = MyScreen.getstring(figrow3 + 1, 38, 10)
                                SumAssured1 = MyScreen.getstring(figrow3 + 1, 17, 10)
                                SumAssured1 = Val(SumAssured1)
                                SumAssured = SummAssured + SumAssured1
                                LCpremium1 = MyScreen.getstring(figrow, 38, 10)
                                LCpremium1 = Val(LCpremium1)
                                LCPremium = LCPremium + LCpremium1
                                LCCessationDate = MyScreen.getstring(figrow3 + 3, 38, 10)
                                figrow = figrow + 5
                                FigRow2 = FigRow2 + 5
                                figrow3 = figrow3 + 5
                                GoTo nextfig
                        End If
                        If spchk = "SP" Then SPfig = MyScreen.getstring(figrow, 17, 10): _
                        SPfig = Val(SPfig): _
                        SPamount = SPamount + SPfig
                   
                    'Get BA
                        BAfig = MyScreen.getstring(figrow3 + 1, 17, 10)
                        BAfig = Val(BAfig)
                
                    'Get Bonus
                        Bonfig = MyScreen.getstring(figrow3 + 1, 57, 10)
                        Bonfig = Val(Bonfig)
                        
                   
                       
getvals:
                    'Compile values
                        figrow = figrow + 5
                        FigRow2 = FigRow2 + 5
                        figrow3 = figrow3 + 5
                        BA = BA + BAfig
                        Bonus = Bonus + Bonfig
                                          
nextfig:
                    Next
                    Sess0.Screen.SendKeys ("<Pf8>")
                    Sess0.Screen.WaitHostQuiet (g_hostsettletime)
                    Next
                    
                    'Check for WOP and get values
                    
                    If wopchk = True Then
                    Sess0.Screen.SendKeys ("<Enter>")
                    Sess0.Screen.WaitHostQuiet (g_hostsettletime)
                    If PolNo = Pol1 Then WOPtermdate = MyScreen.getstring(8, 21, 10)
                    WOPtermdate = Format(WOPtermdate, "D MMMM YYYY")
                    For woproutine = 1 To 9
                        PWChk = MyScreen.getstring(7 + woproutine, 7, 2)
                        If PWChk = "PW" Then wopprem = MyScreen.getstring(7 + woproutine, 12, 8)
                        wopprem = CCur(wopprem)
                        TotalWop = TotalWop + wopprem
                        wopprem = 0
                    
                      Next
                    End If
                   
                      Sess0.Screen.SendKeys ("<Pf3>")
                    Sess0.Screen.WaitHostQuiet (g_hostsettletime)
                    Next

hope this helps as it navigates through the same screens when looping
 
hi mqwils,
Basically,I have a file with multiple pages where I need to copy data from 2 fields on each page. I would then add this data to another file within Attachmate.

My coding was something like this:

A1=Sess2.screen.GETstring(5,62,5) 'Field1 page 1
B1=Sess2.screen.GETstring(8,62,5) 'Field2 page 1
Sess2.Screen.Sendkeys("<PA2>") 'page advance

C1=Sess2.screen.GETstring(5,62,5) 'Field1 page 2
D1=Sess2.screen.GETstring(8,62,5) 'Field2 page 2
Sess2.Screen.Sendkeys("<PA2>") 'page advance


I would <PA2> until I see a message "Foward Completed.

Then I would call another screen in Attachmate and add the data as follows:

Sess2.screen.putstring A1,5,62
Sess2.screen.putstring B1,8,62
Sess2.Screen.Sendkeys("<PF4>") 'add file
Sess2.Screen.WaitHostQuiet(1000)

Sess2.screen.putstring C1,5,62
Sess2.screen.putstring D1,8,62
Sess2.Screen.Sendkeys("<PF4>") 'add file
Sess2.Screen.WaitHostQuiet(1000)

I continue with the putstring until the last string as been added.

I want to simplify this process.

So far I have this with the coding you supplied:

Dim A1(),B1() as string
Dim count as integer

Do
count = count + 1
redim preserve A1(count)
redim preserve B1(count)
A1(count)=Sess2.screen.GETstring(5,62,5)
B1(count)=Sess2.screen.GETstring(8,62,5)
Sess2.screen.sendkeys ("<PA2>")
Loop While Sess2.screen.GETstring(where?,where?,16)<>"Foward Completed"
'add the coords your expecting Foward Completed to be at in place of where?

for count = 1 to count
Sess2.screen.PutString A1(count),count,1 'starts at row 1

next

would I replace
Sess2.screen.PutString A1(count),count,1 'starts at row 1

with the follow?

Sess2.screen.PutString A1(count),count,5,62
Sess2.screen.PutString B1(count),count,8,62


thanks again for all your help
 
Code:
Dim A1(),B1() as string
Dim count as integer
'gets your variables and stores in an array
Do
  count = count + 1
  redim preserve A1(count)
  redim preserve B1(count)
  A1(count)=Sess2.screen.GETstring(5,62,5)
  B1(count)=Sess2.screen.GETstring(8,62,5) 
  Sess2.screen.sendkeys ("<PA2>")
  Sess2.Screen.WaitHostQuiet(1000)
Loop While Sess2.screen.GETstring(where?,where?,16)<>"Foward Completed"
'see the where?,where? on the line above
'replace it with the coords for your Forward Complete
'statement where it appears on your final page
'(1,1,16) if it's the first thing on the page ect.

'call your input file/page here, I don't how you do it you
'didn't supply that in your example but something like

'Sess2.screen.putstring("whatever gets your page"),1,1
'Sess2.screen.sendkeys ("<PA2>")
'Sess2.Screen.WaitHostQuiet(1000)
'then ...
Code:
for count = 1 to count
  Sess2.screen.putstring A1(count),5,62
  Sess2.screen.putstring B1(count),8,62
  Sess2.Screen.Sendkeys("<PF4>")    'add file
  Sess2.Screen.WaitHostQuiet(1000)
next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top