Sign in to follow this  
Followers 0
DoubleMcLovin

Exiting previous loop

11 posts in this topic

I am working on an extensive macroing interface right now, currently it looks a little something like this:

Func 1()
 call1
 call2
 call3
EndFunc

Func 2()
 While 1
   Call1
   Call2
 WEnd
EndFunc

HotKeySet("1", "1")
HotKeySet("2", "2")

That is basically the mechanic of the script. Now, my problem is that once I enter the while loop, I am unable to escape. I don't want the loop to have a condition to end itself. The loop in func 2 should continue forever if I do not press 1, but as soon as I do I want the while loop to end and the script to run the func 1, then wait for further input. How is this possible?

Share this post


Link to post
Share on other sites



DoubleMcLovin,

That was fun! :P

I needed 2 flags to make it work, but it seems to do what you want:

$fFunc_1_Running = False
$fFunc_2_Running = False

Func _1()
    ConsoleWrite("In Func 1" & @CRLF)
    If $fFunc_2_Running = True Then $fFunc_1_Running = True
    call1()
    call2()
    call3()
    ConsoleWrite("Out Func 1" & @CRLF)
EndFunc   ;==>1

Func _2()
    ConsoleWrite("In Func 2" & @CRLF)
    $fFunc_2_Running = True
    While 1
        call1()
        If $fFunc_1_Running Then ExitLoop
        call2()
        If $fFunc_1_Running Then ExitLoop
    WEnd
    ConsoleWrite("Out Func 2" & @CRLF)
    $fFunc_1_Running = False
    $fFunc_2_Running = False
    Return
EndFunc   ;==>2

Func call1()
    ConsoleWrite("Call 1" & @CRLF)
    Sleep(100)
EndFunc
Func call2()
    ConsoleWrite("Call 2" & @CRLF)
    Sleep(100)
EndFunc
Func call3()
    ConsoleWrite("Call 3" & @CRLF)
    Sleep(100)
EndFunc

Func On_Exit()
    Exit
EndFunc

HotKeySet("1", "_1")
HotKeySet("2", "_2")
HotKeySet("{ESC}", "On_Exit")

While 1
    Sleep(10)
WEnd

The ConsoleWrite lines are just so you can see what is going on as it runs - you can delete them when you are happy.

I hope I understood what you wanted correctly. :mellow:

M3


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

Spoiler

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

#3 ·  Posted (edited)

That does work indeed, but the macro interface I have has about 12 different functions that all have the possibility of running together. I can't imagine just clustering in 12 checks into each of these functions. My script would be hideous! Could you think of a way to run this through a function call maybe? Or would having 12 redundant checks be the safest way?

EDIT::

What would be the best choice, is if when I call func 1 while func 2 is running, func 1 has a way of ending func 2. With your current setup you just wait for func 2 to realize that func 1 is running and it ends because of that.

Also, maybe I am just slightly confused by your code here. It makes sense to me except for part:

call1()
        If $fFunc_1_Running Then ExitLoop
        call2()
        If $fFunc_1_Running Then ExitLoop
I understand what that does, but why is it that it never actually calls 1 or 2? Edited by DoubleMcLovin

Share this post


Link to post
Share on other sites

DoubleMcLovin,

It depends on how the different functions interact. :mellow:

Do all the functions loop like Func _2? Do you want every function to interrupt every other one when they are looping? Is there just the one Func _1 that runs and stops?

A bit more info is needed before I can try to develop anything further. :P

M23


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

Spoiler

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

#5 ·  Posted (edited)

DoubleMcLovin,

It depends on how the different functions interact. :mellow:

Do all the functions loop like Func _2? Do you want every function to interrupt every other one when they are looping?(yes) Is there just the one Func _1 that runs and stops?

A bit more info is needed before I can try to develop anything further. :P

M23

There are currently 7 functions that only process once such as your Func _1. There are also 5 functions that function such as your Func _2.

I want this to be like an either-or type of switch, meaning that as soon as another function is called (regardless of its looping ability) I want it to interrupt any loop currently in process, execute its own call, then return to the main process unless it wants to loop itself (waiting for key input by sleeping for 10ms is a good example of the main process).

Edited by DoubleMcLovin

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

