Jump to content
Eli_jahbot

Repeat Specific segment then continue

Recommended Posts

Eli_jahbot

hello,

I'm looking for some help on the following conundrum that has plagued me these past few days.

I have automated a repetitive process in an application where it inputs values X amount of times then stops and prompts with  a message box telling the user what to do next.

I'm reviewing all my scripts and really want to condense them. I struggle with loops/repeats of code segments, could someone please advise me on how I make the script repeats lines 18-59 4 times then prompt a message box. This would remove 100+lines from my script if I could grasp this simple sounding function.

be swell and thank you

 

Share this post


Link to post
Share on other sites
taylansan

Can you also give some part of those 100+lines from your code? 

Go to line 17 and For $i=1 To 4; then go to line 60 Next


TY.

Share this post


Link to post
Share on other sites
Eli_jahbot

Thank you, here is a segment that i would like to repeat 4 times or more. I appreciate the help

Lines 35 to 62 in the code are what id like to repeat and they are below.

Sleep(2000)
send("!s")
send("i")
send($ndc)
send("{ENTER}")
sleep(1500)
send("{ENTER}")
sleep(1500)
send("!m")
sleep(1200)
send("{+}")
send("999999")
sleep(1500)
send("{TAB}")
sleep(1500)
send("{DOWN}")
send("{DOWN}")
send("{DOWN}")
send("{DOWN}")
send("{Enter}")
sleep(1500)
send("{Enter}")
send("{tab}")
Send($username)
Send("{TAB}")
send($password)
Send("{ENTER}")
sleep(2000)
send("!m")

Share this post


Link to post
Share on other sites
Realm

Simply put:

For $i = 1 to 4
    _DoSomething()
Next

Func _DoSomething()
    ;DoSomething
EndFunc

 


My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites
Eli_jahbot

Thank you for the quick responses. I used the below recommendation and it works amazing! Now the code went from 160 lines down to 69 total.

I do have a question as to why it worked so i understand.

The For $i = 1 to 4

_do stuff

Next

I dont have a variable declared as $i? So does the variable $i become all the commands between the For and Next?

Also the:

Func _do stuff

EndFunc

 I couldnt get this one to work with the For and Next? Did you offer that as an alternative? If so can you please elaborate as to how i would use the Func/Endfunc to repeat specific code segments? Could you adjust the code below to reflect how it would look using the Func/Endfunc instead of For/Next?

 

Code that now works thanks to you:

For $1 = 1 to 4
WinWaitActive($invload)
send("!m")
sleep(2000)
send($adjustment)
send("999999")
sleep(2000)
send("{TAB}")
sleep(2000)
send("{DOWN 4}")
send("{Enter}")
sleep(2000)
send("{Enter}")
send("{tab}")
Send($username)
Send("{TAB}")
send($password)
Send("{ENTER}")
sleep(2000)
Next
MsgBox(64, "Script Complete", "Reprocess the Rx")

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×