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!

VBScript Looping Statement Help

Status
Not open for further replies.

OutOfStep

Technical User
May 21, 2012
1
0
0
US
I am new to VBScript and could use some help. I am trying to create a macro "loop" in JD Edwards World 8.1, which gives me the option to record in VBScript. I have recorded the keystrokes for "Paste Next / Enter / End" in a VBScript format. What I am trying to do now is add a statement at the end that will loop that series of keystrokes a specified number of times. Here is the VBScript that I have for the keystrokes:

REM This line calls the macro subroutine
PasteNext

sub PasteNext()
autECLSession.autECLOIA.WaitForAppAvailable

autECLMacro "[edit-paste-next]"

autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[enter]"

autECLSession.autECLPS.WaitForAttrib 5,29,"00","3c",3,10000

autECLSession.autECLPS.WaitForCursor 5,30,10000

autECLSession.autECLOIA.WaitForAppAvailable

autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[eraseeof]"
end sub
------------------------------------------------------
I have experimented with the "For...Next" looping statement, but I can't get it to work properly. I would like to add something to the end of this that basically tells it to "repeat this subroutine X number of times," where I could go in and change the value of X as needed.

Any VBScript gurus out there that can show me what I need to add to accomplish this? Any help is greatly appreciated.

 


Hi,

Seems as if you are coding an asynchronous interface (maybe a screen emulator).

If so, there are severl issues to coding your loop. In general you might use a Do...Loop. In particular, you would loop WHILE some condition or UNTIL some condition, or use in IF test within the loop to Exit Do.

But even as cirtical is the fact that since the processing is asynchronous, there is no direct feedback that the commands you sent to the external system/emulator, have completed. Simply WAITING a certain number of seconds is no an adequate method. You must loop within the loop, testing for an adequate return that guarantees the command process has completed.

So you code might look something like this...
Code:
Sub PasteNext()

    Do
        'PUT data on screen
        autECLMacro "[edit-paste-next]"
        
        'submit ENTER command
        autECLSession.autECLPS.SendKeys "[enter]"
        
        'Wait until cursor returns @ location
        Do
            DoEvents
        Loop Until autECLSession.autECLPS.WaitForCursor(5, 30, 10000)
        
    '[Some Condition] indicates that looping is complete
    Loop Until [Some condition]
End Sub


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top