DoubleMcLovin,

Sorry for the delay - dinner and France-Mexico (Viva Mexico!!!!) got in the way! :party:

Edit: Woke up with a new idea - see post below. :mellow:

I think this meets your requirements. I have commented Func _1 and Func _8 - the others are copies: :P

$fFunc_1_Running = False
$fFunc_2_Running = False
$fFunc_3_Running = False
$fFunc_4_Running = False
$fFunc_5_Running = False
$fFunc_6_Running = False
$fFunc_7_Running = False
$fFunc_8_Running = False
$fFunc_9_Running = False
$fFunc_a_Running = False
$fFunc_b_Running = False
$fFunc_c_Running = False

Func _1()
    ; Unset the HotKey to prevent multiple firing
    HotKeySet("1")
    ConsoleWrite("In Func 1" & @CRLF)
    ; Set the flag if there is a looping function running
    If _CheckLooping() = True Then $fFunc_1_Running = True
    call1()
    call2()
    call3()
    ConsoleWrite("Out Func 1" & @CRLF)
    ; reset the HotKey
    HotKeySet("1", "_1")
EndFunc   ;==>_1

Func _2()
    HotKeySet("2", "_2")
    ConsoleWrite("In Func 2" & @CRLF)
    If _CheckLooping() = True Then $fFunc_2_Running = True
    call1()
    call2()
    call3()
    ConsoleWrite("Out Func 2" & @CRLF)
    HotKeySet("2", "_2")
EndFunc   ;==>_2

Func _3()
    HotKeySet("3")
    ConsoleWrite("In Func 3" & @CRLF)
    If _CheckLooping() = True Then $fFunc_3_Running = True
    call1()
    call2()
    call3()
    ConsoleWrite("Out Func 3" & @CRLF)
    HotKeySet("3", "_3")
EndFunc   ;==>_3

Func _4()
    HotKeySet("4")
    ConsoleWrite("In Func 4" & @CRLF)
    If _CheckLooping() = True Then $fFunc_4_Running = True
    call1()
    call2()
    call3()
    ConsoleWrite("Out Func 4" & @CRLF)
    HotKeySet("4", "_4")
EndFunc   ;==>_4

Func _5()
    HotKeySet("5")
    ConsoleWrite("In Func 5" & @CRLF)
    If _CheckLooping() = True Then $fFunc_5_Running = True
    call1()
    call2()
    call3()
    ConsoleWrite("Out Func 5" & @CRLF)
    HotKeySet("5", "_5")
EndFunc   ;==>_5

Func _6()
    HotKeySet("6")
    ConsoleWrite("In Func 6" & @CRLF)
    If _CheckLooping() = True Then $fFunc_6_Running = True
    call1()
    call2()
    call3()
    ConsoleWrite("Out Func 6" & @CRLF)
    HotKeySet("6", "_6")
EndFunc   ;==>_6

Func _7()
    HotKeySet("7")
    ConsoleWrite("In Func 7" & @CRLF)
    If _CheckLooping() = True Then $fFunc_7_Running = True
    call1()
    call2()
    call3()
    ConsoleWrite("Out Func 7" & @CRLF)
    HotKeySet("7", "_7")
EndFunc   ;==>_7

Func _8()
    ; Unset the HotKey
    HotKeySet("8")
    ConsoleWrite("In Func 8" & @CRLF)
    ; Set all flags to false
    _SetAllFalse()
    ; But then set the flag for this function
    $fFunc_8_Running = True
    While 1
        call1()
        ; Check if any function other than this is running OR if this function has been terminated by another being selected
        If _CheckRunning(8) Or Not $fFunc_8_Running Then ExitLoop
        call2()
        If _CheckRunning(8) Or Not $fFunc_8_Running Then ExitLoop
    WEnd
    ConsoleWrite("Out Func 8" & @CRLF)
    ; Set al flags to false
    _SetAllFalse()
    ; Reset the HotKey
    HotKeySet("8", "_8")
    Return
EndFunc   ;==>_8

