matumbo Posted October 10, 2007 Share Posted October 10, 2007 Does it exist any function to restart a loop? probably a stupid question, but I didn't find one in the help files. Link to comment Share on other sites More sharing options...
BrettF Posted October 10, 2007 Share Posted October 10, 2007 For loop example: For $i = 1 To 100 If $i = 50 Then $i = 1 ToolTip($i) Sleep(20) Next Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
matumbo Posted October 10, 2007 Author Share Posted October 10, 2007 (edited) This is my whole script, it's a bank simulator. Made this one just for fun. expandcollapse popup#include <GUIConstants.au3> Dim $1 Dim $2 Dim $3 Dim $Answer Global $BankAmount $BankAmount = 1000 guicreate("Options","275","100") guictrlcreatelabel("What do you want to do?","100","20") $1 = GUICtrlCreateButton("Deposit","40","60") $2 = GUICtrlCreateButton("Withdraw","100","60") $3 = GUICtrlCreateButton("Statement","170","60") GUISetState (@SW_SHOW) While True $Msg = GUIGetMsg() Switch $Msg case $GUI_EVENT_CLOSE ExitLoop case $1 guicreate("Input","275","100") GUICtrlCreateLabel("How much would you like to deposit?","70","20") $Input = GUICtrlCreateInput("","65","40") $Button = GUICtrlCreateButton("Send","110","65") guisetstate(@SW_SHOW) Do Sleep(1) $Msg2 = GUIGetMsg() until $Msg2 = $Button $Amount = GUICtrlRead($Input) GUICtrlSetData($Input,"") $Bankamount = $Bankamount + $Amount Msgbox(0,"Money","Money left on Account =" &$BankAmount) ;[b][u]I want it to restart when it's here, close the window and start over.[/u][/b] case $2 ;Haven't finished the script from here yet. Case $3 EndSwitch WEnd I don't find a way to use that example here. Edited October 10, 2007 by matumbo Link to comment Share on other sites More sharing options...
SadBunny Posted October 10, 2007 Share Posted October 10, 2007 Do you mean something like ContinueLoop [level] Parameters level [optional] The level of the loop to restart. The default is 1 (meaning the current loop). Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
matumbo Posted October 10, 2007 Author Share Posted October 10, 2007 hm, if it does what it sounds like it would do I think it's it. Thx Link to comment Share on other sites More sharing options...
matumbo Posted October 10, 2007 Author Share Posted October 10, 2007 Only one problem I think, when I continue the loop the window remains open, what function should I use to only close the inputbox? Link to comment Share on other sites More sharing options...
SadBunny Posted October 10, 2007 Share Posted October 10, 2007 Only one problem I think, when I continue the loop the window remains open, what function should I use to only close the inputbox? You need to point a variable towards the extra GUI you create (the input gui), so you can delete that gui later on just before the loop re-initiates. I changed only two lines in your code; the two lines that are left-justified. Seems to work for me like this. expandcollapse popup#include <GUIConstants.au3> Dim $1 Dim $2 Dim $3 Dim $Answer Global $BankAmount $BankAmount = 1000 GUICreate("Options", "275", "100") GUICtrlCreateLabel("What do you want to do?", "100", "20") $1 = GUICtrlCreateButton("Deposit", "40", "60") $2 = GUICtrlCreateButton("Withdraw", "100", "60") $3 = GUICtrlCreateButton("Statement", "170", "60") GUISetState(@SW_SHOW) While True $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE ExitLoop Case $1 $GuiInput = GUICreate("Input", "275", "100") GUICtrlCreateLabel("How much would you like to deposit?", "70", "20") $Input = GUICtrlCreateInput("", "65", "40") $Button = GUICtrlCreateButton("Send", "110", "65") GUISetState(@SW_SHOW) Do Sleep(1) $Msg2 = GUIGetMsg() Until $Msg2 = $Button $Amount = GUICtrlRead($Input) GUIDelete($GuiInput) $BankAmount = $BankAmount + $Amount MsgBox(0, "Money", "Money left on Account =" & $BankAmount) ;I want it to restart when it's here, close the window and start over. Case $2 ;Haven't finished the script from here yet. Case $3 EndSwitch WEnd Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 10, 2007 Share Posted October 10, 2007 (edited) Changing the value of the counter variable inside the loop is considered very bad form, honestly. Why not just nest the loop and test for a condition? $intFlag = 0 While $intFlag = 0 $condition = True While $condition = True ; Some code if SomeThing () = Whatever then $condition = False Wend Wend Edited October 10, 2007 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache 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