×
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

Statement return

Statement return

Statement return

(OP)
Skip,
I was able to fix the For, next issue, but I'm still missing something. My variables are not working, they are returning the same values, and are not capturing the values for all the pages in the statements.

CODE -->

Sess0.Screen.Sendkeys("<Reset>")
   Sess0.Screen.Sendkeys("<Clear>")
   Sess0.Save
    Do Until Sess0.Screen.WaitHostQuiet(g_HostSettleTime) 
      DoEvents
   Loop 
   Sess0.Screen.Sendkeys("cis "& acnt$)
   Sess0.Screen.Sendkeys("<Enter>")
   Sess0.Screen.Sendkeys("css")
   Sess0.Screen.Sendkeys("<Enter>")
    Do Until Sess0.Screen.Getstring(02,52,02) <= Sess0.Screen.Getstring(02,60,02)
     DoEvents
      Loop

        For i = 1 To 3
            For rw = 5 To 19
        
                Ret1$ = Sess0.Screen.Getstring(rw,04,04)
                Ret1a$ = Sess0.Screen.Getstring(rw,26,05)
                Ret1b$ = Sess0.Screen.Getstring(rw,72,08)
                Sess0.Screen.Sendkeys("<Pf8>")
                Ret2$ = Sess0.Screen.Getstring(rw,04,04)
                Ret2a$ = Sess0.Screen.Getstring(rw,26,05)
                Ret2b$ = Sess0.Screen.Getstring(rw,72,08)  
                WRITE #2,acnt$,Ret1$,Ret1a$,Ret1b$,Ret2$,Ret2a$,Ret2b$
         
       Next
'          Next
       
'        Sess0.Screen.Sendkeys("<Pf8>")	
'        If Sess0.Screen.Getstring(02,52,02) <> Sess0.Screen.Getstring(02,60,02)+1 then
'        Do Until Sess0.Screen.Getstring(02,52,02) <= Sess0.Screen.Getstring(02,60,02)
'            DoEvents 
'        Loop
'              
'        For j = 1 To 3
'            For rw = 5 To 19  
'                Ret2$ = Sess0.Screen.Getstring(rw,04,04)
'                Ret2a$ = Sess0.Screen.Getstring(rw,26,05)
'                Ret2b$ = Sess0.Screen.Getstring(rw,72,08)   
'  
'                WRITE #2,acnt$,Ret2$,Ret2a$,Ret2b$
                

'         Next
            Sess0.Screen.Sendkeys("<Enter>")
'           Do Until Sess0.Screen.WaitForCursor(01, 02) 'Kept as alernative in event 'Do Until' below doesn't work
            Do Until Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
                DoEvents
            Loop 
            Sess0.Save
     Next
XXX: 
LOOP


CLOSE #1

msgbox "Your macro is complete, have a nice day."
End Sub 

I left the old code so you could see my changes and hopefully my logic with that I am trying to do. Thanks Skip!

James

RE: Statement return

Hi,

1) I’m confused.

What about the beginning of your outer loop...

CODE

Do While Not EOF(1)

   Input #1,acnt$

   ACNT$ = LEFT$(ACNT$,16) 

   WRITE #2,acnt$

‘... 

2) When you SendKeys this...

CODE

Sess0.Screen.Sendkeys("cis "& acnt$) 
...does your screen change, cuz if it does, you need to WaitFor... feedback, until the system is ready.

And you have a bunch of those, including the <PF8>s.

3) Blocks must be nested. Each Sub...End Sub, each For...Next, each If...Then...End If, each Do...Loop must be totally within a block.

Style wise, I like to indent each block. Procedurally, I enter the skeleton form of my block to insure that I’ve added all the essential elements, and once established, I fill in the particulars. The Excel VBA editor actually helps you out when you set up a Sub or Function, by automatically giving you an End Sub or End Function.

CODE

Sub MyTest()
   
End Sub 

BTW, I’ve done ALL my Attachmate screen coding in Excel because a) the VBA Editor is soooo much better and b) because my screen scrapes akways begin with a list from Excel and end up as a list in Excel.

Here’s the beginning of a loop...

CODE

Sub MyTest()
   Dim i As Integer

   For i = 1 To 3

   Next
End Sub 

Here’s the beginning of an If, where x is just a temporary placeholder...

CODE

Sub MyTest()
   Dim i As Integer

   For i = 1 To 3
      If x Then

      Else

      End If
   Next
End Sub 

I have my block structures in place. Any other blocks must reside totally within an existing block.

Can’t have this...

CODE

Sub MyTest()
   Dim i As Integer, j As Integer

   For i = 1 To 3
      If x Then

      Else
         For j = 1 to 2
      End If
   Next
         Next
End Sub 

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Statement return

(OP)
Thanks skip, I've never used the Excel macro editor before, and it did help me line things up (as well as your explanation). I made a couple changes to make it even easier to read with the variables (at least I think)

CODE -->

Dim PageNo As Integer
    Dim Month As Integer
    Dim Pages As Integer
        
    Do While Not EOF(1)

        Input #1, acnt$
        acnt$ = LEFT$(acnt$, 16)
        
        Sess0.Screen.Sendkeys ("<Reset>")
        Sess0.Screen.Sendkeys ("<Clear>")
        Sess0.Save
        Sess0.Screen.Sendkeys ("cis " & acnt$)
        Sess0.Screen.Sendkeys ("<Enter>")
                
        Sess0.Screen.Sendkeys ("css")
        Sess0.Screen.Sendkeys ("<Enter>")
                
        For Month = 1 To 3
             Sess0.Screen.Sendkeys ("<Enter>")
             PageNo = Sess0.Screen.Getstring(2, 60, 2)          
             
             For Pages = 1 To PageNo
               
                For rw = 5 To 19
                
                    Ret1$ = Sess0.Screen.Getstring(rw, 4, 4)
                    Ret1a$ = Sess0.Screen.Getstring(rw, 26, 5)
                    Ret1b$ = Sess0.Screen.Getstring(rw, 72, 8)
                    
                    Write #2, acnt$, Ret1$, Ret1a$, Ret1b$
                Next
                
                Sess0.Screen.Sendkeys ("<Pf8>")
                
             Next
        
        Next    
        
       
        
    Loop
    
    Sess0.Screen.Sendkeys ("<Clear>")


    Close #1
    Close #2
    
msgbox "Your macro has been completed. Have a nice day."

End Sub 

Thank you again for your help!
James

RE: Statement return

Much better!

I’d suggest some tips on variables.

Stay away from variable names like

Year, Month, Day, Hour, Minute, Second, Page, Pages

Most are reserve words, Function Names.

Some programmers use naming conventions for variables that give an indication of the Data Type:

i for Integer... Dim iCnt As Integer
l for Long... Dim lRow As Long
s for String... Dim sSQL As String
ws for Worksheet... Dim wsMaster As Worksheet
wb for Workbook... Dim wbAccounts As Workbook
r for Range... Dim rAccounts As Range
o for Object... Dim oScreen As Object
d for Date... Dim dStart As Date, dDate As Date

Once you “format” your declarations, the Excel VBA Editor will provide the capitalization that you provided in your declarations. Same with reserve words like for, next, if, then, else, date, now. It’s a good self-check. If what you thought was a reserve word spelling isn’t, it won’t get capitalized.

Have fun!

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! Already a Member? Login

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