Func _9()
    HotKeySet("9")
    ConsoleWrite("In Func 9" & @CRLF)
    _SetAllFalse()
    $fFunc_9_Running = True
    While 1
        call1()
        If _CheckRunning(9) Or Not $fFunc_9_Running Then ExitLoop
        call2()
        If _CheckRunning(9) Or Not $fFunc_9_Running Then ExitLoop
    WEnd
    ConsoleWrite("Out Func 9" & @CRLF)
    _SetAllFalse()
    HotKeySet("9", "_9")
    Return
EndFunc   ;==>_9

Func _a()
    HotKeySet("a")
    ConsoleWrite("In Func A" & @CRLF)
    _SetAllFalse()
    $fFunc_a_Running = True
    While 1
        call1()
        If _CheckRunning("A") Or Not $fFunc_a_Running Then ExitLoop
        call2()
        If _CheckRunning("A") Or Not $fFunc_a_Running Then ExitLoop
    WEnd
    ConsoleWrite("Out Func A" & @CRLF)
    _SetAllFalse()
    HotKeySet("a", "_a")
    Return
EndFunc   ;==>_a

Func _b()
    HotKeySet("b")
    ConsoleWrite("In Func B" & @CRLF)
    _SetAllFalse()
    $fFunc_b_Running = True
    While 1
        call1()
        If _CheckRunning("B") Or Not $fFunc_b_Running Then ExitLoop
        call2()
        If _CheckRunning("B") Or Not $fFunc_b_Running Then ExitLoop
    WEnd
    ConsoleWrite("Out Func B" & @CRLF)
    _SetAllFalse()
    HotKeySet("b", "_b")
    Return
EndFunc   ;==>_b

Func _c()
    HotKeySet("c")
    ConsoleWrite("In Func C" & @CRLF)
    _SetAllFalse()
    $fFunc_c_Running = True
    While 1
        call1()
        If _CheckRunning("C") Or Not $fFunc_c_Running Then ExitLoop
        call2()
        If _CheckRunning("C") Or Not $fFunc_c800_Running Then ExitLoop
    WEnd
    ConsoleWrite("Out Func C" & @CRLF)
    _SetAllFalse()
    HotKeySet("c", "_c")
    Return
EndFunc   ;==>_c

Func _CheckLooping($sSelf = "")

    $fReturn = False
    If $sSelf <> 8 And $fFunc_8_Running Then $fReturn = True
    If $sSelf <> 9 And $fFunc_9_Running Then $fReturn = True
    If $sSelf <> "A" And $fFunc_a_Running Then $fReturn = True
    If $sSelf <> "B" And $fFunc_b_Running Then $fReturn = True
    If $sSelf <> "C" And $fFunc_c_Running Then $fReturn = True

    Return $fReturn

EndFunc   ;==>_CheckLooping

Func _CheckRunning($sSelf)

    $fReturn = _CheckLooping($sSelf)
    If $fFunc_1_Running Then $fReturn = True
    If $fFunc_2_Running Then $fReturn = True
    If $fFunc_3_Running Then $fReturn = True
    If $fFunc_4_Running Then $fReturn = True
    If $fFunc_5_Running Then $fReturn = True
    If $fFunc_6_Running Then $fReturn = True
    If $fFunc_7_Running Then $fReturn = True

    Return $fReturn

EndFunc   ;==>_CheckRunning

Func _SetAllFalse()

    $fFunc_1_Running = False
    $fFunc_2_Running = False
    $fFunc_3_Running = False
    $fFunc_4_Running = False
    $fFunc_5_Running = False
    $fFunc_6_Running = False
    $fFunc_7_Running = False
    $fFunc_8_Running = False
    $fFunc_9_Running = False
    $fFunc_a_Running = False
    $fFunc_b_Running = False
    $fFunc_c_Running = False

EndFunc   ;==>_SetAllFalse

Func call1()
    ConsoleWrite("Call 1" & @CRLF)
    Sleep(100)
EndFunc   ;==>call1
Func call2()
    ConsoleWrite("Call 2" & @CRLF)
    Sleep(100)
EndFunc   ;==>call2
Func call3()
    ConsoleWrite("Call 3" & @CRLF)
    Sleep(100)
EndFunc   ;==>call3

Func On_Exit()
    Exit
EndFunc   ;==>On_Exit

