RAWBERRY Posted October 15, 2009 Share Posted October 15, 2009 Here is my script. $random_ms = 12 If $random_ms = 12 Then Do MsgBox(0, "Variable Test", $random_ms) $random_ms = $random_ms + 1 Until $random_ms = 23 EndIF If $random_ms = 23 Then $random_ms = 12 EndIf For some reason the MsgBox will not loop back to 12, and repeat the count from 12-23. Logic tells me this should be looping, but it isn't. Any help, or a better method would be greatly appreciated. Link to comment Share on other sites More sharing options...
Mison Posted October 15, 2009 Share Posted October 15, 2009 try: $random_ms = 12 While 1 MsgBox(0,"",$random_ms) $random_ms += 1 If $random_ms = 23 Then $random_ms = 12 WEnd Hi ;) Link to comment Share on other sites More sharing options...
rliiack Posted October 15, 2009 Share Posted October 15, 2009 (edited) Two problems: 1. Your do loop stop at 23 so it never executes the MsgBox(0, "Variable Test", $random_ms) when $random_ms is 23. Set the limit to 24. 2.The code stops when the last if statement is executed, it won't jump to the beginning of the program again. Put a while loop around it. $random_ms = 12 while 1 If $random_ms = 12 Then Do MsgBox(0, "Variable Test", $random_ms) $random_ms = $random_ms + 1 Until $random_ms = 24 EndIF If $random_ms = 24 Then $random_ms = 12 EndIf WEnd Edited October 15, 2009 by rliiack My Projects:Smart Icons Link to comment Share on other sites More sharing options...
Beege Posted October 15, 2009 Share Posted October 15, 2009 Here is my script. $random_ms = 12 If $random_ms = 12 Then Do MsgBox(0, "Variable Test", $random_ms) $random_ms = $random_ms + 1 Until $random_ms = 23 EndIF If $random_ms = 23 Then $random_ms = 12 EndIf For some reason the MsgBox will not loop back to 12, and repeat the count from 12-23. Logic tells me this should be looping, but it isn't. Any help, or a better method would be greatly appreciated. You need to check $random_ms before you exit your loop. random_ms = 12 If $random_ms = 12 Then Do MsgBox(0, "Variable Test", $random_ms) $random_ms = $random_ms + 1 If $random_ms = 23 Then $random_ms = 12 EndIf Until $random_ms = 23 EndIF Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
RAWBERRY Posted October 15, 2009 Author Share Posted October 15, 2009 Wow, thanks a ton for all of the help. However I figured out a method which did what I wanted too while I was waiting for a response, which turned out to be exactly what booge suggested. Only problem is my until. I would like be able to exit the script upon clicking the X on the message box. I searched the help document, and couldn't find anything. Here's what I have so far. $random_ms = 12 If $random_ms = 12 Then Do MsgBox(0, "Variable Test", $random_ms) $random_ms = $random_ms + 1 If $random_ms = 23 Then $random_ms = 12 EndIf Until $random_ms = 24 EndIf It keeps looping, which is good, but it doesn't stop. I had to terminate through windows task manager. Link to comment Share on other sites More sharing options...
Mison Posted October 15, 2009 Share Posted October 15, 2009 Exit upon clicking the X? I don't know if that possible.. but this works for me: $random_ms = 12 If $random_ms = 12 Then Do $input = MsgBox(1, "Variable Test.. hit Cancel to exit", $random_ms) If $input = 2 Then Exit $random_ms = $random_ms + 1 If $random_ms = 23 Then $random_ms = 12 EndIf Until $random_ms = 24 EndIf Hi ;) Link to comment Share on other sites More sharing options...
Beege Posted October 15, 2009 Share Posted October 15, 2009 (edited) I dont think its possible either because OK and X both return 1. Also use Exitloop if you don't want program to end. Edited October 15, 2009 by Beege Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
RAWBERRY Posted October 15, 2009 Author Share Posted October 15, 2009 Exit upon clicking the X? I don't know if that possible.. but this works for me: $random_ms = 12 If $random_ms = 12 Then Do $input = MsgBox(1, "Variable Test.. hit Cancel to exit", $random_ms) If $input = 2 Then Exit $random_ms = $random_ms + 1 If $random_ms = 23 Then $random_ms = 12 EndIf Until $random_ms = 24 EndIf Yes, that works perfectly well, however, if anyone does know of a method to terminate with the X button, it may be useful to me later if you care to share. Thanks a lot guys! 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