Jump to content
Sign in to follow this  

Infinity loop on AdlibRegister..

Recommended Posts


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
ConsoleWrite("Start Sleep" & @CRLF )
ConsoleWrite("End Sleep" & @CRLF )

Func function()
;~  AdlibUnRegister()
    $num = $num + 1
    ConsoleWrite("test" & $num & @CRLF )
Edited by MiserableLife

Share this post

Link to post
Share on other sites


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                      |            Inactive

The 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()

; 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

; The Adlib function
Func Counter()
    ; Increase counter
    $i += 1
    ; Write it
    ConsoleWrite($i & @CRLF)

I hope that helps. Ask if anything is unclear. :evil:


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites

The way you express is very clear..


Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this