Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

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!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I am very happy with the whole site and would like to extend my compliments to all of you who work to make it one of the most useful sites (If not THE Most Useful) ...and the easiest to navigate..."

Geography

Where in the world do Tek-Tips members come from?

VBScript Looping Statement Help

OutOfStep (TechnicalUser)
21 May 12 11:25
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.

SkipVought (Programmer)
21 May 12 12:05


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,

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

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!

Back To Forum

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