Chobyhy Posted September 5, 2006 Share Posted September 5, 2006 First question. If i use a script where it will keep adding +1 to variable will the variable reset when the script restarts? Second Question: How do you make it so the script restarts? Link to comment Share on other sites More sharing options...
Achilles Posted September 5, 2006 Share Posted September 5, 2006 First question. If i use a script where it will keep adding +1 to variable will the variable reset when the script restarts?Second Question: How do you make it so the script restarts?Question 1 = Yes, I had the problem so I had the variable but in an ini file (I'm by restart you mean you close the script and re open it)Question 2 = Well obviously you could exit it and then open it again manually... or you could and a function in there somewhere and if done right it would restart after your done...Piano_Man My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted September 5, 2006 Share Posted September 5, 2006 (edited) put in a loop edit: forgot the add part Edit again my bad + before = $i = 1 while 1 msgbox(0,"your loop is","Your loop number is " & $i) $i+=1 Sleep(1000) wend Edited September 5, 2006 by thatsgreat2345 Link to comment Share on other sites More sharing options...
Chobyhy Posted September 5, 2006 Author Share Posted September 5, 2006 that doesnt explain how to reload my script Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted September 5, 2006 Share Posted September 5, 2006 $i = 1 Start() func Start() msgbox(0,"your loop is","Your loop number is " & $i) $i+=1 Sleep(1000) Start() EndFunc Link to comment Share on other sites More sharing options...
MHz Posted September 5, 2006 Share Posted September 5, 2006 $i = 1 Start() func Start() msgbox(0,"your loop is","Your loop number is " & $i) $i+=1 Sleep(1000) Start() EndFuncQuickest way to get a recursion error. Bad logic calling a function within itself. @Chobyhy Where is your script so advice can be given to allow it to restart as there is no magic goto start of script keywork in AutoIt. Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted September 5, 2006 Share Posted September 5, 2006 Quickest way to get a recursion error. Bad logic calling a function within itself.@ChobyhyWhere is your script so advice can be given to allow it to restart as there is no magic goto start of script keywork in AutoIt.Yes i know about recursion limit just giving simple examples cuz im at loss to as what he wants Link to comment Share on other sites More sharing options...
Chobyhy Posted September 5, 2006 Author Share Posted September 5, 2006 well im not making it the "go to" script or other wise i would use the $var = 0 command instead of restarting. actually wtf was i thinking i can just use $var = 0 command Link to comment Share on other sites More sharing options...
vanowm Posted May 12, 2008 Share Posted May 12, 2008 Ok, let me continue this topic, since no answer has been given on how to restart the script withing the script. In my case I want make the script restart itself as soon as it has been modified, so I can see the result without need in close current script and start it again, as soon as I hit save button in my editor. In AHK there is a built-in feature "Reload" which restarts the script. In AI3 I don't see such feature, so I guess the only way is to run new instance of the script and then exit the "old" script? Link to comment Share on other sites More sharing options...
vanowm Posted May 12, 2008 Share Posted May 12, 2008 Unfortunately with the method I've described I see no "easy" way trace errors (if script failed to start, then don't exit the "old" instance) without going nuts codding too complicated for what it worth... P.S. we can't edit our posts? Link to comment Share on other sites More sharing options...
ChrisL Posted May 12, 2008 Share Posted May 12, 2008 I'm not sure if this is what you mean but this is how you could make a script that restarts itself and sends some information to the new instance of the script. $MyVariable = 0;This is the variable we are going to pass data too initialize it for the first time of running must be before the commandline check If $CMDLine[0] > 0 then;check the commandline to see if any variable data was passed For $i = 1 to $CMDLine[0] If StringLeft($CMDLine[$i],4) = "/var" then $MyVariable = StringTrimLeft($CMDLine[$i],5) Next EndIf ;start the script Msgbox(0,"","Start of script $MyVariable = " & $MyVariable) For $i = $MyVariable to $MyVariable +10 Msgbox(0,"","For loop " & $i,1) $MyVariable = $i Next If $MyVariable = 30 then Exit _restartScript($MyVariable);restart the script and send the data from $MyVariable Func _restartScript($Var=0) If @compiled then Run('"' & @ScriptFullPath & '"' & " /var:" & $var, @ScriptDir) Else Run (@AutoItExe & " /AutoIt3ExecuteScript " & FileGetShortName(@ScriptFullPath) & " /var:" & $Var, @ScriptDir) EndIf Exit EndFunc [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
vanowm Posted May 12, 2008 Share Posted May 12, 2008 Thanks for the response. Doesn't look to complicated, however, this doesn't check if the script has been successfully restarted...what if the script has been modified and has syntax error? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now