HotKeySet("1", "_1")
HotKeySet("2", "_2")
HotKeySet("3", "_3")
HotKeySet("4", "_4")
HotKeySet("5", "_5")
HotKeySet("6", "_6")
HotKeySet("7", "_7")
HotKeySet("8", "_8")
HotKeySet("9", "_9")
HotKeySet("a", "_a")
HotKeySet("b", "_b")
HotKeySet("c", "_c")
HotKeySet("{ESC}", "On_Exit")

While 1
    Sleep(10)
WEnd

If this does not do what you - then you are on your own from now on! :party:

M23

Edited by Melba23

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

Spoiler

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

DoubleMcLovin,

A much simpler version! :party:

The main problem with the earlier version was that it kept breaking in on running functions so that you ended up with a fair degree of stacking. You also could not break in on a running function with the same function. This new version ends each function before starting the next one, removing that limitation. :party:

We set up an array with an index marking the element containing the name of the function to run. When a HotKey is pressed it does not run the function directly, but the name of the relevant function is added to the array in the next available position (this index is also tracked). If the 2 indices do not match then there is a function waiting to run, so we end the current function and start the new one. The indices are adjusted as required and will wrap around the array when they reach the end so we get an infinite queue (I use them quite often - they are very a useful tool :party: ).

Here is the code. I hope you agree that it is a lot clearer - even if a bit longer: :mellow:

#Region ; Declarations

; Set max size for function array
Global $iMaxIndex = 10

; Declare array to hold functions waiting to be run
Global $aFunctions[$iMaxIndex] = [0]

; Set indices for running and last waiting function
Global $iRunningIndex = 0, $iWaitingIndex = 0

#EndRegion ; Declarations
#Region ; Running functions

; This function shows how to interrupt a single run macro in mid flow if that is what you want to do
Func _1()
    ConsoleWrite("In Func 1" & @CRLF)
    call1()
    If $iRunningIndex <> $iWaitingIndex Then
        ConsoleWrite("Out Func 1" & @CRLF)
        Return
    EndIf
    call2()
    If $iRunningIndex <> $iWaitingIndex Then
        ConsoleWrite("Out Func 1" & @CRLF)
        Return
    EndIf
    call3()
    If $iRunningIndex <> $iWaitingIndex Then
        ConsoleWrite("Out Func 1" & @CRLF)
        Return
    EndIf
    ConsoleWrite("Out Func 1" & @CRLF)
    
EndFunc   ;==>_1

; This function shows how to let a single run macro run completely if that is what you want to do
Func _2()
    ConsoleWrite("In Func 2" & @CRLF)
    call1()
    call2()
    call3()
    ConsoleWrite("Out Func 2" & @CRLF)
EndFunc   ;==>_2

Func _3()
    ConsoleWrite("In Func 3" & @CRLF)
    call1()
    call2()
    call3()
    ConsoleWrite("Out Func 3" & @CRLF)
EndFunc   ;==>_3

Func _4()
    ConsoleWrite("In Func 4" & @CRLF)
    call1()
    call2()
    call3()
    ConsoleWrite("Out Func 4" & @CRLF)
EndFunc   ;==>_4

Func _5()
    ConsoleWrite("In Func 5" & @CRLF)
    call1()
    call2()
    call3()
    ConsoleWrite("Out Func 5" & @CRLF)
EndFunc   ;==>_5

Func _6()
    ConsoleWrite("In Func 6" & @CRLF)
    call1()
    call2()
    call3()
    ConsoleWrite("Out Func 6" & @CRLF)
EndFunc   ;==>_6

Func _7()
    ConsoleWrite("In Func 7" & @CRLF)
    call1()
    call2()
    call3()
    ConsoleWrite("Out Func 7" & @CRLF)
EndFunc   ;==>_7

; This looping function will be interrupted immediately if another function is waiting
Func _8()
    ConsoleWrite("In Func 8" & @CRLF)
    While 1
        call1()
        If $iRunningIndex <> $iWaitingIndex Then ExitLoop
        call2()
        If $iRunningIndex <> $iWaitingIndex Then ExitLoop
    WEnd
    ConsoleWrite("Out Func 8" & @CRLF)
    Return
EndFunc   ;==>_8

