leegold Posted December 25, 2013 Share Posted December 25, 2013 Hi, This question might show a gap in my understanding how Autoit works but hopefully I'll learn...so I did not think this would work: Global $z = 1 Example() Sleep(5000) ConsoleWrite("five sec" & @LF) $z=0 Func Example() $c = 0 While $z == 1 ConsoleWrite($c & @LF) Sleep(1000) If $z == 0 Then ConsoleWrite("$z == 0" & @LF) EndIf $c=$c+1 WEnd EndFunc ;==>Example Once the function starts it's impervious to changes in $z, the code never progresses past the function call. What I actually want to do is to stop the while loop while I change somethings outside of the function then restart the while loop and have the change "stick" inside the function/while loop. Is the only way to do this to kill the example() function, make changes, then call/restart the fuction again? Thanks Link to comment Share on other sites More sharing options...
martin Posted December 25, 2013 Share Posted December 25, 2013 You just need to have something which will make the script halt the function and respond to an event then continue. For example HotKeySet("^{F10}",'SetZ') HotKeySet("!{F10}",'ReSetZ') Global $z = 1 Example() Sleep(5000) ConsoleWrite("five sec" & @LF) $z=0 Func Example() $c = 0 While $z == 1 ConsoleWrite($c & @LF) Sleep(1000) If $z == 0 Then ConsoleWrite("$z == 0" & @LF) EndIf $c=$c+1 WEnd EndFunc ;==>Example Func setZ() $z = 1 EndFunc Func ResetZ() $z = 0 EndFunc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Gianni Posted December 25, 2013 Share Posted December 25, 2013 also, you could insert another function call inside the While -WEnd loop and that function will manage the $z variable value Global $z = 1 Example() Sleep(5000) ConsoleWrite("five sec" & @LF) $z=0 Func Example() $c = 0 While $z == 1 ConsoleWrite($c & @LF) Sleep(1000) _Manage_z() ; <-- this function will change $z If $z == 0 Then ConsoleWrite("$z == 0" & @LF) EndIf $c=$c+1 WEnd EndFunc ;==>Example Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
leegold Posted December 25, 2013 Author Share Posted December 25, 2013 This helps immensely. Thanks: 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