MiserableLife Posted January 3, 2010 Posted January 3, 2010 (edited) I've ran into a little problem here. I wanted to understand how AdlibRegister works but some how it just loops. The way I understand AdlibReg is like this: Part A Time line Part B 1. AdlibRegister( Func , Sleep Time ) | 2. Continue Script v Register Func And Sleep( Sleep Time ) 3. Do Something | Sleeping 4. Paused v Pause Script after sleep and run func 5. Script Continued | Sleeping Why does it loop so many times and the script does not exit? And another question is, in Step 4 Part B, will the script be paused UNTIL the function is finnished ? The code to make the infinity loop happen: Global $num AdlibRegister('function',100) ConsoleWrite("Start Sleep" & @CRLF ) Sleep(100) ConsoleWrite("End Sleep" & @CRLF ) Func function() sleep(100) ;~ AdlibUnRegister() $num = $num + 1 ConsoleWrite("test" & $num & @CRLF ) EndFunc Edited January 3, 2010 by MiserableLife
Moderators Melba23 Posted January 3, 2010 Moderators Posted January 3, 2010 MiserableLife,I am not sure your understanding of Adlib is correct - here is mine:Main script Time line Adlib function 1. AdlibRegister( Func , Time ) | 2. Continue Script | Inactive 3. Paused Time Run 4. Continue Script | Inactive 5. Paused Time Run 6. Continue Script | InactiveThe Adlib function interrupts the main script every Time ms and this will continue until you AdlibUnregister the function or the script ends.I have no idea what you want to do in your script. If you want to run a count every 100ms, then one way to do it is like this:; Give ourselves an out by pressing ESC HotKeySet("{ESC}", "On_Exit") Func On_Exit() Exit EndFunc ; Register the Adlib function AdlibRegister("Counter", 100) ; Set the counter $i = 0 ; Start an infinite loop - but this could be anything you wanted While 1 Sleep(10) WEnd ; The Adlib function Func Counter() ; Increase counter $i += 1 ; Write it ConsoleWrite($i & @CRLF) EndFuncI hope that helps. Ask if anything is unclear. 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
MiserableLife Posted January 3, 2010 Author Posted January 3, 2010 The way you express is very clear.. Thanks!
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