Func _9()
    ConsoleWrite("In Func 9" & @CRLF)
    While 1
        call1()
        If $iRunningIndex <> $iWaitingIndex Then ExitLoop
        call2()
        If $iRunningIndex <> $iWaitingIndex Then ExitLoop
    WEnd
    ConsoleWrite("Out Func 9" & @CRLF)
    Return
EndFunc   ;==>_9

Func _a()
    ConsoleWrite("In Func a" & @CRLF)
    While 1
        call1()
        If $iRunningIndex <> $iWaitingIndex Then ExitLoop
        call2()
        If $iRunningIndex <> $iWaitingIndex Then ExitLoop
    WEnd
    ConsoleWrite("Out Func a" & @CRLF)
    Return
EndFunc   ;==>_a
Func _b()
    ConsoleWrite("In Func b" & @CRLF)
    While 1
        call1()
        If $iRunningIndex <> $iWaitingIndex Then ExitLoop
        call2()
        If $iRunningIndex <> $iWaitingIndex Then ExitLoop
    WEnd
    ConsoleWrite("Out Func b" & @CRLF)
    Return
EndFunc   ;==>_b
Func _c()
    ConsoleWrite("In Func c" & @CRLF)
    While 1
        call1()
        If $iRunningIndex <> $iWaitingIndex Then ExitLoop
        call2()
        If $iRunningIndex <> $iWaitingIndex Then ExitLoop
    WEnd
    ConsoleWrite("Out Func c" & @CRLF)
    Return
EndFunc   ;==>_cc

#EndRegion ; Running functions
#Region ; Adding functions

; These HotKey functions add the relevant function to the array ready for running

Func _Add_1()

    ; Increase Waiting Index
    _Inc_Waiting_Index()
    ; Add function to list
    $aFunctions[$iWaitingIndex] = "_1"

EndFunc   ;==>_Add_1

Func _Add_2()

    ; Increase Waiting Index
    _Inc_Waiting_Index()
    ; Add function to list
    $aFunctions[$iWaitingIndex] = "_2"

EndFunc   ;==>_Add_2

Func _Add_3()

    ; Increase Waiting Index
    _Inc_Waiting_Index()
    ; Add function to list
    $aFunctions[$iWaitingIndex] = "_3"

EndFunc   ;==>_Add_3

Func _Add_4()

    ; Increase Waiting Index
    _Inc_Waiting_Index()
    ; Add function to list
    $aFunctions[$iWaitingIndex] = "_4"

EndFunc   ;==>_Add_4

Func _Add_5()

    ; Increase Waiting Index
    _Inc_Waiting_Index()
    ; Add function to list
    $aFunctions[$iWaitingIndex] = "_5"

EndFunc   ;==>_Add_5

Func _Add_6()

    ; Increase Waiting Index
    _Inc_Waiting_Index()
    ; Add function to list
    $aFunctions[$iWaitingIndex] = "_6"

EndFunc   ;==>_Add_6

Func _Add_7()

    ; Increase Waiting Index
    _Inc_Waiting_Index()
    ; Add function to list
    $aFunctions[$iWaitingIndex] = "_7"

EndFunc   ;==>_Add_7

Func _Add_8()

    ; Increase Waiting Index
    _Inc_Waiting_Index()
    ; Add function to list
    $aFunctions[$iWaitingIndex] = "_8"

EndFunc   ;==>_Add_8

Func _Add_9()

    ; Increase Waiting Index
    _Inc_Waiting_Index()
    ; Add function to list
    $aFunctions[$iWaitingIndex] = "_9"

EndFunc   ;==>_Add_9

Func _Add_a()

    ; Increase Waiting Index
    _Inc_Waiting_Index()
    ; Add function to list
    $aFunctions[$iWaitingIndex] = "_a"

EndFunc   ;==>_Add_a

Func _Add_b()

    ; Increase Waiting Index
    _Inc_Waiting_Index()
    ; Add function to list
    $aFunctions[$iWaitingIndex] = "_b"

EndFunc   ;==>_Add_b

Func _Add_c()

    ; Increase Waiting Index
    _Inc_Waiting_Index()
    ; Add function to list
    $aFunctions[$iWaitingIndex] = "_c"

