Jump to content
Sign in to follow this  
Snarg

Return To Begining

Recommended Posts

Snarg

I understand the topic is poorly phrased, but I can not think of a better way to phrase it.

I would like my script to start a program. The script is going to check and see if the program started. If it did not start, I would like to to go back to the begining and try again. Since we no longer have GoTo (Yeah, I used it a lot), I would like to know of another way to do this. Here is what I have:

ReadInfo ()
StartProgram ()

  $CheckWindow = WinExists ( 'Program' )
    If $CheckWindow = 0 Then
      Run ( 'another_program.exe' & ' ' & $Paramaters, @SCRIPTDIR )
      Sleep ( 5000 )
    EndIf

NextFunction ()

If the window does not exist, I would like the script to return back to ReadInfo () and start over from the begining..

Any help is greatly appreciated, thank you.


A little reading goes a long way. Post count means nothing.

Share this post


Link to post
Share on other sites
Jos

somthing like :

do 
   ReadInfo ()
   StartProgram ()
   sleep(2000)
untill WinExists ( 'Program' )
Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Snarg

Thank you for the help. I put it all into the 'StartProgram' function. This is what I came up with:

Func StartProgram ()

  Do
    $Switches = IniRead ( $SettingsFile, $Variable, 'Paramater', "ERROR" )
      Run ( $ProgramPath & '\' & $ProgramExecutable & ' ' & $Switches, $ProgramPath )
      Sleep ( $LoadDelay )
        $CheckWindow = WinExists ( 'Program' )
          If $CheckWindow = 0 Then
            Run ( 'another_program' & ' ' & $Variables, @SCRIPTDIR )
            Sleep ( 5000 )
          EndIf
 Until WinExists ( 'Program' )
  Return
EndFunc

Once again, thank you.

Edited by Snarg

A little reading goes a long way. Post count means nothing.

Share this post


Link to post
Share on other sites
scriptkitty

one other thought

while 1
run("notepad.exe")
sleep(1000)
; do something
if NOT winexists("Untitled") then continueloop; this would restart at while 1
; do more stuff

exitloop
Wend
MsgBox(1,"hi","there")

So many ways....


AutoIt3, the MACGYVER Pocket Knife for computers.

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.