HankHell Posted September 6, 2018 Share Posted September 6, 2018 hey guys, I was trying to figure out how to make an infinite variable, as in the case below expandcollapse popupGlobal $count = 0 Global $userinput = 5 HotKeySet("{F1}", "Cycle") HotKeySet("{ESC}", "End") Sleeptime() Func Sleeptime() While 1 Sleep(100) WEnd EndFunc Func Cycle() While 1 If $userinput = 0 Then $userinput = $userinput + 1 Else If $count = $userinput Then $count = 0 ExitLoop EndIf EndIf $count = $count + 1 ;add junk here ;Example Send($count) ;Example WEnd EndFunc Func End() Exit EndFunc basically, I want to replace this: If $userinput = 0 Then $userinput = $userinput + 1 with something like this: If $userinput = 0 Then $userinput = ;infinity? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 6, 2018 Moderators Share Posted September 6, 2018 HankHell, A simple check should do the trick: expandcollapse popupGlobal $count = 0 Global $userinput = 0 HotKeySet("{F1}", "Cycle") HotKeySet("{ESC}", "End") Sleeptime() Func Sleeptime() While 1 Sleep(10) ; 10 is enough Sleep WEnd EndFunc ;==>Sleeptime Func Cycle() While 1 ; Check for infinite looping If $userinput <> 0 Then ; Check for loop limit If $count = $userinput Then $count = 0 ExitLoop EndIf EndIf $count = $count + 1 ;add junk here ;Example ConsoleWrite($count & @CRLF) ;Send($count) ;Example Sleep(10) ; Do not CPU here either! WEnd EndFunc ;==>Cycle Func End() Exit EndFunc ;==>End M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
HankHell Posted September 6, 2018 Author Share Posted September 6, 2018 1 minute ago, Melba23 said: HankHell, A simple check should do the trick: M23 but now I won't be able to overwrite infinity with a different $var later on in the func... that's why I needed it as a $var Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 6, 2018 Moderators Share Posted September 6, 2018 HankHell, Neither could you in the original script - I assumed that was just an example of the loop. Just add another function for the user input: expandcollapse popupGlobal $count = 0 Global $userinput = 5 HotKeySet("{F1}", "Cycle") HotKeySet("{F2}", "Input") HotKeySet("{ESC}", "End") Sleeptime() Func Sleeptime() While 1 Sleep(10) ; 10 is enough Sleep WEnd EndFunc ;==>Sleeptime Func Input() $userinput = Number(InputBox("Loops", "How many? (0=infinite)")) EndFunc Func Cycle() While 1 ; Check for infinite looping If $userinput <> 0 Then ; Check for loop limit If $count = $userinput Then $count = 0 ExitLoop EndIf EndIf $count = $count + 1 ;add junk here ;Example ConsoleWrite($count & @CRLF) ;Send($count) ;Example Sleep(10) ; Do not CPU here either! WEnd EndFunc ;==>Cycle Func End() Exit EndFunc ;==>End M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
HankHell Posted September 6, 2018 Author Share Posted September 6, 2018 (edited) 5 minutes ago, Melba23 said: HankHell, Neither could you in the original script - I assumed that was just an example of the loop. Just add another function for the user input: expandcollapse popupGlobal $count = 0 Global $userinput = 5 HotKeySet("{F1}", "Cycle") HotKeySet("{F2}", "Input") HotKeySet("{ESC}", "End") Sleeptime() Func Sleeptime() While 1 Sleep(10) ; 10 is enough Sleep WEnd EndFunc ;==>Sleeptime Func Input() $userinput = Number(InputBox("Loops", "How many? (0=infinite)")) EndFunc Func Cycle() While 1 ; Check for infinite looping If $userinput <> 0 Then ; Check for loop limit If $count = $userinput Then $count = 0 ExitLoop EndIf EndIf $count = $count + 1 ;add junk here ;Example ConsoleWrite($count & @CRLF) ;Send($count) ;Example Sleep(10) ; Do not CPU here either! WEnd EndFunc ;==>Cycle Func End() Exit EndFunc ;==>End M23 ah yeah didn't think of that, thanks also, yes this was just a representation and not the script I'm working on Edited September 6, 2018 by HankHell Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 6, 2018 Moderators Share Posted September 6, 2018 (edited) HankHell, Thinking a little deeper, best change the comparison to: ; Check for loop limit If $count >= $userinput Then Now if the user enters a valid number while the loop is infinite it will stop if already over the limit. Or reset $count to 0 at the same time as getting the new input. M23 P.S. When you reply in future, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily. Thanks in advance for your cooperation. Edited September 6, 2018 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
HankHell Posted September 6, 2018 Author Share Posted September 6, 2018 Just now, Melba23 said: HankHell, Thinking a little deeper, best change the comparison to: ; Check for loop limit If $count >= $userinput Then Now if the user enters a valid number while the loop is infinite it will stop if already over the limit. Or reset $count to 0 at the same time as getting the new input. M23 ah yeah, good idea, I was thinking something similar as well. thanks a bunch for the help Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 6, 2018 Moderators Share Posted September 6, 2018 HankHell, My pleasure as always. But please read the P.S. on the above post. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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