EndFunc   ;==>_Add_c

; Increases the array index for the next waiting function to be added
Func _Inc_Waiting_Index()
    $iWaitingIndex += 1
    If $iWaitingIndex = $iMaxIndex Then $iWaitingIndex = 0
EndFunc   ;==>_Inc_Waiting_Index

#EndRegion ; Adding functions
#Region ; Called functions

Func call1()
    ConsoleWrite("Call 1" & @CRLF)
    Sleep(100)
EndFunc   ;==>call1
Func call2()
    ConsoleWrite("Call 2" & @CRLF)
    Sleep(100)
EndFunc   ;==>call2
Func call3()
    ConsoleWrite("Call 3" & @CRLF)
    Sleep(100)
EndFunc   ;==>call3

#EndRegion ; Called functions
#Region ; Main loop

Func On_Exit()
    Exit
EndFunc   ;==>On_Exit

HotKeySet("1", "_Add_1")
HotKeySet("2", "_Add_2")
HotKeySet("3", "_Add_3")
HotKeySet("4", "_Add_4")
HotKeySet("5", "_Add_5")
HotKeySet("6", "_Add_6")
HotKeySet("7", "_Add_7")
HotKeySet("8", "_Add_8")
HotKeySet("9", "_Add_9")
HotKeySet("a", "_Add_a")
HotKeySet("b", "_Add_b")
HotKeySet("c", "_Add_c")
HotKeySet("{ESC}", "On_Exit")

While 1
    Sleep(10)
    If $iRunningIndex <> $iWaitingIndex Then
        ; Increase the array index for the function to run
        $iRunningIndex += 1
        If $iRunningIndex = $iMaxIndex Then $iRunningIndex = 0
        ; Run the function
        Call($aFunctions[$iRunningIndex])
    EndIf
WEnd

#EndRegion ; Main loop

A couple of further points;

- I have adjusted Func _1() to exit as quickly as possible if another function is waiting. At the moment it looks like a lot of code, but that is only because I wanted to use the ConsoleWrite to show what was going on. Once you no longer need those lines, Each If..Then can be reduced to:

If $iRunningIndex <> $iWaitingIndex Then Return

Obviously once you have decided which way you want the single run functions to work, you need to adjust them so that they all do the same thing. If you want to see the difference, I suggest you increase the Sleep(100) lines in teh call1, etc function to Sleep(1000) so that you have time to interrupt the function in mid-flow. :party:

- Similarly, the looping functions (Func _8 to Func _c) can have their ConsoleWrite lines removed and their If..Then lines changed as above.

- I have set the size of the array to 10 which seems adequate to cope with the short call1, etc functions we have here. If your called functions take considerably longer, you may want to increase the size of the array so that you lower the risk of overrunning the buffer by adding too many waiting functions. All you need do is to increase the value of $iMaxIndex.

I hope that is all clear and does what you want. Please ask if you have any questions on the code. :P

M23


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

Spoiler

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

#8 ·  Posted (edited)

That works brilliantly! The code is much more extensive, but runs smooth. Thank you very much. I am going to take a few minutes to implement my existing macros into it, and then I will edit this post with further thoughts and questions.

EDIT:

Absolutely brilliant! I love it. I had rigged up a mechanism that used a variable $counter and would alternate between setting the counter true or false and ran checks on that, very short but it bugged up a lot on me. I am glad you made this revision, it does exactly what I wanted. Now if only I could figure out what part of my function is forcing a restart on my computer lol >_>

Edited by DoubleMcLovin

Share this post


Link to post
Share on other sites

DoubleMcLovin,

Just for my personal interest, did you go for the "interruptable" one-shot function or the "run-it-all" version?

Glad you like it - I admit I am quite pleased with it too! :mellow:

M23


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

Spoiler

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

I used your second script that you submitted, and a combination of both sets of options in there. Basically my layout looks somewhat like yours now. And I am pleased to say that the script is running perfectly now. After the stacking issue was resolved the minor problems made themselves obvious and I fixed those pretty easily.

Share this post


Link to post
Share on other sites

DoubleMcLovin,

Good to hear. I am delighted we got it to work so well. :mellow:

M23


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

Spoiler

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

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  
Followers 0