Jump to content

Timer made from array / listview items?


zvvyt
 Share

Go to solution Solved by dmob,

Recommended Posts

Hello again.

First of all, this is a "version 2.0" of the scipt posted at '?do=embed' frameborder='0' data-embedContent>> if you'd like to get the whole picture of this.

What I have is a ListView created with GUICtrlCreateListView with, f.ex, columns "a" and "b".

The number of items in the ListView will vary all from "0" to "n", all based on the user.

In column "a" there will be a string which will decide what function to be run, and in column "b" there will be a value of at what interval the specific function will be ran.

In the original script I've used _Timer_SetTimer as a global timer, triggering all functions after another, but now I'd like all the functions to have their own intervals.

Is it possible to use _Timer_SetTimer for this, or would it be easier to use another type of timerfunction?

Don't know if I'm making any sense in this, so feel free to ask if there's anything I can do to help you help me.

Best regards,

zvvyt

Link to comment
Share on other sites

Post your code, then we'll all know what you're talking about.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Here's the current script in its whole.

The timer is under the _Run-function.

An edit for the original post:

I need to at least know the data of 3 columns, not just 2.

I need the user-specified name, the "action" to do and the interval, OR just the name as the other 2 are easily retrieveable after that. 

;#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <EditConstants.au3>
#include <String.au3>
;#include <Array.au3>
#include <Constants.au3>
#include <File.au3>
#include <ComboConstants.au3>
#include <Timers.au3>

#NoTrayIcon

Opt("TrayMenuMode", 1 + 2)
Local $Tray_name = TrayCreateItem("E60 Folder checker")
TrayItemSetState(-1, $TRAY_DISABLE)
TrayCreateItem("")
Local $Tray_settings = TrayCreateItem("Settings")
TrayCreateItem("")
Local $Tray_exit = TrayCreateItem("Exit")
TraySetState(2)

Global $Input_name, $Main_window, $list, $Interval_input, $Interval_format, $Button_new, $Button_delete, $Button_info, $Button_save, $Button_start, $Timer_delay, $Action_count, $_Action_filetype, $_Action_folder

Call("_Settings")
Func _Settings()
    $Main_window = GUICreate("E60 Folder checker - Settings", 400, 300, -1, -1)
    ;GUICtrlCreatePic("E60.jpg", 0, 0, 400, 300)
    ;GUICtrlSetState(-1, $gui_disable)
    $list = GUICtrlCreateListView("Name |Function |Folder(s) to check |Files |Date    ", 20, 100, 360, 150)
    $Button_new = GUICtrlCreateButton("New", 25, 260, 80, 30)
    $Button_delete = GUICtrlCreateButton("Delete", 115, 260, 80, 30)
    $Button_info = GUICtrlCreateButton("Info", 205, 260, 80, 30)
    $Button_save = GUICtrlCreateButton("Save", 295, 260, 80, 30)
    $Interval_input = GUICtrlCreateInput("0", 285, 30, 40, 22, $ES_NUMBER)
    GUICtrlSetLimit(-1, 4, 1)
    $Interval_format = GUICtrlCreateCombo("ms", 340, 30, 40, Default, $CBS_DROPDOWNLIST)
    GUICtrlSetData(-1, "s|min|h")
    $Button_run = GUICtrlCreateButton("Run", 300, 60, 80, 30)
    $Checkbox_log = GUICtrlCreateCheckbox("Make log-file", 20,20,-1,-1)

    GUISetState(@SW_SHOW)
    #region Load-part
    If FileExists("Settings.ini") Then
        If FileReadLine("Settings.ini", 1) <> "" Then
            $Load_interval = StringSplit(FileReadLine("Settings.ini", 1), " ", 1)
            GUICtrlSetData($Interval_input, $Load_interval[1])
            GUICtrlSetData($Interval_format, $Load_interval[2])
        EndIf
        $Load_check_earlier_functions = IniReadSectionNames("Settings.ini")
        If @error Then
        Else
            $Load_interval = StringSplit(FileReadLine("Settings.ini", 1), " ", 1)
            GUICtrlSetData($Interval_input, $Load_interval[1])
            GUICtrlSetData($Interval_format, $Load_interval[2])
            For $Load_Count1 = 1 To $Load_check_earlier_functions[0] Step +1
                $Load_read_earlier_functions = IniReadSection("Settings.ini", $Load_check_earlier_functions[$Load_Count1])
                GUICtrlCreateListViewItem($Load_check_earlier_functions[$Load_Count1] & "|" & $Load_read_earlier_functions[1][1] & "|" & $Load_read_earlier_functions[2][1] & "|" & $Load_read_earlier_functions[3][1] & "|" & $Load_read_earlier_functions[4][1], $list)
            Next
        EndIf
    EndIf
    #endregion Load-part
    While 1
        $Msg = GUIGetMsg()
        Switch $Msg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button_new
                ConsoleWrite("New-function initiated" & @CRLF)
                Call("_New")
                ConsoleWrite("New-function ended" & @CRLF)
            Case $Button_delete
                ConsoleWrite("Delete-function initiated" & @CRLF)
                Call("_Delete")
                ConsoleWrite("Delete-function ended" & @CRLF)
            Case $Button_info
                Call("_Info")
            Case $Button_save
                ConsoleWrite("Save-function initiated" & @CRLF)
                Call("_Save")
                ConsoleWrite("Save-function ended" & @CRLF)
            Case $Button_run
                ConsoleWrite("Run-function initiated" & @CRLF)
                GUISetState(@SW_HIDE, $Main_window)
                GUISetState(@SW_LOCK, $Main_window)
                TraySetState(1)
                Call("_Run")
                TraySetState(2)
                GUISetState(@SW_UNLOCK, $Main_window)
                GUISetState(@SW_SHOW, $Main_window)
                ConsoleWrite("Run-function ended" & @CRLF)
        EndSwitch
        If _GUICtrlListView_GetSelectedCount($list) = 0 And GUICtrlGetState($Button_delete) = 80 Then
            GUICtrlSetState($Button_delete, $gui_disable)
            GUICtrlSetState($Button_info, $gui_disable)
        EndIf
        If _GUICtrlListView_GetSelectedCount($list) > 0 And GUICtrlGetState($Button_delete) = 144 Then
            GUICtrlSetState($Button_delete, $gui_enable)
            GUICtrlSetState($Button_info, $gui_enable)
        EndIf
        $Interval_input_checker = StringSplit(GUICtrlRead($Interval_input), "0")
        If $Interval_input_checker[1] = "" And GUICtrlRead($Interval_input) <> "0" Then GUICtrlSetData($Interval_input, StringReplace(GUICtrlRead($Interval_input), "0", "", 1))
    WEnd
EndFunc   ;==>_Settings

#region "New" part
Func _New()
    #region Function selection part
    $Input_name = InputBox("Folder checker - New", "Enter a name for the new function" & @CRLF & "NOTE! Duplicate or blank names are not allowed", "", "", "", "", Default, Default, "", $Main_window)
    If @error = 1 Then
        ConsoleWrite("Cancel@Name check" & @CRLF)
        Return
    EndIf
    If @error <> 0 Then
        ConsoleWrite("ERROR:" & @error & "@Name check")
        Return
    EndIf
    If $Input_name = "" Then
        Do
            $Input_name = InputBox("Folder checker - New", "Enter a name for the new function" & @CRLF & "NOTE! Duplicate or blank names are not allowed", "", "", "", "", Default, Default, "", $Main_window)
            If @error = 1 Then
                ConsoleWrite("Cancel@Name check" & @CRLF)
                Return
            EndIf
            If @error <> 0 Then
                ConsoleWrite("ERROR:" & @error & "@Name check")
                Return
            EndIf
        Until $Input_name <> ""
    EndIf
    For $1 = 0 To _GUICtrlListView_GetItemCount($list) Step +1
        $Name_dublicate_check = _GUICtrlListView_GetItemText($list, $1, 0)
        If $Input_name = $Name_dublicate_check Then
            ConsoleWrite("Duplicate names!" & @CRLF)
            MsgBox(0, "Folder checker - Error", "Name already in use. Please select a new name")
            $Input_name = ""
            $Name_dublicate_check = ""
            Call("_New")
            Return
        EndIf
    Next
    ConsoleWrite("Passed namecheck" & @CRLF)
    $Select_function = GUICreate("Folder checker - Select a function", 200, 200, -1, -1, $WS_BORDER, "", $Main_window)
    $Select_function_func1 = GUICtrlCreateRadio("Copy files", 30, 20, 170, 30) ;-----------------------------------COPY
    GUICtrlSetTip(-1, "Click the ""?"" for more info")
    $Select_function_func2 = GUICtrlCreateRadio("Move files", 30, 50, 170, 30) ;-----------------------------------MOVE
    GUICtrlSetTip(-1, "Click the ""?"" for more info")
    $Select_function_func3 = GUICtrlCreateRadio("Delete files", 30, 80, 170, 30) ;---------------------------------DELETE
    GUICtrlSetTip(-1, "Click the ""?"" for more info")
    $Select_function_continue = GUICtrlCreateButton("Continue", 15, 140, 80, 30)
    GUICtrlSetState(-1, $gui_disable)
    Local $Select_function_continue_disabled = 1
    $Select_function_cancel = GUICtrlCreateButton("Cancel", 105, 140, 80, 30)
    GUISetState(@SW_SHOW)
    Local $Function_selected = ""
    Local $Destinating_folder
    While 1 ;----------------------------------------Select function
        ;if WinActive($Main_window) then WinActivate($Select_function)
        GUISetState(@SW_DISABLE, $Main_window)
        $Msg = GUIGetMsg()
        If $Select_function_continue_disabled = 1 And BitXOR(GUICtrlRead($Select_function_func1), GUICtrlRead($Select_function_func2), GUICtrlRead($Select_function_func3)) = $GUI_CHECKED Then
            GUICtrlSetState($Select_function_continue, $gui_enable)
            $Select_function_continue_disabled = 0
        EndIf
        Switch $Msg
            Case $Select_function_cancel
                ConsoleWrite("Cancel@Function selection" & @CRLF)
                GUISetState(@SW_ENABLE, $Main_window)
                GUIDelete($Select_function)
                WinActivate($Main_window)
                Return
            Case $Select_function_continue
                If BitAND(GUICtrlRead($Select_function_func1), $GUI_CHECKED) = $GUI_CHECKED Then
                    GUIDelete($Select_function)
                    $Function_selected = "Copy"
                    ;call("NewCopy")
                EndIf
                If BitAND(GUICtrlRead($Select_function_func2), $GUI_CHECKED) = $GUI_CHECKED Then
                    GUIDelete($Select_function)
                    $Function_selected = "Move"
                    ;call("NewMove")
                EndIf
                If BitAND(GUICtrlRead($Select_function_func3), $GUI_CHECKED) = $GUI_CHECKED Then
                    GUIDelete($Select_function)
                    $Function_selected = "Delete"
                    ;call("NewDelete")
                EndIf
                ;GUISetState(@SW_ENABLE,$Main_window)
                ExitLoop
        EndSwitch
    WEnd
    #endregion Function selection part
    #region Folder selection part
    ConsoleWrite($Function_selected)
    If $Function_selected = "Delete" Then
        $Origin_folder = FileSelectFolder("Select file folder", "", 1, "", $Main_window)
        If @error = 1 Then
            ConsoleWrite("Cancel@Folder selction" & @CRLF)
            GUISetState(@SW_ENABLE, $Main_window)
            Return
        EndIf
    Else
        $Origin_folder = FileSelectFolder("Select file origin folder", "", 1, "", $Main_window)
        If @error = 1 Then
            ConsoleWrite("Cancel@Origin folder selction" & @CRLF)
            GUISetState(@SW_ENABLE, $Main_window)
            Return
        EndIf
        $Destinating_folder = FileSelectFolder("Select destinating folder", "", 1, "", $Main_window)
        If @error = 1 Then
            ConsoleWrite("Cancel@Destinating folder selction" & @CRLF)
            GUISetState(@SW_ENABLE, $Main_window)
            Return
        EndIf
        If $Origin_folder = $Destinating_folder Then
            Do
                MsgBox(0, "Error", "Same folder specified. Please chose another folder to copy from/to")
                $Origin_folder = FileSelectFolder("Select file origin folder", "", 1, "", $Main_window)
                If @error = 1 Then
                    ConsoleWrite("Cancel@Origin folder selction" & @CRLF)
                    GUISetState(@SW_ENABLE, $Main_window)
                    Return
                EndIf
                $Destinating_folder = FileSelectFolder("Select destinating folder", "", 1, "", $Main_window)
                If @error = 1 Then
                    ConsoleWrite("Cancel@Destinating folder selction" & @CRLF)
                    GUISetState(@SW_ENABLE, $Main_window)
                    Return
                EndIf
            Until $Origin_folder <> $Destinating_folder
        EndIf
    EndIf
    #endregion Folder selection part
    #region File selection part

    $Select_files = GUICreate("Folder checker - Select files", 200, 200, -1, -1, $WS_BORDER, "", $Main_window)
    $All_files = GUICtrlCreateRadio("All files", 30, 30, 170, 30)
    $Specific_files = GUICtrlCreateRadio("Specific filetype", 30, 60, 170, 30)
    $Filetype_input = GUICtrlCreateInput("", 50, 100, 100, 20)
    $Select_files_continue = GUICtrlCreateButton("Continue", 15, 140, 80, 30)
    GUICtrlSetState(-1, $gui_disable)
    Local $Select_files_continue_disable = 1
    $Select_files_cancel = GUICtrlCreateButton("Cancel", 105, 140, 80, 30)
    GUICtrlSetState($Filetype_input, $gui_disable)
    GUISetState(@SW_SHOW)
    Local $Filetype_input_Dot_checker[4]
    While 1
        $Filetype_input_Space_checker = StringSplit(GUICtrlRead($Filetype_input), " ")
        If $Filetype_input_Space_checker[0] = 2 Then
            $Filetype_input_no_space = StringReplace(GUICtrlRead($Filetype_input), " ", "")
            GUICtrlSetData($Filetype_input, $Filetype_input_no_space)
        EndIf
        $Filetype_input_Dot_checker = StringSplit(GUICtrlRead($Filetype_input), ".")
        If $Filetype_input_Dot_checker[0] >= 2 Then
            If $Filetype_input_Dot_checker[1] <> "" Then
                GUICtrlSetData($Filetype_input, StringReplace(GUICtrlRead($Filetype_input), ".", "", 1))
            EndIf
            If $Filetype_input_Dot_checker[0] = 3 Then
                GUICtrlSetData($Filetype_input, _StringReverse(StringReplace(_StringReverse(GUICtrlRead($Filetype_input)), ".", "", 1)))
            EndIf
        EndIf
        GUISetState(@SW_DISABLE, $Main_window)
        If GUICtrlRead($Specific_files) = 1 And GUICtrlRead($Filetype_input) = "" And $Select_files_continue_disable = 0 Then
            GUICtrlSetState($Select_files_continue, $gui_disable)
            $Select_files_continue_disable = 1
        EndIf
        If GUICtrlRead($Specific_files) = 1 And GUICtrlRead($Filetype_input) = "." And $Select_files_continue_disable = 0 Then
            GUICtrlSetState($Select_files_continue, $gui_disable)
            $Select_files_continue_disable = 1
        EndIf
        If GUICtrlRead($All_files) = 1 And $Select_files_continue_disable = 1 Then
            GUICtrlSetState($Select_files_continue, $gui_enable)
            $Select_files_continue_disable = 0
        EndIf
        If GUICtrlRead($Specific_files) = 1 And GUICtrlRead($Filetype_input) <> "" And $Select_files_continue_disable = 1 And GUICtrlRead($Filetype_input) <> "." Then
            GUICtrlSetState($Select_files_continue, $gui_enable)
            $Select_files_continue_disable = 0
        EndIf
        $Msg = GUIGetMsg()
        Switch $Msg
            Case $Select_files_cancel
                GUISetState(@SW_ENABLE, $Main_window)
                ConsoleWrite("Cancel@File selection" & @CRLF)
                GUIDelete($Select_files)
                Return
            Case $Specific_files
                GUICtrlSetState($Filetype_input, $gui_enable)
            Case $All_files
                GUICtrlSetState($Filetype_input, $gui_disable)
            Case $Select_files_continue
                $Function_date_made_long = @YEAR & @MON & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC
                $Function_date_made = @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN
                If GUICtrlRead($All_files) = $GUI_CHECKED Then
                    If $Function_selected = "Delete" Then
                        GUICtrlCreateListViewItem($Input_name & "|" & $Function_selected & "|" & $Origin_folder & "|All|" & $Function_date_made_long, $list)
                    Else
                        GUICtrlCreateListViewItem($Input_name & "|" & $Function_selected & "|" & $Origin_folder & " to " & $Destinating_folder & "|All|" & $Function_date_made_long, $list)
                    EndIf
                    GUIDelete($Select_files)
                    ConsoleWrite("All files" & @CRLF)
                EndIf
                If GUICtrlRead($Specific_files) = $GUI_CHECKED And GUICtrlRead($Filetype_input) <> "" Then
                    $Filetype_input_Dot_checker = StringSplit(GUICtrlRead($Filetype_input), ".")
                    If $Filetype_input_Dot_checker[0] = 1 Then
                        GUICtrlSetData($Filetype_input, "." & GUICtrlRead($Filetype_input))
                    EndIf
                    $Filetype_input = StringLower(GUICtrlRead($Filetype_input))
                    If $Function_selected = "Delete" Then
                        GUICtrlCreateListViewItem($Input_name & "|" & $Function_selected & "|" & $Origin_folder & "|" & $Filetype_input & "|" & $Function_date_made_long, $list)
                    Else
                        GUICtrlCreateListViewItem($Input_name & "|" & $Function_selected & "|" & $Origin_folder & " to " & $Destinating_folder & "|" & $Filetype_input & "|" & $Function_date_made_long, $list)
                    EndIf
                    GUIDelete($Select_files)
                    ConsoleWrite("Specific files" & @CRLF)
                EndIf
                GUISetState(@SW_ENABLE, $Main_window)
                ExitLoop
        EndSwitch
    WEnd

    #endregion File selection part
    WinActivate($Main_window)
EndFunc   ;==>_New
#endregion "New" part

Func _Delete()
    _GUICtrlListView_DeleteItemsSelected($list)
EndFunc   ;==>_Delete
Func _Info()

EndFunc   ;==>_Info
Func _Save()
    ;Thanks Melba.
    If GUICtrlRead($Interval_input) = "" Then GUICtrlSetData($Interval_input, "0")
    _FileWriteToLine("Settings.ini", 1, GUICtrlRead($Interval_input) & " " & GUICtrlRead($Interval_format), 1)
    GUICtrlSetState($Button_save, $gui_disable)
    $Save_check_earlier_functions = IniReadSectionNames("Settings.ini")
    If @error Then
        Local $Save_check_earlier_functions[1] = ["0"]
    EndIf
    $Save_check_current_functions = _GUICtrlListView_GetItemCount($list)
    ; Are there any saved functions to check?
    If $Save_check_earlier_functions[0] <> 0 Then
        ; Loop through the ini and check if sections are in the ListView
        For $Save_Count1 = 1 To $Save_check_earlier_functions[0]
            $iIndex = _GUICtrlListView_FindText($list, $Save_check_earlier_functions[$Save_Count1])
            ; If not found then delete
            If $iIndex = -1 Then
                IniDelete("Settings.ini", $Save_check_earlier_functions[$Save_Count1])
            EndIf
        Next
    EndIf
    ; Are there any items in the ListView?
    If $Save_check_current_functions > 0 Then
        ; Now loop through ListView and see if any functions need to be added
        For $Save_Count2 = 0 To $Save_check_current_functions - 1 ; Remember ListView items are 0-indexed
            $iIndex = _ArraySearch($Save_check_earlier_functions, _GUICtrlListView_GetItemText($list, $Save_Count2, 0))
            ; If not found then add
            If $iIndex = -1 Then
                IniWrite("Settings.ini", _GUICtrlListView_GetItemText($list, $Save_Count2, 0), "Function", _GUICtrlListView_GetItemText($list, $Save_Count2, 1))
                IniWrite("Settings.ini", _GUICtrlListView_GetItemText($list, $Save_Count2, 0), "Folder", _GUICtrlListView_GetItemText($list, $Save_Count2, 2))
                IniWrite("Settings.ini", _GUICtrlListView_GetItemText($list, $Save_Count2, 0), "File", _GUICtrlListView_GetItemText($list, $Save_Count2, 3))
                IniWrite("Settings.ini", _GUICtrlListView_GetItemText($list, $Save_Count2, 0), "Date", _GUICtrlListView_GetItemText($list, $Save_Count2, 4))
            EndIf
        Next
    EndIf
    GUICtrlSetState($Button_save, $gui_enable)
EndFunc   ;==>_Save
Func _Run()
    If GUICtrlRead($Interval_format) = "ms" Then $Timer_delay = GUICtrlRead($Interval_input) * 1
    If GUICtrlRead($Interval_format) = "s" Then $Timer_delay = GUICtrlRead($Interval_input) * 1000
    If GUICtrlRead($Interval_format) = "min" Then $Timer_delay = GUICtrlRead($Interval_input) * 60000
    If GUICtrlRead($Interval_format) = "h" Then $Timer_delay = GUICtrlRead($Interval_input) * 3600000
    $Timer = _Timer_SetTimer($Main_window, $Timer_delay, "_Action") ;------------------------------- Current timer
    While 1
        Switch TrayGetMsg()
            Case $Tray_settings
                _Timer_KillTimer($Main_window, $Timer)
                ExitLoop
            Case $Tray_exit
                _Timer_KillTimer($Main_window, $Timer)
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>_Run

Func _Action($hWnd, $Msg, $iIDTimer, $dwTime)
    #forceref $hWnd, $Msg, $iIDTimer, $dwTime
    ConsoleWrite("Timer reached" & @CRLF)
    $Action_listview_count = _GUICtrlListView_GetItemCount($list)
    If $Action_listview_count >= 1 Then
        For $Action_count = 0 To $Action_listview_count Step +1
            $_Action_folder = _GUICtrlListView_GetItemText($list, $Action_count, 2)
            $_Action_filetype = _GUICtrlListView_GetItemText($list, $Action_count, 3)
            If _GUICtrlListView_GetItemText($list, $Action_count, 1) = "Copy" Then Call("_Action_Copy")
            If _GUICtrlListView_GetItemText($list, $Action_count, 1) = "Move" Then Call("_Action_Move")
            If _GUICtrlListView_GetItemText($list, $Action_count, 1) = "Delete" Then Call("_Action_Delete")
        Next
    EndIf
EndFunc   ;==>_Action

Func _Action_Copy()
    ConsoleWrite("Action_Copy" & @CRLF)
    $_Action_folder_split = StringSplit($_Action_folder, " to ", 1)
    If $_Action_filetype = "All" Then
        $_Action_Source_folder_files = _FileListToArray($_Action_folder_split[1], "*.*", 1)
        If $_Action_Source_folder_files <> 0 Then
            $Action_Time = @YEAR&@MON&@MDAY&":"&@HOUR&":"&@MIN&":"&@SEC
            IniWriteSection("Log.ini",$Action_Time &" Copy","")
            If $_Action_Source_folder_files = 0 Then Return
            For $_Action_count1 = 1 To $_Action_Source_folder_files[0] Step +1
                If FileExists($_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1]) Then
                    If FileGetTime($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], 0, 1) > FileGetTime($_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 0, 1) Then
                        ; Copy and replace
                        FileCopy($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 1)
                        IniWriteSection("Log.ini",$Action_Time, $_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1] &" to "& $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1])
                    EndIf
                Else
                    FileCopy($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 1)
                    IniWriteSection("Log.ini",$Action_Time, $_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1] &" to "& $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1])
                EndIf
            Next
        EndIf
    Else
        $_Action_Source_folder_files = _FileListToArray($_Action_folder_split[1], "*" & $_Action_filetype, 1)
        If $_Action_Source_folder_files <> 0 Then
            $Action_Time = @YEAR&@MON&@MDAY&":"&@HOUR&":"&@MIN&":"&@SEC
            IniWriteSection("Log.ini",$Action_Time&" Copy","")
            For $_Action_count1 = 1 To $_Action_Source_folder_files[0] Step +1
                If FileExists($_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1]) Then
                    If FileGetTime($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], 0, 1) > FileGetTime($_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 0, 1) Then
                        ; Copy and replace
                        FileCopy($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 9)
                        IniWriteSection("Log.ini",$Action_Time, $_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1] &" to "& $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1])
                    EndIf
                Else
                    FileCopy($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 9)
                    IniWriteSection("Log.ini",$Action_Time, $_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1] &" to "& $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1])
                EndIf
            Next
        EndIf
    EndIf
    Return
EndFunc   ;==>_Action_Copy

Func _Action_Move()
    ConsoleWrite("Action_Move" & @CRLF)
    $_Action_folder_split = StringSplit($_Action_folder, " to ", 1)
    If $_Action_filetype = "All" Then
        $_Action_Source_folder_files = _FileListToArray($_Action_folder_split[1], "*.*", 1)
        If $_Action_Source_folder_files <> 0 Then
            $Action_Time = @YEAR&@MON&@MDAY&":"&@HOUR&":"&@MIN&":"&@SEC
            IniWriteSection("Log.ini",$Action_Time&" Move","")
            For $_Action_count1 = 1 To $_Action_Source_folder_files[0] Step +1
                If FileExists($_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1]) Then
                    If FileGetTime($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], 0, 1) >= FileGetTime($_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 0, 1) Then
                        FileMove($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 1)
                        IniWriteSection("Log.ini",$Action_Time, $_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1] &" to "& $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1])
                    EndIf
                Else
                    FileMove($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 1)
                    IniWriteSection("Log.ini",$Action_Time, $_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1] &" to "& $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1])
                EndIf
            Next
        EndIf
    Else
        $_Action_Source_folder_files = _FileListToArray($_Action_folder_split[1], "*" & $_Action_filetype, 1)
        If $_Action_Source_folder_files <> 0 Then
            $Action_Time = @YEAR&@MON&@MDAY&":"&@HOUR&":"&@MIN&":"&@SEC
            IniWriteSection("Log.ini",$Action_Time&" Move","")
            For $_Action_count1 = 1 To $_Action_Source_folder_files[0] Step +1
                If FileExists($_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1]) Then
                    If FileGetTime($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], 0, 1) >= FileGetTime($_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 0, 1) Then
                        FileMove($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 9)
                        IniWriteSection("Log.ini",$Action_Time, $_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1] &" to "& $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1])
                    EndIf
                Else
                    FileMove($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 9)
                    IniWriteSection("Log.ini",$Action_Time, $_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1] &" to "& $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1])
                EndIf
            Next
        EndIf
    EndIf
    Return
EndFunc   ;==>_Action_Move

Func _Action_Delete()
    ConsoleWrite("Action_Delete" & @CRLF)
    If $_Action_filetype = "All" Then
        $_Action_Source_folder_files = _FileListToArray($_Action_folder, "*.*", 1)
        If $_Action_Source_folder_files <> 0 Then
            $Action_Time = @YEAR&@MON&@MDAY&":"&@HOUR&":"&@MIN&":"&@SEC
            IniWriteSection("Log.ini",$Action_Time&" Delete","")
            For $_Action_count1 = 1 To $_Action_Source_folder_files[0] Step +1
                FileDelete($_Action_folder & "\" & $_Action_Source_folder_files[$_Action_count1])
                IniWriteSection("Log.ini",$Action_Time, $_Action_folder & "\" & $_Action_Source_folder_files[$_Action_count1])
            Next
        EndIf
    Else
        $_Action_Source_folder_files = _FileListToArray($_Action_folder, "*" & $_Action_filetype, 1)
        If $_Action_Source_folder_files <> 0 Then
            $Action_Time = @YEAR&@MON&@MDAY&":"&@HOUR&":"&@MIN&":"&@SEC
            IniWriteSection("Log.ini",$Action_Time&" Delete","")
            For $_Action_count1 = 1 To $_Action_Source_folder_files[0] Step +1
                FileDelete($_Action_folder & "\" & $_Action_Source_folder_files[$_Action_count1])
                IniWriteSection("Log.ini",$Action_Time, $_Action_folder & "\" & $_Action_Source_folder_files[$_Action_count1])
            Next
        EndIf
    EndIf
    Return
EndFunc   ;==>_Action_Delete

@BrewManNH

I've read your post at regarding passing variables when using _Timer_SetTimer.

For that example to work for me now I would need a way to retrieve the name of the "function" that the timer was made for from inside the timer-called function.

Thanks in advance, and sorry if I'm messing things up with my "descriptions" :oops:

Edited by zvvyt
Link to comment
Share on other sites

What I've come down to now is I made a 2D array containing both the timerID and the corresponding name/number of the function in the ListView all to realise you can't pass arrays into functions with _Timer_SetTimer.

Someone's got a tip for a workaround?

 

The Adlib UDF by jennico works very well for me.

Could you perhaps give me some kind of example or hint of which functions to use for my problem? Would be much appreciated.

Else: Here's the script in its current whole.

;#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <EditConstants.au3>
#include <String.au3>
#include <Array.au3>
#include <Constants.au3>
#include <File.au3>
#include <ComboConstants.au3>
#include <Timers.au3>
#include "_Adlib.au3"

#NoTrayIcon

Opt("TrayMenuMode", 1 + 2)
Local $Tray_name = TrayCreateItem("E60 Folder checker")
TrayItemSetState(-1, $TRAY_DISABLE)
TrayCreateItem("")
Local $Tray_settings = TrayCreateItem("Settings")
TrayCreateItem("")
Local $Tray_exit = TrayCreateItem("Exit")
TraySetState(2)

Global $Input_name, $Main_window, $list, $Interval_input, $Interval_format, $Button_new, $Button_delete, $Button_edit, $Button_save, $Button_start, $Timer_delay, $Action_count, $_Action_filetype, $_Action_folder, $TimerID_Function_Name

Call("_Settings")
Func _Settings()
    $Main_window = GUICreate("E60 Folder checker - Settings", 400, 300, -1, -1)
    ;GUICtrlCreatePic("E60.jpg", 0, 0, 400, 300)
    ;GUICtrlSetState(-1, $gui_disable)
    $list = GUICtrlCreateListView("Name |Function |Folder(s) to check |Files |Interval |Date    ", 20, 100, 360, 150)
    $Button_new = GUICtrlCreateButton("New", 25, 260, 80, 30)
    $Button_delete = GUICtrlCreateButton("Delete", 115, 260, 80, 30)
    $Button_edit = GUICtrlCreateButton("Edit", 205, 260, 80, 30)
    $Button_save = GUICtrlCreateButton("Save", 295, 260, 80, 30)
    $Button_run = GUICtrlCreateButton("Run", 300, 60, 80, 30)
    ;$Checkbox_log = GUICtrlCreateCheckbox("Make log-file", 20,20,-1,-1)

    GUISetState(@SW_SHOW)
    #region Load-part
    If FileExists("Settings.ini") Then
        $Load_check_earlier_functions = IniReadSectionNames("Settings.ini")
        If @error Then
        Else
            For $Load_Count1 = 1 To $Load_check_earlier_functions[0] Step +1
                $Load_read_earlier_functions = IniReadSection("Settings.ini", $Load_check_earlier_functions[$Load_Count1])
                GUICtrlCreateListViewItem($Load_check_earlier_functions[$Load_Count1] & "|" & $Load_read_earlier_functions[1][1] & "|" & $Load_read_earlier_functions[2][1] & "|" & $Load_read_earlier_functions[3][1] & "|" & $Load_read_earlier_functions[4][1] & "|" & $Load_read_earlier_functions[5][1], $list)
            Next
        EndIf
    EndIf
    #endregion Load-part
    While 1
        if _GUICtrlListView_GetItemCount($list) = 0 And GUICtrlGetState($Button_run) = 80 Then GUICtrlSetState($Button_run, $gui_disable)
        if _GUICtrlListView_GetItemCount($list) <> 0 And GUICtrlGetState($Button_run) = 144 Then GUICtrlSetState($Button_run, $gui_enable)
        $Msg = GUIGetMsg()
        Switch $Msg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button_new
                ConsoleWrite("New-function initiated" & @CRLF)
                Call("_New")
                ConsoleWrite("New-function ended" & @CRLF)
            Case $Button_delete
                ConsoleWrite("Delete-function initiated" & @CRLF)
                Call("_Delete")
                ConsoleWrite("Delete-function ended" & @CRLF)
            Case $Button_edit
                Call("_Edit")
            Case $Button_save
                ConsoleWrite("Save-function initiated" & @CRLF)
                Call("_Save")
                ConsoleWrite("Save-function ended" & @CRLF)
            Case $Button_run
                ConsoleWrite("Run-function initiated" & @CRLF)
                GUISetState(@SW_HIDE, $Main_window)
                GUISetState(@SW_LOCK, $Main_window)
                TraySetState(1)
                Call("_Run")
                TraySetState(2)
                GUISetState(@SW_UNLOCK, $Main_window)
                GUISetState(@SW_SHOW, $Main_window)
                ConsoleWrite("Run-function ended" & @CRLF)
        EndSwitch
        If _GUICtrlListView_GetSelectedCount($list) = 0 And GUICtrlGetState($Button_delete) = 80 Then ;enabled
            GUICtrlSetState($Button_delete, $gui_disable)
            GUICtrlSetState($Button_edit, $gui_disable)
        EndIf
        If _GUICtrlListView_GetSelectedCount($list) > 0 And GUICtrlGetState($Button_delete) = 144 Then ;disabled
            GUICtrlSetState($Button_delete, $gui_enable)
            GUICtrlSetState($Button_edit, $gui_enable)
        EndIf
        $Interval_input_checker = StringSplit(GUICtrlRead($Interval_input), "0")
        If $Interval_input_checker[1] = "" And GUICtrlRead($Interval_input) <> "0" Then GUICtrlSetData($Interval_input, StringReplace(GUICtrlRead($Interval_input), "0", "", 1))
    WEnd
EndFunc   ;==>_Settings

#region "New" part
Func _New()
    #region Function selection part
    $Input_name = InputBox("Folder checker - New", "Enter a name for the new function" & @CRLF & "NOTE! Duplicate or blank names are not allowed", "", "", "", "", Default, Default, "", $Main_window)
    If @error = 1 Then
        ConsoleWrite("Cancel@Name check" & @CRLF)
        Return
    EndIf
    If @error <> 0 Then
        ConsoleWrite("ERROR:" & @error & "@Name check")
        Return
    EndIf
    If $Input_name = "" Then
        Do
            $Input_name = InputBox("Folder checker - New", "Enter a name for the new function" & @CRLF & "NOTE! Duplicate or blank names are not allowed", "", "", "", "", Default, Default, "", $Main_window)
            If @error = 1 Then
                ConsoleWrite("Cancel@Name check" & @CRLF)
                Return
            EndIf
            If @error <> 0 Then
                ConsoleWrite("ERROR:" & @error & "@Name check")
                Return
            EndIf
        Until $Input_name <> ""
    EndIf
    For $1 = 0 To _GUICtrlListView_GetItemCount($list) Step +1
        $Name_dublicate_check = _GUICtrlListView_GetItemText($list, $1, 0)
        If $Input_name = $Name_dublicate_check Then
            ConsoleWrite("Duplicate names!" & @CRLF)
            MsgBox(0, "Folder checker - Error", "Name already in use. Please select a new name")
            $Input_name = ""
            $Name_dublicate_check = ""
            Call("_New")
            Return
        EndIf
    Next
    ConsoleWrite("Passed namecheck" & @CRLF)
    $Select_function = GUICreate("Folder checker - Select a function", 200, 200, -1, -1, $WS_BORDER, "", $Main_window)
    $Select_function_func1 = GUICtrlCreateRadio("Copy files", 30, 20, 170, 30) ;-----------------------------------COPY
    GUICtrlSetTip(-1, "Click the ""?"" for more info")
    $Select_function_func2 = GUICtrlCreateRadio("Move files", 30, 50, 170, 30) ;-----------------------------------MOVE
    GUICtrlSetTip(-1, "Click the ""?"" for more info")
    $Select_function_func3 = GUICtrlCreateRadio("Delete files", 30, 80, 170, 30) ;---------------------------------DELETE
    GUICtrlSetTip(-1, "Click the ""?"" for more info")
    $Select_function_continue = GUICtrlCreateButton("Continue", 15, 140, 80, 30)
    GUICtrlSetState(-1, $gui_disable)
    Local $Select_function_continue_disabled = 1
    $Select_function_cancel = GUICtrlCreateButton("Cancel", 105, 140, 80, 30)
    GUISetState(@SW_SHOW)
    Local $Function_selected = ""
    Local $Destinating_folder
    While 1 ;----------------------------------------Select function
        ;if WinActive($Main_window) then WinActivate($Select_function)
        GUISetState(@SW_DISABLE, $Main_window)
        $Msg = GUIGetMsg()
        If $Select_function_continue_disabled = 1 And BitXOR(GUICtrlRead($Select_function_func1), GUICtrlRead($Select_function_func2), GUICtrlRead($Select_function_func3)) = $GUI_CHECKED Then
            GUICtrlSetState($Select_function_continue, $gui_enable)
            $Select_function_continue_disabled = 0
        EndIf
        Switch $Msg
            Case $Select_function_cancel
                ConsoleWrite("Cancel@Function selection" & @CRLF)
                GUISetState(@SW_ENABLE, $Main_window)
                GUIDelete($Select_function)
                WinActivate($Main_window)
                Return
            Case $Select_function_continue
                If BitAND(GUICtrlRead($Select_function_func1), $GUI_CHECKED) = $GUI_CHECKED Then
                    GUIDelete($Select_function)
                    $Function_selected = "Copy"
                    ;call("NewCopy")
                EndIf
                If BitAND(GUICtrlRead($Select_function_func2), $GUI_CHECKED) = $GUI_CHECKED Then
                    GUIDelete($Select_function)
                    $Function_selected = "Move"
                    ;call("NewMove")
                EndIf
                If BitAND(GUICtrlRead($Select_function_func3), $GUI_CHECKED) = $GUI_CHECKED Then
                    GUIDelete($Select_function)
                    $Function_selected = "Delete"
                    ;call("NewDelete")
                EndIf
                ;GUISetState(@SW_ENABLE,$Main_window)
                ExitLoop
        EndSwitch
    WEnd
    #endregion Function selection part
    #region Folder selection part
    ConsoleWrite($Function_selected)
    If $Function_selected = "Delete" Then
        $Origin_folder = FileSelectFolder("Select file folder", "", 1, "", $Main_window)
        If @error = 1 Then
            ConsoleWrite("Cancel@Folder selction" & @CRLF)
            GUISetState(@SW_ENABLE, $Main_window)
            Return
        EndIf
    Else
        $Origin_folder = FileSelectFolder("Select file origin folder", "", 1, "", $Main_window)
        If @error = 1 Then
            ConsoleWrite("Cancel@Origin folder selction" & @CRLF)
            GUISetState(@SW_ENABLE, $Main_window)
            Return
        EndIf
        $Destinating_folder = FileSelectFolder("Select destinating folder", "", 1, "", $Main_window)
        If @error = 1 Then
            ConsoleWrite("Cancel@Destinating folder selction" & @CRLF)
            GUISetState(@SW_ENABLE, $Main_window)
            Return
        EndIf
        If $Origin_folder = $Destinating_folder Then
            Do
                MsgBox(0, "Error", "Same folder specified. Please chose another folder to copy from/to")
                $Origin_folder = FileSelectFolder("Select file origin folder", "", 1, "", $Main_window)
                If @error = 1 Then
                    ConsoleWrite("Cancel@Origin folder selction" & @CRLF)
                    GUISetState(@SW_ENABLE, $Main_window)
                    Return
                EndIf
                $Destinating_folder = FileSelectFolder("Select destinating folder", "", 1, "", $Main_window)
                If @error = 1 Then
                    ConsoleWrite("Cancel@Destinating folder selction" & @CRLF)
                    GUISetState(@SW_ENABLE, $Main_window)
                    Return
                EndIf
            Until $Origin_folder <> $Destinating_folder
        EndIf
    EndIf
    #endregion Folder selection part
    #region File selection part

    $Select_files = GUICreate("Folder checker - Select files", 200, 200, -1, -1, $WS_BORDER, "", $Main_window)
    $All_files = GUICtrlCreateRadio("All files", 30, 30, 170, 30)
    $Specific_files = GUICtrlCreateRadio("Specific filetype", 30, 60, 170, 30)
    $Filetype_input = GUICtrlCreateInput("", 50, 100, 100, 20)
    $Select_files_continue = GUICtrlCreateButton("Continue", 15, 140, 80, 30)
    GUICtrlSetState(-1, $gui_disable)
    Local $Select_files_continue_disable = 1
    $Select_files_cancel = GUICtrlCreateButton("Cancel", 105, 140, 80, 30)
    GUICtrlSetState($Filetype_input, $gui_disable)
    GUISetState(@SW_SHOW)
    Local $Filetype_input_Dot_checker[4]
    While 1
        $Filetype_input_Space_checker = StringSplit(GUICtrlRead($Filetype_input), " ")
        If $Filetype_input_Space_checker[0] = 2 Then
            $Filetype_input_no_space = StringReplace(GUICtrlRead($Filetype_input), " ", "")
            GUICtrlSetData($Filetype_input, $Filetype_input_no_space)
        EndIf
        $Filetype_input_Dot_checker = StringSplit(GUICtrlRead($Filetype_input), ".")
        If $Filetype_input_Dot_checker[0] >= 2 Then
            If $Filetype_input_Dot_checker[1] <> "" Then
                GUICtrlSetData($Filetype_input, StringReplace(GUICtrlRead($Filetype_input), ".", "", 1))
            EndIf
            If $Filetype_input_Dot_checker[0] = 3 Then
                GUICtrlSetData($Filetype_input, _StringReverse(StringReplace(_StringReverse(GUICtrlRead($Filetype_input)), ".", "", 1)))
            EndIf
        EndIf
        GUISetState(@SW_DISABLE, $Main_window)
        If GUICtrlRead($Specific_files) = 1 And GUICtrlRead($Filetype_input) = "" And $Select_files_continue_disable = 0 Then
            GUICtrlSetState($Select_files_continue, $gui_disable)
            $Select_files_continue_disable = 1
        EndIf
        If GUICtrlRead($Specific_files) = 1 And GUICtrlRead($Filetype_input) = "." And $Select_files_continue_disable = 0 Then
            GUICtrlSetState($Select_files_continue, $gui_disable)
            $Select_files_continue_disable = 1
        EndIf
        If GUICtrlRead($All_files) = 1 And $Select_files_continue_disable = 1 Then
            GUICtrlSetState($Select_files_continue, $gui_enable)
            $Select_files_continue_disable = 0
        EndIf
        If GUICtrlRead($Specific_files) = 1 And GUICtrlRead($Filetype_input) <> "" And $Select_files_continue_disable = 1 And GUICtrlRead($Filetype_input) <> "." Then
            GUICtrlSetState($Select_files_continue, $gui_enable)
            $Select_files_continue_disable = 0
        EndIf
        $Msg = GUIGetMsg()
        Switch $Msg
            Case $Select_files_cancel
                GUISetState(@SW_ENABLE, $Main_window)
                ConsoleWrite("Cancel@File selection" & @CRLF)
                GUIDelete($Select_files)
                Return
            Case $Specific_files
                GUICtrlSetState($Filetype_input, $gui_enable)
            Case $All_files
                GUICtrlSetState($Filetype_input, $gui_disable)
            Case $Select_files_continue
                If GUICtrlRead($All_files) = $GUI_CHECKED Then $Filetype_input = "All"
                If GUICtrlRead($Specific_files) = $GUI_CHECKED And GUICtrlRead($Filetype_input) <> "" Then
                    $Filetype_input_Dot_checker = StringSplit(GUICtrlRead($Filetype_input), ".")
                    If $Filetype_input_Dot_checker[0] = 1 Then
                        GUICtrlSetData($Filetype_input, "." & GUICtrlRead($Filetype_input))
                    EndIf
                    $Filetype_input = StringLower(GUICtrlRead($Filetype_input))
                EndIf
            GUIDelete($Select_files)
            ExitLoop
        EndSwitch
    WEnd
    $Interval_window = GUICreate("Folder checker - Enter interval", 200,200,-1,-1, $WS_BORDER, "", $Main_window)
    $Interval_input = GUICtrlCreateInput("0", 85, 30, 40, 22, $ES_NUMBER)
    GUICtrlSetLimit(-1, 4, 1)
    $Interval_format = GUICtrlCreateCombo("s", 140, 30, 40, Default, $CBS_DROPDOWNLIST)
    GUICtrlSetData(-1, "min|h")
    $Interval_continue = GUICtrlCreateButton("Continue", 15, 140, 80, 30)
    GUICtrlSetState(-1, $gui_disable)
    $Interval_cancel = GUICtrlCreateButton("Cancel", 105, 140, 80, 30)
    GUISetState()
    while 1
        if GUICtrlRead($Interval_input) = "" And GUICtrlGetState($Interval_continue) = 80 Then GUICtrlSetState($Interval_continue, $gui_disable)
        if GUICtrlRead($Interval_input) <> "" And GUICtrlGetState($Interval_continue) = 144 Then GUICtrlSetState($Interval_continue, $gui_enable)
        $Msg = GUIGetMsg()
        Switch $Msg
            Case $Interval_cancel
                GUISetState(@SW_ENABLE, $Main_window)
                ConsoleWrite("Cancel@Interval" & @CRLF)
                GUIDelete($Interval_window)
                Return
            Case $Interval_continue
                $Interval_input = GUICtrlRead($Interval_input)
                $Interval_format = GUICtrlRead($Interval_format)
                GUIDelete($Interval_window)
                ExitLoop
        EndSwitch
    WEnd

    $Function_date_made_long = @YEAR & @MON & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC
    $Function_date_made = @MDAY & "/" & @MON & " " & @HOUR & ":" & @MIN

    If $Function_selected = "Delete" Then
        GUICtrlCreateListViewItem($Input_name & "|" & $Function_selected & "|" & $Origin_folder & "|" & $Filetype_input & "|" & $Interval_input & " " & $Interval_format & "|" & $Function_date_made_long, $list)
    Else
        GUICtrlCreateListViewItem($Input_name & "|" & $Function_selected & "|" & $Origin_folder & " to " & $Destinating_folder & "|" & $Filetype_input & "|" & $Interval_input & " " & $Interval_format & "|" & $Function_date_made_long, $list)
    EndIf
    ConsoleWrite("Filetype selected" & @CRLF)

    #endregion File setup part
    GUISetState(@SW_ENABLE, $Main_window)
    WinActivate($Main_window)
EndFunc   ;==>_New
#endregion "New" part

Func _Delete()
    _GUICtrlListView_DeleteItemsSelected($list)
EndFunc   ;==>_Delete
Func _Edit()

EndFunc   ;==>_Info
Func _Save()
    ;Credit goes to Melba23 of the AutoIt forum.
    GUICtrlSetState($Button_save, $gui_disable)
    $Save_check_earlier_functions = IniReadSectionNames("Settings.ini")
    If @error Then
        Local $Save_check_earlier_functions[1] = ["0"]
    EndIf
    $Save_check_current_functions = _GUICtrlListView_GetItemCount($list)
    ; Are there any saved functions to check?
    If $Save_check_earlier_functions[0] <> 0 Then
        ; Loop through the ini and check if sections are in the ListView
        For $Save_Count1 = 1 To $Save_check_earlier_functions[0]
            $iIndex = _GUICtrlListView_FindText($list, $Save_check_earlier_functions[$Save_Count1])
            ; If not found then delete
            If $iIndex = -1 Then
                IniDelete("Settings.ini", $Save_check_earlier_functions[$Save_Count1])
            EndIf
        Next
    EndIf
    ; Are there any items in the ListView?
    If $Save_check_current_functions > 0 Then
        ; Now loop through ListView and see if any functions need to be added
        For $Save_Count2 = 0 To $Save_check_current_functions - 1 ; Remember ListView items are 0-indexed
            $iIndex = _ArraySearch($Save_check_earlier_functions, _GUICtrlListView_GetItemText($list, $Save_Count2, 0))
            ; If not found then add
            If $iIndex = -1 Then
                IniWrite("Settings.ini", _GUICtrlListView_GetItemText($list, $Save_Count2, 0), "Function", _GUICtrlListView_GetItemText($list, $Save_Count2, 1))
                IniWrite("Settings.ini", _GUICtrlListView_GetItemText($list, $Save_Count2, 0), "Folder", _GUICtrlListView_GetItemText($list, $Save_Count2, 2))
                IniWrite("Settings.ini", _GUICtrlListView_GetItemText($list, $Save_Count2, 0), "File", _GUICtrlListView_GetItemText($list, $Save_Count2, 3))
                IniWrite("Settings.ini", _GUICtrlListView_GetItemText($list, $Save_Count2, 0), "Interval", _GUICtrlListView_GetItemText($list, $Save_Count2, 4))
                IniWrite("Settings.ini", _GUICtrlListView_GetItemText($list, $Save_Count2, 0), "Date", _GUICtrlListView_GetItemText($list, $Save_Count2, 5))
            EndIf
        Next
    EndIf
    GUICtrlSetState($Button_save, $gui_enable)
EndFunc   ;==>_Save





Func _Run()
    ;GUIRegisterMsg($WM_TIMER, "WM_TIMER")
    $Action_listview_count = _GUICtrlListView_GetItemCount($list)
    If $Action_listview_count >= 1 Then
        local $TimerID_Function_Name[$Action_listview_count][2]
        for $Run_Count = 0 to $Action_listview_count step +1
            $Interval_split = StringSplit(_GUICtrlListView_GetItemText($list, $Run_Count, 4), " ", 1)
            if $Interval_split[0] >= 2 Then
                ;if $Interval_split[2] = "ms" Then $Interval_time = $Interval_split[1] * 1
                if $Interval_split[2] = "s" Then $Interval_time = $Interval_split[1] * 1000
                if $Interval_split[2] = "min" Then $Interval_time = $Interval_split[1] * 60000
                if $Interval_split[2] = "h" Then $Interval_time = $Interval_split[1] * 3600000

                _AdlibEnable("_Action", $Interval_time, -1, $Run_Count)


                ;$TimerID_Function_Name[$Run_Count][0] = _Timer_SetTimer($Main_window, _GUICtrlListView_GetItemText($list, $Run_Count, 4))
                ;$TimerID_Function_Name[$Run_Count][1] = $Run_Count
            EndIf
        Next
    EndIf
    While 1
        Switch TrayGetMsg()
            Case $Tray_settings
                _AdlibDisable()
                ;_Timer_KillAllTimers($Main_window)
                ExitLoop
            Case $Tray_exit
                _AdlibDisable()
                ;_Timer_KillAllTimers($Main_window)
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>_Run

Func _Action($Timer_Function_Number)

        $_Action_folder = _GUICtrlListView_GetItemText($list, $Timer_Function_Number, 2)
        $_Action_filetype = _GUICtrlListView_GetItemText($list, $Timer_Function_Number, 3)
        If _GUICtrlListView_GetItemText($list, $Timer_Function_Number, 1) = "Copy" Then Call("_Action_Copy")
        If _GUICtrlListView_GetItemText($list, $Timer_Function_Number, 1) = "Move" Then Call("_Action_Move")
        If _GUICtrlListView_GetItemText($list, $Timer_Function_Number, 1) = "Delete" Then Call("_Action_Delete")
EndFunc




#cs
Func WM_TIMER($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $ilParam
    ConsoleWrite("Timer reached" & @CRLF)
    $_Action_function_number = _ArraySearch($TimerID_Function_Name, _Timer_GetTimerID($iwParam))
        $_Action_folder = _GUICtrlListView_GetItemText($list, $TimerID_Function_Name[$_Action_function_number][1], 2)
        $_Action_filetype = _GUICtrlListView_GetItemText($list, $TimerID_Function_Name[$_Action_function_number][1], 3)
        If _GUICtrlListView_GetItemText($list, $TimerID_Function_Name[$_Action_function_number][1], 1) = "Copy" Then Call("_Action_Copy")
        If _GUICtrlListView_GetItemText($list, $TimerID_Function_Name[$_Action_function_number][1], 1) = "Move" Then Call("_Action_Move")
        If _GUICtrlListView_GetItemText($list, $TimerID_Function_Name[$_Action_function_number][1], 1) = "Delete" Then Call("_Action_Delete")
EndFunc   ;==>WM_TIMER
#ce






Func _Action_Copy()
    ConsoleWrite("Action_Copy" & @CRLF)
    $_Action_folder_split = StringSplit($_Action_folder, " to ", 1)
    If $_Action_filetype = "All" Then
        $_Action_Source_folder_files = _FileListToArray($_Action_folder_split[1], "*.*", 1)
        If $_Action_Source_folder_files <> 0 Then
            $Action_Time = @YEAR&@MON&@MDAY&":"&@HOUR&":"&@MIN&":"&@SEC
            IniWriteSection("Log.ini",$Action_Time &" Copy","")
            If $_Action_Source_folder_files = 0 Then Return
            For $_Action_count1 = 1 To $_Action_Source_folder_files[0] Step +1
                If FileExists($_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1]) Then
                    If FileGetTime($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], 0, 1) > FileGetTime($_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 0, 1) Then
                        ; Copy and replace
                        FileCopy($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 1)
                        IniWriteSection("Log.ini",$Action_Time, $_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1] &" to "& $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1])
                    EndIf
                Else
                    FileCopy($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 1)
                    IniWriteSection("Log.ini",$Action_Time, $_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1] &" to "& $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1])
                EndIf
            Next
        EndIf
    Else
        $_Action_Source_folder_files = _FileListToArray($_Action_folder_split[1], "*" & $_Action_filetype, 1)
        If $_Action_Source_folder_files <> 0 Then
            $Action_Time = @YEAR&@MON&@MDAY&":"&@HOUR&":"&@MIN&":"&@SEC
            IniWriteSection("Log.ini",$Action_Time&" Copy","")
            For $_Action_count1 = 1 To $_Action_Source_folder_files[0] Step +1
                If FileExists($_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1]) Then
                    If FileGetTime($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], 0, 1) > FileGetTime($_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 0, 1) Then
                        ; Copy and replace
                        FileCopy($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 9)
                        IniWriteSection("Log.ini",$Action_Time, $_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1] &" to "& $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1])
                    EndIf
                Else
                    FileCopy($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 9)
                    IniWriteSection("Log.ini",$Action_Time, $_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1] &" to "& $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1])
                EndIf
            Next
        EndIf
    EndIf
    Return
EndFunc   ;==>_Action_Copy

Func _Action_Move()
    ConsoleWrite("Action_Move" & @CRLF)
    $_Action_folder_split = StringSplit($_Action_folder, " to ", 1)
    If $_Action_filetype = "All" Then
        $_Action_Source_folder_files = _FileListToArray($_Action_folder_split[1], "*.*", 1)
        If $_Action_Source_folder_files <> 0 Then
            $Action_Time = @YEAR&@MON&@MDAY&":"&@HOUR&":"&@MIN&":"&@SEC
            IniWriteSection("Log.ini",$Action_Time&" Move","")
            For $_Action_count1 = 1 To $_Action_Source_folder_files[0] Step +1
                If FileExists($_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1]) Then
                    If FileGetTime($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], 0, 1) >= FileGetTime($_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 0, 1) Then
                        FileMove($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 1)
                        IniWriteSection("Log.ini",$Action_Time, $_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1] &" to "& $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1])
                    EndIf
                Else
                    FileMove($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 1)
                    IniWriteSection("Log.ini",$Action_Time, $_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1] &" to "& $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1])
                EndIf
            Next
        EndIf
    Else
        $_Action_Source_folder_files = _FileListToArray($_Action_folder_split[1], "*" & $_Action_filetype, 1)
        If $_Action_Source_folder_files <> 0 Then
            $Action_Time = @YEAR&@MON&@MDAY&":"&@HOUR&":"&@MIN&":"&@SEC
            IniWriteSection("Log.ini",$Action_Time&" Move","")
            For $_Action_count1 = 1 To $_Action_Source_folder_files[0] Step +1
                If FileExists($_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1]) Then
                    If FileGetTime($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], 0, 1) >= FileGetTime($_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 0, 1) Then
                        FileMove($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 9)
                        IniWriteSection("Log.ini",$Action_Time, $_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1] &" to "& $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1])
                    EndIf
                Else
                    FileMove($_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1], $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1], 9)
                    IniWriteSection("Log.ini",$Action_Time, $_Action_folder_split[1] & "\" & $_Action_Source_folder_files[$_Action_count1] &" to "& $_Action_folder_split[2] & "\" & $_Action_Source_folder_files[$_Action_count1])
                EndIf
            Next
        EndIf
    EndIf
    Return
EndFunc   ;==>_Action_Move

Func _Action_Delete()
    ConsoleWrite("Action_Delete" & @CRLF)
    If $_Action_filetype = "All" Then
        $_Action_Source_folder_files = _FileListToArray($_Action_folder, "*.*", 1)
        If $_Action_Source_folder_files <> 0 Then
            $Action_Time = @YEAR&@MON&@MDAY&":"&@HOUR&":"&@MIN&":"&@SEC
            IniWriteSection("Log.ini",$Action_Time&" Delete","")
            For $_Action_count1 = 1 To $_Action_Source_folder_files[0] Step +1
                FileDelete($_Action_folder & "\" & $_Action_Source_folder_files[$_Action_count1])
                IniWriteSection("Log.ini",$Action_Time, $_Action_folder & "\" & $_Action_Source_folder_files[$_Action_count1])
            Next
        EndIf
    Else
        $_Action_Source_folder_files = _FileListToArray($_Action_folder, "*" & $_Action_filetype, 1)
        If $_Action_Source_folder_files <> 0 Then
            $Action_Time = @YEAR&@MON&@MDAY&":"&@HOUR&":"&@MIN&":"&@SEC
            IniWriteSection("Log.ini",$Action_Time&" Delete","")
            For $_Action_count1 = 1 To $_Action_Source_folder_files[0] Step +1
                FileDelete($_Action_folder & "\" & $_Action_Source_folder_files[$_Action_count1])
                IniWriteSection("Log.ini",$Action_Time, $_Action_folder & "\" & $_Action_Source_folder_files[$_Action_count1])
            Next
        EndIf
    EndIf
    Return
EndFunc   ;==>_Action_Delete

Thanks in advance!

EDIT: I read up on the Adlib-UDF and it wasn't so hard to grasp BUT I'm getting errors in the UDF. Variables undeclared etc.

The UDF is one from the post you gave me. ( title="">)

The UDF made by ResNullius ( title="">) didn't seem to have the ability to pass arrays into functions, so I'd rather have a go with Jennicos (if I can get it to work)

Edited by zvvyt
Link to comment
Share on other sites

Thanks for your support in this!

I tried to "fix" this one myself, but after i did all I could it still crashed in my face..

Here's the original UDF:

#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

#cs
    ;#=#INDEX#===================================================#
    ;#  Title .........: _Adlib.au3
    ;#  Description ...: Enhanced Adlib functionality, enables multiple adlib instances, function parameters, limited adlibs, and adlib pausing
    ;#  Date ..........: 8.11.08
    ;#  Version .......: 1.2 improved AdlibDisable, _AdlibResume, _AdlibAdd and __AdlibMain
    ;#                       _AdlibDisable will not break the "rythm" anymore
    ;#                       added _AdlibUpdate
    ;#                       added _AdlibSync
    ;#                       added _Sync parameter to _AdlibEnable
    ;#                       fixed bug when last instance disabled by count
    ;#                       fixed bug in _AdlibResume (resuming disabled)
    ;#                       generally improved synchronicity of instances
    ;#                       changed: one function can be called by different instances now.
    ;#  History .......: v1.1   7.11.08
    ;#                          some descriptions precizised
    ;#                          added forgotten AdlibDisable() in __AdlibKill
    ;#                          added count param to _AdlibPause
    ;#                   v1.0   6.11.08
    ;#  Author ........: jennico (jennicoattminusonlinedotde)
    ;#  Main Functions : _AdlibEnable ( "function" [, time [, count [, param]]] )
    ;#                   _AdlibDisable ( [$al_ID] )
    ;#                   _AdlibPause ( [$al_ID [, $count]] )
    ;#                   _AdlibResume ( [$al_ID] )
    ;#                   _AdlibUpdate ( $al_ID, time [, count [, param]] )
    ;#                   _AdlibSync ( $al_ID1, $al_ID2 )
    ;#                   _AdlibMainFreq ( )
    ;#                   _AdlibFreq ( $al_ID )
    ;#                   _AdlibFunc ( $al_ID )
    ;#                   _AdlibID ( $func )
    ;#                   _AdlibParams ( $al_ID )
    ;#                   _AdlibActive ( [$al_ID] )
    ;#  Subfunctions ..: __AdlibAdd ( $al_ID [, $time] )
    ;#                   __AdlibMain ( )
    ;#                   __AdlibKill ( )
    ;#                   __Euclid ( $a, $b )
    ;#===========================================================#
#ce

#include-once

#Region;--------------------------Global declarations

__AdlibKill()
Global $al_timer = TimerInit()

#EndRegion;--------------------------Global declarations
#region;--------------------------Main Functions
#region;--------_AdlibEnable

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibEnable ( "function" [, time [, count [, param [, sync ]]]] )
    ;#  Description....: Enables Multi Adlib functionality and starts a new adlib instance.
    ;#  Parameters.....: function = The name of the adlib function to call (without parentheses).
    ;#                   time [optional] = frequency how often in milliseconds (> 0) to call the function. Default is 250 ms.
    ;#                   count [optional] = how many times (> 0) the function shall be called ("time ticks"). Default is -1 (=continuous).
    ;#                   param [optional] = parameter or array of parameters to be passed to "function".
    ;#                   sync [optional] = Adlib-ID returned by a previously enabled instance.
    ;#  Return Value ..: Returns Adlib-ID to be used in the other functions.
    ;#                   Returns 0 if sync is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: When using _AdlibEnable, the built-in AdlibEnable and AdlibDisable MUST not be used at all at the same time. This would deactivate all instances immediately.
    ;#                   When using count, the adlib instance will be disabled after count ticks of time and the Adlib-ID will be invalid.
    ;#                   When using sync, the start of the instance will be synchronized with the next tick of the instance represented by the specified Adlib-ID (results in a delay).
    ;#                   To pass multiple parameters to function, pass a 1-based array. Element 0 is used internally and will be overwritten.
    ;#                   For an example on multiple params, refer to Function "Call" in help file.
    ;#                   To skip one parameter, use "" (blank string).
    ;#                   A hint : If param (function parameter) is declared globally it can be updated dynamically without using any of these functions.
    ;#                   Theoretical limit of Alib instances is 15,999,999.
    ;#                   Every 250 ms (or time ms) the specified "function" is called.
    ;#                   The adlib function should be kept simple as it is executed often and during this time the main script is paused.
    ;#                   Also, the time parameter should be used carefully to avoid CPU load.
    ;#                   To update a parameter, use _AdlibUpdate.
    ;#                   NEW : Two or more instances can call the same function now. So you can use one adlib function to be called from several instances with different parameters.
    ;#                   Important recommendation:
    ;#                   If possible, please use round (multiples of each others) time frequencies to avoid CPU load . The main calling frequency of multiple adlibs is their greatest common divisor.
    ;#                   E.g. for two adlib instances, better choose 100 and 50 (main=50) for time than 99 and 51 (main=3).
    ;#                   If you choose two primes instead, the main frequency will be 1 ms and your CPU will possibly be locked.
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibDisable, _AdlibPause, _AdlibResume, _AdlibUpdate, _AdlibSync
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibEnable($func, $time = 250, $count = -1, $param = "", $sync = 0)
    If $sync < 0 Or $sync > $al_func[0] Or $al_func[$sync] = "" And $sync <> 0 Then Return
    If $time <= 0 Then $time = 250
    If $count = 0 Then $count = -1
    $al_ID = $al_func[0] + 1
    ReDim $al_func[$al_ID + 1], $al_time[$al_ID + 1], $al_current[$al_ID + 1], _
            $al_next[$al_ID + 1], $al_param[$al_ID + 1], $al_count[$al_ID + 1]
    If IsArray($param) Then $param[0] = "CallArgArray" 
    $al_func[0] = $al_ID
    $al_func[$al_ID] = $func
    $al_count[$al_ID] = $count
    $al_param[$al_ID] = $param
    $al_current[$al_ID] = $time
    If $sync = 0 Then
        __AdlibAdd($al_ID, $time)
    Else
        $al_next[$al_ID] = $al_next[$sync]
        $al_update = 1
    EndIf
    Return $al_ID
EndFunc   ;==>_AdlibEnable

#EndRegion;--------_AdlibEnable
#region;--------_AdlibDisable

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibDisable ( [$al_ID] )
    ;#  Description....: Stops specified adlib instance or disables entire adlib functionality.
    ;#  Parameters.....: $al_ID [optional] = The Adlib-ID returned by a previous _AdlibEnable call.
    ;#                   If omitted or 0, all instances will be stopped and adlib functionality disabled.
    ;#  Return Value ..: Success: Returns 1
    ;#                   Special: Returns 2 if all processes killed (Success)
    ;#                   Failure: Returns 0 if Adlib-ID is not valid (<0, not defined or disabled before).
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: NOT the same as AdlibDisable, do not use it when you use (Multi) _Adlib !
    ;#                   Instead of the Adlib-ID, the function name can be passed as an argument, if the name is not valid, 0 will be the return value. Be careful when the function is used by more than one instance.
    ;#                   When passing the Adlib-ID, make sure that it is a number !
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibPause, _AdlibResume, _AdlibUpdate, _AdlibSync
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibDisable($al_ID = 0)
    If IsInt($al_ID) = 0 Then
        $al_ID = _AdlibID($al_ID)
        If $al_ID = 0 Then Return 0
    EndIf
    If $al_ID > $al_func[0] Or $al_ID < 0 Then Return 0
    If $al_ID = 0 Then
        __AdlibKill()
        Return 1
    EndIf
    $al_next[$al_ID] = 0
    $al_count[$al_ID] = 0
    $al_current[$al_ID] = 0
    $al_param[$al_ID] = ""
    $al_func[$al_ID] = ""
    $al_update = 1
    If __AdlibAdd($al_ID, 0) = 0 Then Return 2
    Return 1
EndFunc   ;==>_AdlibDisable

#EndRegion;--------_AdlibDisable
#region;--------_AdlibPause

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibPause ( [$al_ID [, $count]] )
    ;#  Description....: Pauses specified or all adlib instance(s).
    ;#  Parameters.....: $al_ID [optional] = The Adlib-ID returned by a previous _AdlibEnable call.
    ;#                   $count [optional] = how many times (> 0) the function shall be paused ("time ticks").
    ;#  Return Value ..: Success: Returns 1
    ;#                   Failure: Returns 0 if Adlib-ID is not valid (<0, not defined or disabled before).
    ;#  Author ........: jennico
    ;#  Date ..........: 7.11.08
    ;#  Remarks .......: If $al_ID omitted or 0, all instances will be paused.
    ;#                   Setting count, the function will be automatically resumed after the specified ticks of time. If you have enabled the function with count parameter before, it will not be automatically disabled anmymore (previous count gets lost).
    ;#                   Main frequency will not be updated on _AdlibPause.
    ;#                   Instead of the Adlib-ID, the function name can be passed as an argument. Be careful when the function is used by more than one instance.
    ;#                   _AdlibPause will preserve the call "rythm", while _AdlibDisable followed by _AdlibEnable starts a new rythm.
    ;#                   On the other hand, if you want to resume immediately, use _AdlibEnable.
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibResume, _AdlibActive, _AdlibUpdate, _AdlibSync
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibPause($al_ID = 0, $count = -1)
    If IsInt($al_ID) = 0 Then $al_ID = _AdlibID($al_ID)
    If $al_ID > $al_func[0] Or $al_ID < 0 Then Return 0
    If $al_ID = 0 Then
        Local $t = 0
        For $i = 1 To $al_func[0]
            If $al_func[$i] Then
                $al_current[$i] = 0
                $al_count[$i] = $count
                $t = 1
            EndIf
        Next
        Return $t
    EndIf
    If $al_func[$al_ID] = "" Then Return
    $al_current[$al_ID] = 0
    $al_count[$al_ID] = $count
    Return 1
EndFunc   ;==>_AdlibPause

#EndRegion;--------_AdlibPause
#region;--------_AdlibResume

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibResume ( [$al_ID] )
    ;#  Description....: Resumes specified or all (paused) adlib instance(s).
    ;#  Parameters.....: $al_ID [optional] = The Adlib-ID returned by a previous _AdlibEnable call.
    ;#  Return Value ..: Success: Returns 1
    ;#                   Failure: Returns 0 if Adlib-ID is not valid (<0, not defined or disabled before).
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: If $al_ID omitted or 0, all instances will be resumed.
    ;#                   Instead of the Adlib-ID, the function name can be passed as an argument. Be careful when the function is used by more than one instance.
    ;#                   The difference to _AdlibEnable is that the function will be resumed to the same rythm as before, while _AdlibEnable starts a new rythm.
    ;#                   On the other hand, if you want to resume immediately, use _AdlibEnable.
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibPause, _AdlibUpdate, _AdlibSync
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibResume($al_ID = 0)
    If IsInt($al_ID) = 0 Then $al_ID = _AdlibID($al_ID)
    If $al_ID > $al_func[0] Or $al_ID < 0 Then Return 0
    If $al_ID = 0 Then
        Local $t = 0
        For $i = 1 To $al_func[0]
            If $al_func[$i] Then
                $al_current[$i] = $al_time[$i]
                $t = 1
            EndIf
        Next
        Return $t
    EndIf
    If $al_func[$al_ID] = "" Then Return
    $al_current[$al_ID] = $al_time[$al_ID]
    Return 1
EndFunc   ;==>_AdlibResume

#EndRegion;--------_AdlibResume
#region;--------_AdlibUpdate

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibUpdate ( $al_ID, time [, count [, param]] )
    ;#  Description....: Updates parameters of specified adlib instance(s).
    ;#  Parameters.....: $al_ID = The Adlib-ID returned by a previous _AdlibEnable call.
    ;#                   time [optional] = new frequency in ms.
    ;#                   count [optional] = new new count in ticks.
    ;#                   param [optional] = new params to be passed to specified function.
    ;#  Return Value ..: Success: Returns 1
    ;#                   Failure: Returns 0 if Adlib-ID is not valid (<0, not defined or disabled before).
    ;#  Author ........: jennico
    ;#  Date ..........: 8.11.08
    ;#  Remarks .......: If $al_ID = 0, all instances will be updated.
    ;#                   To omit time or count, use "0" or "" (blank string)
    ;#                   Instead of the Adlib-ID, the function name can be passed as an argument. Be careful when the function is used by more than one instance.
    ;#                   The difference to _AdlibEnable is that the function will keep up its rythm, while _AdlibEnable starts a new rythm.
    ;#                   With _AdlibUpdate it is possible to change function params, even if they are not declared globally.
    ;#                   Paused instances will be resumed.
    ;#                   Please observe: the updating of a frequency will not be realized instantly, but right after the next call of ANY (not necessarily the specified) adlib function !
    ;#                   This is necessary in order to preserve the current rythm.
    ;#                   Thus you will possibly notice a delay on first new tick.
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibPause, _AdlibResume, _AdlibSync
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibUpdate($al_ID, $time = 0, $count = 0, $param = "")
    If IsInt($al_ID) = 0 Then $al_ID = _AdlibID($al_ID)
    If $al_ID > $al_func[0] Or $al_ID < 0 Then Return 0
    If $al_ID = 0 Then
        Local $t = 0
        For $al_ID = 1 To $al_func[0]
            If $al_func[$al_ID] Then
                If IsArray($param) Then $param[0] = "CallArgArray" 
                If $time > 0 Then
                    $al_current[$al_ID] = $time
                    $al_time[$al_ID] = $time
                EndIf
                If $count > 0 Then $al_count[$al_ID] = $count
                If $param Then $al_param[$al_ID] = $param
                $t = 1
            EndIf
        Next
        If $t = 0 Then Return
        If $time > 0 Then $al_update = $time
        Return 1
    EndIf
    If $al_func[$al_ID] = "" Then Return
    If IsArray($param) Then $param[0] = "CallArgArray" 
    If $time > 0 Then
        $al_current[$al_ID] = $time
        $al_time[$al_ID] = $time
        $al_update = 1
    EndIf
    If $count > 0 Then $al_count[$al_ID] = $count
    If $param Then $al_param[$al_ID] = $param
    Return 1
EndFunc   ;==>_AdlibUpdate

#EndRegion;--------_AdlibUpdate
#region;--------_AdlibSync

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibSync ( $al_ID1, $al_ID2 )
    ;#  Description....: Synchronizes two (or more) _Adlib instances.
    ;#  Parameters.....: $al_ID1 = The instance to be synchronized.
    ;#                   $al_ID1 = The instance to be synchronized with.
    ;#  Return Value ..: Success: Returns 1
    ;#                   Failure: Returns 0 if one of the Adlib-IDs is not valid (<0, not defined or disabled before).
    ;#  Author ........: jennico
    ;#  Date ..........: 8.11.08
    ;#  Remarks .......: If $al_ID1 = 0, all instances will be synchronized with $al_ID2.
    ;#                   Synchronizing means restarting two or more instances ($al_ID1) right at the next call event of $al_ID2 without breaking the rythm of $al_ID2.
    ;#                   Very useful e.g. for collision implementations.
    ;#                   Instead of the Adlib-IDs, the function names can be passed as arguments. Be careful when the function is used by more than one instance.
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibPause, _AdlibResume, _AdlibUpdate
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibSync($al_ID1, $al_ID2)
    If IsInt($al_ID1) = 0 Then $al_ID1 = _AdlibID($al_ID1)
    If IsInt($al_ID2) = 0 Then $al_ID2 = _AdlibID($al_ID2)
    If $al_ID1 > $al_func[0] Or $al_ID1 < 0 Or $al_ID2 > $al_func[0] _
            Or $al_ID2 < 0 Or $al_func[$al_ID2] = "" Then Return 0
    If $al_ID1 = 0 Then
        Local $t = 0
        For $al_ID = 1 To $al_func[0]
            If $al_func[$al_ID] And $al_ID <> $al_ID2 Then
                $al_next[$al_ID] = $al_next[$al_ID2]
                $t = 1
            EndIf
        Next
        Return $t
    EndIf
    If $al_func[$al_ID1] = "" Then Return
    $al_next[$al_ID1] = $al_next[$al_ID2]
    Return 1
EndFunc   ;==>_AdlibSync

#EndRegion;--------_AdlibSync
#region;--------_AdlibMainFreq

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibMainFreq ( )
    ;#  Description....: Returns the current main (overall) adlib frequency.
    ;#  Parameters.....: none [ $p only used internally ]
    ;#  Return Value ..: Success: the current main (overall) adlib frequency in ms. Minimum is 1.
    ;#                   Failure: Returns 0 if Multi adlib functionality is disabled.
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: Designed to observe and prevent CPU load. Highest possible load is on 1.
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibPause, _AdlibResume, _AdlibUpdate, _AdlibSync, _AdlibFreq, _AdlibFunc, _AdlibParams, _AdlibActive
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibMainFreq($p = 1)
    If $al_func[0] = 0 Then Return 0
    Local $t
    For $i = 1 To $al_func[0]
        If $al_func[$i] Then
            $t = $al_time[$i]
            For $al_ID = $i + 1 To $al_func[0]
                If $al_current[$al_ID] Then $t = __Euclid($t, $al_time[$al_ID])
            Next
            Return $t
        EndIf
    Next
    If $p = 1 Then __AdlibKill()
EndFunc   ;==>_AdlibMainFreq

#EndRegion;--------_AdlibMainFreq
#region;--------_AdlibFreq

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibFreq ( $al_ID )
    ;#  Description....: Returns the specified adlib frequency.
    ;#  Parameters.....: $al_ID = The Adlib-ID returned by a previous _AdlibEnable call.
    ;#  Return Value ..: Success: Returns the specified adlib frequency in ms.
    ;#                   Failure: Returns 0 if Adlib-ID is not valid (0, not defined or disabled before).
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: Instead of the Adlib-ID, the function name can be passed as an argument. Be careful when the function is used by more than one instance.
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibPause, _AdlibResume, _AdlibUpdate, _AdlibSync, _AdlibMainFreq, _AdlibFunc, _AdlibID, _AdlibParams, _AdlibActive
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibFreq($al_ID)
    If IsInt($al_ID) = 0 Then $al_ID = _AdlibID($al_ID)
    If $al_ID > $al_func[0] Then Return 0
    Return $al_time[$al_ID]
EndFunc   ;==>_AdlibFreq

#EndRegion;--------_AdlibFreq
#region;--------_AdlibFunc

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibFunc ( $al_ID )
    ;#  Description....: Returns the specified adlib function name.
    ;#  Parameters.....: $al_ID = The Adlib-ID returned by a previous _AdlibEnable call.
    ;#  Return Value ..: Success: Returns the specified adlib function name.
    ;#                   Failure: Returns "" (blank string) if Adlib-ID is not valid (not defined or disabled before).
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: If Sal_ID = 0 then the number of _Adlib instances (incl. disabled and paused) is returned.
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibPause, _AdlibResume, _AdlibUpdate, _AdlibSync, _AdlibMainFreq, _AdlibFreq, _AdlibID, _AdlibParams, _AdlibActive
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibFunc($al_ID)
    If $al_ID > $al_func[0] Then Return ""
    Return $al_func[$al_ID]
EndFunc   ;==>_AdlibFunc

#EndRegion;--------_AdlibFunc
#region;--------_AdlibID

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibID ( $func )
    ;#  Description....: Returns the Adlib-ID specified by passed function name.
    ;#  Parameters.....: $func = The function name registered in a previous _AdlibEnable call.
    ;#  Return Value ..: Success: Returns the Adlib-ID.
    ;#                   Failure: Returns 0 if specified function is not registered in previous _AdlibEnable call.
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: none
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibPause, _AdlibResume, _AdlibUpdate, _AdlibSync, _AdlibMainFreq, _AdlibFreq, _AdlibFunc, _AdlibParams, _AdlibActive
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibID($func)
    For $al_ID = 1 To $al_func[0]
        If $al_func[$al_ID] = $func Then Return $al_ID
    Next
EndFunc   ;==>_AdlibID

#EndRegion;--------_AdlibID
#region;--------_AdlibParams

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibParams ( $al_ID )
    ;#  Description....: Returns an array of parameters and stats of the specified Adlib-ID.
    ;#  Parameters.....: $al_ID = The Adlib-ID returned by a previous _AdlibEnable call.
    ;#  Return Value ..: Success: Returns a 0 based 6 element array.
    ;#                   Failure: Returns "" (blank string) if Adlib-ID is not valid (not defined or = 0).
    ;#  Author ........: jennico
    ;#  Date ..........: 5.11.08
    ;#  Remarks .......: The returned array contains:
    ;#                   Array[0] = (More or less) proper function name incl. parenthesis and parameters (if given and not an array).
    ;#                   Array[1] = current instance Status: 1 for active, 0 for disabled, 2 for paused.
    ;#                   Array[2] = the corresponding function name ("" (blank) if instance is disabled).
    ;#                   Array[3] = the corresponding frequency (0 if instance is disabled).
    ;#                   Array[4] = (> 0) amount of times the corresponding function has been called.
    ;#                              (< 0) If count was specified, element contains the remainig count (time ticks).
    ;#                              (= 0) Instance has been stopped.
    ;#                   Array[5] = corresponding function parameters (can be an array itself) ("" (blank) if instance is disabled).
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibPause, _AdlibResume, _AdlibUpdate, _AdlibSync, _AdlibMainFreq, _AdlibFreq, _AdlibFunc, _AdlibID, _AdlibActive
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibParams($al_ID)
    If $al_ID > $al_func[0] Or $al_ID = 0 Then Return ""
    Local $ret[6]
    $ret[1] = 1
    If $al_func[$al_ID] = "" Then $ret[1] = 0
    If $al_current[$al_ID] = 0 Then $ret[1] = 2
    $ret[2] = $al_func[$al_ID]
    $ret[3] = $al_time[$al_ID]
    $ret[4] = $al_count[$al_ID] * - 1
    If $ret[4] < 0 Then $ret[3] += 1
    If $al_func[$al_ID] = "" Then $ret[4] = 0
    $ret[5] = $al_param[$al_ID]
    $ret[0] = $ret[2] & "(" & $ret[3] & "," & $ret[4] & "," & $ret[5] & ")" 
    Return $ret
EndFunc   ;==>_AdlibParams

#EndRegion;--------_AdlibParams
#region;--------_AdlibActive

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibActive ( [$al_ID] )
    ;#  Description....: Checks if _Adlib instance is active / paused. Or: Retrieves all active _Adlib instances.
    ;#  Parameters.....: $al_ID [optional] = The Adlib-ID returned by a previous _AdlibEnable call.
    ;#  Return Value ..: Success: Returns 1 if instance is active, 0 if disabled, and 2 if paused.
    ;#                            If parameter omitted or = 0 : Returns a 0 based array containing all active _Adlib instances.
    ;#                   Failure: Returns -1 and sets @error to 1 if Adlib-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: If parameter omitted or = 0 :
    ;#                   Array[0] contains total numbers, elements 1 - Array[0] the active Adlib_IDs.
    ;#                   @extended contains the number of paused _Adlib instances. Paused instances are active, too.
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibPause, _AdlibResume, _AdlibUpdate, _AdlibSync, _AdlibMainFreq, _AdlibFreq, _AdlibFunc, _AdlibParams, _AdlibParams
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibActive($al_ID = 0)
    If $al_ID > $al_func[0] Then Return SetError(1, 0, -1)
    If $al_ID Then
        Local $ret = 0
        If $al_func[$al_ID] Then
            $ret = 1
            If $al_current[$al_ID] = 0 Then $ret = 2
        EndIf
        Return $ret
    EndIf
    Local $ret1 = "", $ret2 = 0
    For $al_ID = 1 To $al_func[0]
        If $al_func[$al_ID] Then
            $ret1 &= $al_ID & "*" 
            If $al_current[$al_ID] = 0 Then $ret2 += 1
        EndIf
    Next
    Return SetExtended($ret2, StringSplit(StringTrimRight($ret1, 1), "*"))
EndFunc   ;==>_AdlibActive

#EndRegion;--------_AdlibActive
#EndRegion;--------------------------Main Functions
#Region;--------------------------Internal Functions
#cs
    ;#=#Function#================================================#
    ;#  Name ..........: __AdlibAdd ( $al_ID, $time )
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: internal use only
    ;#  Example........: no
    ;#===========================================================#
#ce

Func __AdlibAdd($al_ID, $time)
    $al_time[$al_ID] = $time
    Local $t = _AdlibMainFreq($time)
    If $time = 0 Then Return $t
    $al_next[$al_ID] = TimerDiff($al_timer) + $time
    AdlibEnable("__AdlibMain", _AdlibMainFreq())
EndFunc   ;==>__AdlibAdd

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: __AdlibMain ( )
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: internal use only
    ;#  Example........: no
    ;#===========================================================#
#ce

Func __AdlibMain()
    If $al_update Then
        AdlibEnable("__AdlibMain", _AdlibMainFreq())
        $al_update = 0
    EndIf
    Local $t = TimerDiff($al_timer)
    For $al_ID = 1 To $al_func[0]
        If $t >= $al_next[$al_ID] And $al_func[$al_ID] Then
            If $al_current[$al_ID] Then
                If $al_param[$al_ID] Then
                    Call($al_func[$al_ID], $al_param[$al_ID])
                Else
                    Call($al_func[$al_ID])
                EndIf
                $al_count[$al_ID] -= 1
                If $al_count[$al_ID] = 0 Then _AdlibDisable($al_ID)
            ElseIf $al_count[$al_ID] > 0 Then
                $al_count[$al_ID] -= 1
                If $al_count[$al_ID] = 0 Then _AdlibResume($al_ID)
            EndIf
            $al_next[$al_ID] += $al_time[$al_ID]
        EndIf
    Next
EndFunc   ;==>__AdlibMain

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: __AdlibKill ( )
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: internal use only
    ;#  Example........: no
    ;#===========================================================#
#ce

Func __AdlibKill()
    AdlibDisable()
    Global $al_func[1] = [0], $al_time[1] = [0], $al_current[1] = [0], _
            $al_next[1] = [0], $al_param[1] = [0], $al_count[1] = [0], $al_update = 0
EndFunc   ;==>__AdlibKill

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: __Euclid ( $a, $b )
    ;#  Description....: Calculates the Greatest Common Divisor
    ;#  Parameters.....: $a = 1st Integer
    ;#                   $b = 2nd Integer
    ;#  Return Value ..: Returns GCD
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: internal use only
    ;#                   taken from _Primes.au3
    ;#  Example........: no
    ;#===========================================================#
#ce

Func __Euclid($a, $b)
    If $b = 0 Then Return $a
    Return __Euclid($b, Mod($a, $b))
EndFunc   ;==>__Euclid

#EndRegion;--------------------------Internal Functions

And here's the console output from the original UDF:

C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(89,41) : WARNING: $al_func: possibly used before declaration.
    If $sync < 0 Or $sync > $al_func[0] Or
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(92,29) : WARNING: $al_ID possibly not declared/created yet
    $al_ID = $al_func[0] + 1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(93,53) : WARNING: $al_time possibly not declared/created yet
    ReDim $al_func[$al_ID + 1], $al_time[$al_ID + 1],
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(93,78) : WARNING: $al_current possibly not declared/created yet
    ReDim $al_func[$al_ID + 1], $al_time[$al_ID + 1], $al_current[$al_ID + 1],
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(94,33) : WARNING: $al_next possibly not declared/created yet
            $al_next[$al_ID + 1],
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(94,56) : WARNING: $al_param possibly not declared/created yet
            $al_next[$al_ID + 1], $al_param[$al_ID + 1],
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(94,79) : WARNING: $al_count possibly not declared/created yet
            $al_next[$al_ID + 1], $al_param[$al_ID + 1], $al_count[$al_ID + 1]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(105,23) : WARNING: $al_update possibly not declared/created yet
        $al_update = 1
~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(93,53) : WARNING: $al_time: declared, but not used in func.
    ReDim $al_func[$al_ID + 1], $al_time[$al_ID + 1],
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(93,78) : WARNING: $al_current: declared, but not used in func.
    ReDim $al_func[$al_ID + 1], $al_time[$al_ID + 1], $al_current[$al_ID + 1],
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(94,56) : WARNING: $al_param: declared, but not used in func.
            $al_next[$al_ID + 1], $al_param[$al_ID + 1],
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(94,79) : WARNING: $al_count: declared, but not used in func.
            $al_next[$al_ID + 1], $al_param[$al_ID + 1], $al_count[$al_ID + 1]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(105,23) : WARNING: $al_update: declared, but not used in func.
        $al_update = 1
~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(142,25) : WARNING: $al_next possibly not declared/created yet
    $al_next[$al_ID] = 0
~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(143,26) : WARNING: $al_count possibly not declared/created yet
    $al_count[$al_ID] = 0
~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(144,28) : WARNING: $al_current possibly not declared/created yet
    $al_current[$al_ID] = 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(145,27) : WARNING: $al_param possibly not declared/created yet
    $al_param[$al_ID] = ""
~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(147,19) : WARNING: $al_update possibly not declared/created yet
    $al_update = 1
~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(142,25) : WARNING: $al_next: declared, but not used in func.
    $al_next[$al_ID] = 0
~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(143,26) : WARNING: $al_count: declared, but not used in func.
    $al_count[$al_ID] = 0
~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(144,28) : WARNING: $al_current: declared, but not used in func.
    $al_current[$al_ID] = 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(145,27) : WARNING: $al_param: declared, but not used in func.
    $al_param[$al_ID] = ""
~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(147,19) : WARNING: $al_update: declared, but not used in func.
    $al_update = 1
~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(183,36) : WARNING: $al_current possibly not declared/created yet
                $al_current[$i] = 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(184,39) : WARNING: $al_count possibly not declared/created yet
                $al_count[$i] = $count
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(183,36) : WARNING: $al_current: declared, but not used in func.
                $al_current[$i] = 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(184,39) : WARNING: $al_count: declared, but not used in func.
                $al_count[$i] = $count
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(224,47) : WARNING: $al_time: possibly used before declaration.
                $al_current[$i] = $al_time[$i]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(224,47) : WARNING: $al_current possibly not declared/created yet
                $al_current[$i] = $al_time[$i]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(224,47) : WARNING: $al_current: declared, but not used in func.
                $al_current[$i] = $al_time[$i]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(273,48) : WARNING: $al_current possibly not declared/created yet
                    $al_current[$al_ID] = $time
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(276,62) : WARNING: $al_count possibly not declared/created yet
                If $count > 0 Then $al_count[$al_ID] = $count
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(277,58) : WARNING: $al_param possibly not declared/created yet
                If $param Then $al_param[$al_ID] = $param
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(282,45) : WARNING: $al_update possibly not declared/created yet
        If $time > 0 Then $al_update = $time
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(273,48) : WARNING: $al_current: declared, but not used in func.
                    $al_current[$al_ID] = $time
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(276,62) : WARNING: $al_count: declared, but not used in func.
                If $count > 0 Then $al_count[$al_ID] = $count
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(277,58) : WARNING: $al_param: declared, but not used in func.
                If $param Then $al_param[$al_ID] = $param
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(282,45) : WARNING: $al_update: declared, but not used in func.
        If $time > 0 Then $al_update = $time
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(328,53) : WARNING: $al_next: possibly used before declaration.
                $al_next[$al_ID] = $al_next[$al_ID2]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(364,40) : WARNING: $al_current: possibly used before declaration.
                If $al_current[$al_ID] Then
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(477,33) : WARNING: $al_count: possibly used before declaration.
    $ret[4] = $al_count[$al_ID] *
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(480,32) : WARNING: $al_param: possibly used before declaration.
    $ret[5] = $al_param[$al_ID]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(558,19) : WARNING: $al_update: possibly used before declaration.
    If $al_update Then
~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(595,86) : WARNING: $al_update already declared/assigned
            $al_next[1] = [0], $al_param[1] = [0], $al_count[1] = [0], $al_update = 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(544,48) : ERROR: AdlibEnable(): undefined function.
    AdlibEnable("__AdlibMain", _AdlibMainFreq())
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3(593,18) : ERROR: AdlibDisable(): undefined function.
    AdlibDisable()
~~~~~~~~~~~~~~~~~^

My "fix" ended up looking like this (with no errors when syntax checked):

#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

#cs
    ;#=#INDEX#===================================================#
    ;#  Title .........: _Adlib.au3
    ;#  Description ...: Enhanced Adlib functionality, enables multiple adlib instances, function parameters, limited adlibs, and adlib pausing
    ;#  Date ..........: 8.11.08
    ;#  Version .......: 1.2 improved AdlibDisable, _AdlibResume, _AdlibAdd and __AdlibMain
    ;#                       _AdlibDisable will not break the "rythm" anymore
    ;#                       added _AdlibUpdate
    ;#                       added _AdlibSync
    ;#                       added _Sync parameter to _AdlibEnable
    ;#                       fixed bug when last instance disabled by count
    ;#                       fixed bug in _AdlibResume (resuming disabled)
    ;#                       generally improved synchronicity of instances
    ;#                       changed: one function can be called by different instances now.
    ;#  History .......: v1.1   7.11.08
    ;#                          some descriptions precizised
    ;#                          added forgotten AdlibDisable() in __AdlibKill
    ;#                          added count param to _AdlibPause
    ;#                   v1.0   6.11.08
    ;#  Author ........: jennico (jennicoattminusonlinedotde)
    ;#  Main Functions : _AdlibEnable ( "function" [, time [, count [, param]]] )
    ;#                   _AdlibDisable ( [$al_ID] )
    ;#                   _AdlibPause ( [$al_ID [, $count]] )
    ;#                   _AdlibResume ( [$al_ID] )
    ;#                   _AdlibUpdate ( $al_ID, time [, count [, param]] )
    ;#                   _AdlibSync ( $al_ID1, $al_ID2 )
    ;#                   _AdlibMainFreq ( )
    ;#                   _AdlibFreq ( $al_ID )
    ;#                   _AdlibFunc ( $al_ID )
    ;#                   _AdlibID ( $func )
    ;#                   _AdlibParams ( $al_ID )
    ;#                   _AdlibActive ( [$al_ID] )
    ;#  Subfunctions ..: __AdlibAdd ( $al_ID [, $time] )
    ;#                   __AdlibMain ( )
    ;#                   __AdlibKill ( )
    ;#                   __Euclid ( $a, $b )
    ;#===========================================================#
#ce

#include-once

#Region;--------------------------Global declarations

__AdlibKill()
Global $al_timer = TimerInit()
    Global $al_func[0], $al_time[0], $al_current[0], _
            $al_next[0], $al_param[0], $al_count[0], $al_update = 0, $al_ID

#EndRegion;--------------------------Global declarations
#region;--------------------------Main Functions
#region;--------_AdlibEnable

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibEnable ( "function" [, time [, count [, param [, sync ]]]] )
    ;#  Description....: Enables Multi Adlib functionality and starts a new adlib instance.
    ;#  Parameters.....: function = The name of the adlib function to call (without parentheses).
    ;#                   time [optional] = frequency how often in milliseconds (> 0) to call the function. Default is 250 ms.
    ;#                   count [optional] = how many times (> 0) the function shall be called ("time ticks"). Default is -1 (=continuous).
    ;#                   param [optional] = parameter or array of parameters to be passed to "function".
    ;#                   sync [optional] = Adlib-ID returned by a previously enabled instance.
    ;#  Return Value ..: Returns Adlib-ID to be used in the other functions.
    ;#                   Returns 0 if sync is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: When using _AdlibEnable, the built-in AdlibEnable and AdlibDisable MUST not be used at all at the same time. This would deactivate all instances immediately.
    ;#                   When using count, the adlib instance will be disabled after count ticks of time and the Adlib-ID will be invalid.
    ;#                   When using sync, the start of the instance will be synchronized with the next tick of the instance represented by the specified Adlib-ID (results in a delay).
    ;#                   To pass multiple parameters to function, pass a 1-based array. Element 0 is used internally and will be overwritten.
    ;#                   For an example on multiple params, refer to Function "Call" in help file.
    ;#                   To skip one parameter, use "" (blank string).
    ;#                   A hint : If param (function parameter) is declared globally it can be updated dynamically without using any of these functions.
    ;#                   Theoretical limit of Alib instances is 15,999,999.
    ;#                   Every 250 ms (or time ms) the specified "function" is called.
    ;#                   The adlib function should be kept simple as it is executed often and during this time the main script is paused.
    ;#                   Also, the time parameter should be used carefully to avoid CPU load.
    ;#                   To update a parameter, use _AdlibUpdate.
    ;#                   NEW : Two or more instances can call the same function now. So you can use one adlib function to be called from several instances with different parameters.
    ;#                   Important recommendation:
    ;#                   If possible, please use round (multiples of each others) time frequencies to avoid CPU load . The main calling frequency of multiple adlibs is their greatest common divisor.
    ;#                   E.g. for two adlib instances, better choose 100 and 50 (main=50) for time than 99 and 51 (main=3).
    ;#                   If you choose two primes instead, the main frequency will be 1 ms and your CPU will possibly be locked.
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibDisable, _AdlibPause, _AdlibResume, _AdlibUpdate, _AdlibSync
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibEnable($func, $time = 250, $count = -1, $param = "", $sync = 0)
    If $sync < 0 Or $sync > $al_func[0] Or $al_func[$sync] = "" And $sync <> 0 Then Return
    If $time <= 0 Then $time = 250
    If $count = 0 Then $count = -1
    $al_ID = $al_func[0] + 1
    ReDim $al_func[$al_ID + 1], $al_time[$al_ID + 1], $al_current[$al_ID + 1], _
            $al_next[$al_ID + 1], $al_param[$al_ID + 1], $al_count[$al_ID + 1]
    If IsArray($param) Then $param[0] = "CallArgArray"
    $al_func[0] = $al_ID
    $al_func[$al_ID] = $func
    $al_count[$al_ID] = $count
    $al_param[$al_ID] = $param
    $al_current[$al_ID] = $time
    If $sync = 0 Then
        __AdlibAdd($al_ID, $time)
    Else
        $al_next[$al_ID] = $al_next[$sync]
        $al_update = 1
    EndIf
    Return $al_ID
EndFunc   ;==>_AdlibEnable

#EndRegion;--------_AdlibEnable
#region;--------_AdlibDisable

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibDisable ( [$al_ID] )
    ;#  Description....: Stops specified adlib instance or disables entire adlib functionality.
    ;#  Parameters.....: $al_ID [optional] = The Adlib-ID returned by a previous _AdlibEnable call.
    ;#                   If omitted or 0, all instances will be stopped and adlib functionality disabled.
    ;#  Return Value ..: Success: Returns 1
    ;#                   Special: Returns 2 if all processes killed (Success)
    ;#                   Failure: Returns 0 if Adlib-ID is not valid (<0, not defined or disabled before).
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: NOT the same as AdlibDisable, do not use it when you use (Multi) _Adlib !
    ;#                   Instead of the Adlib-ID, the function name can be passed as an argument, if the name is not valid, 0 will be the return value. Be careful when the function is used by more than one instance.
    ;#                   When passing the Adlib-ID, make sure that it is a number !
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibPause, _AdlibResume, _AdlibUpdate, _AdlibSync
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibDisable($al_ID = 0)
    If IsInt($al_ID) = 0 Then
        $al_ID = _AdlibID($al_ID)
        If $al_ID = 0 Then Return 0
    EndIf
    If $al_ID > $al_func[0] Or $al_ID < 0 Then Return 0
    If $al_ID = 0 Then
        __AdlibKill()
        Return 1
    EndIf
    $al_next[$al_ID] = 0
    $al_count[$al_ID] = 0
    $al_current[$al_ID] = 0
    $al_param[$al_ID] = ""
    $al_func[$al_ID] = ""
    $al_update = 1
    If __AdlibAdd($al_ID, 0) = 0 Then Return 2
    Return 1
EndFunc   ;==>_AdlibDisable

#EndRegion;--------_AdlibDisable
#region;--------_AdlibPause

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibPause ( [$al_ID [, $count]] )
    ;#  Description....: Pauses specified or all adlib instance(s).
    ;#  Parameters.....: $al_ID [optional] = The Adlib-ID returned by a previous _AdlibEnable call.
    ;#                   $count [optional] = how many times (> 0) the function shall be paused ("time ticks").
    ;#  Return Value ..: Success: Returns 1
    ;#                   Failure: Returns 0 if Adlib-ID is not valid (<0, not defined or disabled before).
    ;#  Author ........: jennico
    ;#  Date ..........: 7.11.08
    ;#  Remarks .......: If $al_ID omitted or 0, all instances will be paused.
    ;#                   Setting count, the function will be automatically resumed after the specified ticks of time. If you have enabled the function with count parameter before, it will not be automatically disabled anmymore (previous count gets lost).
    ;#                   Main frequency will not be updated on _AdlibPause.
    ;#                   Instead of the Adlib-ID, the function name can be passed as an argument. Be careful when the function is used by more than one instance.
    ;#                   _AdlibPause will preserve the call "rythm", while _AdlibDisable followed by _AdlibEnable starts a new rythm.
    ;#                   On the other hand, if you want to resume immediately, use _AdlibEnable.
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibResume, _AdlibActive, _AdlibUpdate, _AdlibSync
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibPause($al_ID = 0, $count = -1)
    If IsInt($al_ID) = 0 Then $al_ID = _AdlibID($al_ID)
    If $al_ID > $al_func[0] Or $al_ID < 0 Then Return 0
    If $al_ID = 0 Then
        Local $t = 0
        For $i = 1 To $al_func[0]
            If $al_func[$i] Then
                $al_current[$i] = 0
                $al_count[$i] = $count
                $t = 1
            EndIf
        Next
        Return $t
    EndIf
    If $al_func[$al_ID] = "" Then Return
    $al_current[$al_ID] = 0
    $al_count[$al_ID] = $count
    Return 1
EndFunc   ;==>_AdlibPause

#EndRegion;--------_AdlibPause
#region;--------_AdlibResume

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibResume ( [$al_ID] )
    ;#  Description....: Resumes specified or all (paused) adlib instance(s).
    ;#  Parameters.....: $al_ID [optional] = The Adlib-ID returned by a previous _AdlibEnable call.
    ;#  Return Value ..: Success: Returns 1
    ;#                   Failure: Returns 0 if Adlib-ID is not valid (<0, not defined or disabled before).
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: If $al_ID omitted or 0, all instances will be resumed.
    ;#                   Instead of the Adlib-ID, the function name can be passed as an argument. Be careful when the function is used by more than one instance.
    ;#                   The difference to _AdlibEnable is that the function will be resumed to the same rythm as before, while _AdlibEnable starts a new rythm.
    ;#                   On the other hand, if you want to resume immediately, use _AdlibEnable.
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibPause, _AdlibUpdate, _AdlibSync
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibResume($al_ID = 0)
    If IsInt($al_ID) = 0 Then $al_ID = _AdlibID($al_ID)
    If $al_ID > $al_func[0] Or $al_ID < 0 Then Return 0
    If $al_ID = 0 Then
        Local $t = 0
        For $i = 1 To $al_func[0]
            If $al_func[$i] Then
                $al_current[$i] = $al_time[$i]
                $t = 1
            EndIf
        Next
        Return $t
    EndIf
    If $al_func[$al_ID] = "" Then Return
    $al_current[$al_ID] = $al_time[$al_ID]
    Return 1
EndFunc   ;==>_AdlibResume

#EndRegion;--------_AdlibResume
#region;--------_AdlibUpdate

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibUpdate ( $al_ID, time [, count [, param]] )
    ;#  Description....: Updates parameters of specified adlib instance(s).
    ;#  Parameters.....: $al_ID = The Adlib-ID returned by a previous _AdlibEnable call.
    ;#                   time [optional] = new frequency in ms.
    ;#                   count [optional] = new new count in ticks.
    ;#                   param [optional] = new params to be passed to specified function.
    ;#  Return Value ..: Success: Returns 1
    ;#                   Failure: Returns 0 if Adlib-ID is not valid (<0, not defined or disabled before).
    ;#  Author ........: jennico
    ;#  Date ..........: 8.11.08
    ;#  Remarks .......: If $al_ID = 0, all instances will be updated.
    ;#                   To omit time or count, use "0" or "" (blank string)
    ;#                   Instead of the Adlib-ID, the function name can be passed as an argument. Be careful when the function is used by more than one instance.
    ;#                   The difference to _AdlibEnable is that the function will keep up its rythm, while _AdlibEnable starts a new rythm.
    ;#                   With _AdlibUpdate it is possible to change function params, even if they are not declared globally.
    ;#                   Paused instances will be resumed.
    ;#                   Please observe: the updating of a frequency will not be realized instantly, but right after the next call of ANY (not necessarily the specified) adlib function !
    ;#                   This is necessary in order to preserve the current rythm.
    ;#                   Thus you will possibly notice a delay on first new tick.
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibPause, _AdlibResume, _AdlibSync
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibUpdate($al_ID, $time = 0, $count = 0, $param = "")
    If IsInt($al_ID) = 0 Then $al_ID = _AdlibID($al_ID)
    If $al_ID > $al_func[0] Or $al_ID < 0 Then Return 0
    If $al_ID = 0 Then
        Local $t = 0
        For $al_ID = 1 To $al_func[0]
            If $al_func[$al_ID] Then
                If IsArray($param) Then $param[0] = "CallArgArray"
                If $time > 0 Then
                    $al_current[$al_ID] = $time
                    $al_time[$al_ID] = $time
                EndIf
                If $count > 0 Then $al_count[$al_ID] = $count
                If $param Then $al_param[$al_ID] = $param
                $t = 1
            EndIf
        Next
        If $t = 0 Then Return
        If $time > 0 Then $al_update = $time
        Return 1
    EndIf
    If $al_func[$al_ID] = "" Then Return
    If IsArray($param) Then $param[0] = "CallArgArray"
    If $time > 0 Then
        $al_current[$al_ID] = $time
        $al_time[$al_ID] = $time
        $al_update = 1
    EndIf
    If $count > 0 Then $al_count[$al_ID] = $count
    If $param Then $al_param[$al_ID] = $param
    Return 1
EndFunc   ;==>_AdlibUpdate

#EndRegion;--------_AdlibUpdate
#region;--------_AdlibSync

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibSync ( $al_ID1, $al_ID2 )
    ;#  Description....: Synchronizes two (or more) _Adlib instances.
    ;#  Parameters.....: $al_ID1 = The instance to be synchronized.
    ;#                   $al_ID1 = The instance to be synchronized with.
    ;#  Return Value ..: Success: Returns 1
    ;#                   Failure: Returns 0 if one of the Adlib-IDs is not valid (<0, not defined or disabled before).
    ;#  Author ........: jennico
    ;#  Date ..........: 8.11.08
    ;#  Remarks .......: If $al_ID1 = 0, all instances will be synchronized with $al_ID2.
    ;#                   Synchronizing means restarting two or more instances ($al_ID1) right at the next call event of $al_ID2 without breaking the rythm of $al_ID2.
    ;#                   Very useful e.g. for collision implementations.
    ;#                   Instead of the Adlib-IDs, the function names can be passed as arguments. Be careful when the function is used by more than one instance.
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibPause, _AdlibResume, _AdlibUpdate
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibSync($al_ID1, $al_ID2)
    If IsInt($al_ID1) = 0 Then $al_ID1 = _AdlibID($al_ID1)
    If IsInt($al_ID2) = 0 Then $al_ID2 = _AdlibID($al_ID2)
    If $al_ID1 > $al_func[0] Or $al_ID1 < 0 Or $al_ID2 > $al_func[0] _
            Or $al_ID2 < 0 Or $al_func[$al_ID2] = "" Then Return 0
    If $al_ID1 = 0 Then
        Local $t = 0
        For $al_ID = 1 To $al_func[0]
            If $al_func[$al_ID] And $al_ID <> $al_ID2 Then
                $al_next[$al_ID] = $al_next[$al_ID2]
                $t = 1
            EndIf
        Next
        Return $t
    EndIf
    If $al_func[$al_ID1] = "" Then Return
    $al_next[$al_ID1] = $al_next[$al_ID2]
    Return 1
EndFunc   ;==>_AdlibSync

#EndRegion;--------_AdlibSync
#region;--------_AdlibMainFreq

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibMainFreq ( )
    ;#  Description....: Returns the current main (overall) adlib frequency.
    ;#  Parameters.....: none [ $p only used internally ]
    ;#  Return Value ..: Success: the current main (overall) adlib frequency in ms. Minimum is 1.
    ;#                   Failure: Returns 0 if Multi adlib functionality is disabled.
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: Designed to observe and prevent CPU load. Highest possible load is on 1.
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibPause, _AdlibResume, _AdlibUpdate, _AdlibSync, _AdlibFreq, _AdlibFunc, _AdlibParams, _AdlibActive
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibMainFreq($p = 1)
    If $al_func[0] = 0 Then Return 0
    Local $t
    For $i = 1 To $al_func[0]
        If $al_func[$i] Then
            $t = $al_time[$i]
            For $al_ID = $i + 1 To $al_func[0]
                If $al_current[$al_ID] Then $t = __Euclid($t, $al_time[$al_ID])
            Next
            Return $t
        EndIf
    Next
    If $p = 1 Then __AdlibKill()
EndFunc   ;==>_AdlibMainFreq

#EndRegion;--------_AdlibMainFreq
#region;--------_AdlibFreq

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibFreq ( $al_ID )
    ;#  Description....: Returns the specified adlib frequency.
    ;#  Parameters.....: $al_ID = The Adlib-ID returned by a previous _AdlibEnable call.
    ;#  Return Value ..: Success: Returns the specified adlib frequency in ms.
    ;#                   Failure: Returns 0 if Adlib-ID is not valid (0, not defined or disabled before).
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: Instead of the Adlib-ID, the function name can be passed as an argument. Be careful when the function is used by more than one instance.
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibPause, _AdlibResume, _AdlibUpdate, _AdlibSync, _AdlibMainFreq, _AdlibFunc, _AdlibID, _AdlibParams, _AdlibActive
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibFreq($al_ID)
    If IsInt($al_ID) = 0 Then $al_ID = _AdlibID($al_ID)
    If $al_ID > $al_func[0] Then Return 0
    Return $al_time[$al_ID]
EndFunc   ;==>_AdlibFreq

#EndRegion;--------_AdlibFreq
#region;--------_AdlibFunc

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibFunc ( $al_ID )
    ;#  Description....: Returns the specified adlib function name.
    ;#  Parameters.....: $al_ID = The Adlib-ID returned by a previous _AdlibEnable call.
    ;#  Return Value ..: Success: Returns the specified adlib function name.
    ;#                   Failure: Returns "" (blank string) if Adlib-ID is not valid (not defined or disabled before).
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: If Sal_ID = 0 then the number of _Adlib instances (incl. disabled and paused) is returned.
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibPause, _AdlibResume, _AdlibUpdate, _AdlibSync, _AdlibMainFreq, _AdlibFreq, _AdlibID, _AdlibParams, _AdlibActive
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibFunc($al_ID)
    If $al_ID > $al_func[0] Then Return ""
    Return $al_func[$al_ID]
EndFunc   ;==>_AdlibFunc

#EndRegion;--------_AdlibFunc
#region;--------_AdlibID

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibID ( $func )
    ;#  Description....: Returns the Adlib-ID specified by passed function name.
    ;#  Parameters.....: $func = The function name registered in a previous _AdlibEnable call.
    ;#  Return Value ..: Success: Returns the Adlib-ID.
    ;#                   Failure: Returns 0 if specified function is not registered in previous _AdlibEnable call.
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: none
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibPause, _AdlibResume, _AdlibUpdate, _AdlibSync, _AdlibMainFreq, _AdlibFreq, _AdlibFunc, _AdlibParams, _AdlibActive
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibID($func)
    For $al_ID = 1 To $al_func[0]
        If $al_func[$al_ID] = $func Then Return $al_ID
    Next
EndFunc   ;==>_AdlibID

#EndRegion;--------_AdlibID
#region;--------_AdlibParams

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibParams ( $al_ID )
    ;#  Description....: Returns an array of parameters and stats of the specified Adlib-ID.
    ;#  Parameters.....: $al_ID = The Adlib-ID returned by a previous _AdlibEnable call.
    ;#  Return Value ..: Success: Returns a 0 based 6 element array.
    ;#                   Failure: Returns "" (blank string) if Adlib-ID is not valid (not defined or = 0).
    ;#  Author ........: jennico
    ;#  Date ..........: 5.11.08
    ;#  Remarks .......: The returned array contains:
    ;#                   Array[0] = (More or less) proper function name incl. parenthesis and parameters (if given and not an array).
    ;#                   Array[1] = current instance Status: 1 for active, 0 for disabled, 2 for paused.
    ;#                   Array[2] = the corresponding function name ("" (blank) if instance is disabled).
    ;#                   Array[3] = the corresponding frequency (0 if instance is disabled).
    ;#                   Array[4] = (> 0) amount of times the corresponding function has been called.
    ;#                              (< 0) If count was specified, element contains the remainig count (time ticks).
    ;#                              (= 0) Instance has been stopped.
    ;#                   Array[5] = corresponding function parameters (can be an array itself) ("" (blank) if instance is disabled).
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibPause, _AdlibResume, _AdlibUpdate, _AdlibSync, _AdlibMainFreq, _AdlibFreq, _AdlibFunc, _AdlibID, _AdlibActive
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibParams($al_ID)
    If $al_ID > $al_func[0] Or $al_ID = 0 Then Return ""
    Local $ret[6]
    $ret[1] = 1
    If $al_func[$al_ID] = "" Then $ret[1] = 0
    If $al_current[$al_ID] = 0 Then $ret[1] = 2
    $ret[2] = $al_func[$al_ID]
    $ret[3] = $al_time[$al_ID]
    $ret[4] = $al_count[$al_ID] * - 1
    If $ret[4] < 0 Then $ret[3] += 1
    If $al_func[$al_ID] = "" Then $ret[4] = 0
    $ret[5] = $al_param[$al_ID]
    $ret[0] = $ret[2] & "(" & $ret[3] & "," & $ret[4] & "," & $ret[5] & ")"
    Return $ret
EndFunc   ;==>_AdlibParams

#EndRegion;--------_AdlibParams
#region;--------_AdlibActive

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: _AdlibActive ( [$al_ID] )
    ;#  Description....: Checks if _Adlib instance is active / paused. Or: Retrieves all active _Adlib instances.
    ;#  Parameters.....: $al_ID [optional] = The Adlib-ID returned by a previous _AdlibEnable call.
    ;#  Return Value ..: Success: Returns 1 if instance is active, 0 if disabled, and 2 if paused.
    ;#                            If parameter omitted or = 0 : Returns a 0 based array containing all active _Adlib instances.
    ;#                   Failure: Returns -1 and sets @error to 1 if Adlib-ID is not valid.
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: If parameter omitted or = 0 :
    ;#                   Array[0] contains total numbers, elements 1 - Array[0] the active Adlib_IDs.
    ;#                   @extended contains the number of paused _Adlib instances. Paused instances are active, too.
    ;#  Related........: AdlibEnable, AdlibDisable, Call, _AdlibEnable, _AdlibDisable, _AdlibPause, _AdlibResume, _AdlibUpdate, _AdlibSync, _AdlibMainFreq, _AdlibFreq, _AdlibFunc, _AdlibParams, _AdlibParams
    ;#  Example........: yes
    ;#===========================================================#
#ce

Func _AdlibActive($al_ID = 0)
    If $al_ID > $al_func[0] Then Return SetError(1, 0, -1)
    If $al_ID Then
        Local $ret = 0
        If $al_func[$al_ID] Then
            $ret = 1
            If $al_current[$al_ID] = 0 Then $ret = 2
        EndIf
        Return $ret
    EndIf
    Local $ret1 = "", $ret2 = 0
    For $al_ID = 1 To $al_func[0]
        If $al_func[$al_ID] Then
            $ret1 &= $al_ID & "*"
            If $al_current[$al_ID] = 0 Then $ret2 += 1
        EndIf
    Next
    Return SetExtended($ret2, StringSplit(StringTrimRight($ret1, 1), "*"))
EndFunc   ;==>_AdlibActive

#EndRegion;--------_AdlibActive
#EndRegion;--------------------------Main Functions
#Region;--------------------------Internal Functions
#cs
    ;#=#Function#================================================#
    ;#  Name ..........: __AdlibAdd ( $al_ID, $time )
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: internal use only
    ;#  Example........: no
    ;#===========================================================#
#ce

Func __AdlibAdd($al_ID, $time)
    $al_time[$al_ID] = $time
    Local $t = _AdlibMainFreq($time)
    If $time = 0 Then Return $t
    $al_next[$al_ID] = TimerDiff($al_timer) + $time
    _AdlibEnable("__AdlibMain", _AdlibMainFreq())
EndFunc   ;==>__AdlibAdd

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: __AdlibMain ( )
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: internal use only
    ;#  Example........: no
    ;#===========================================================#
#ce

Func __AdlibMain()
    If $al_update Then
        _AdlibEnable("__AdlibMain", _AdlibMainFreq())
        $al_update = 0
    EndIf
    Local $t = TimerDiff($al_timer)
    For $al_ID = 1 To $al_func[0]
        If $t >= $al_next[$al_ID] And $al_func[$al_ID] Then
            If $al_current[$al_ID] Then
                If $al_param[$al_ID] Then
                    Call($al_func[$al_ID], $al_param[$al_ID])
                Else
                    Call($al_func[$al_ID])
                EndIf
                $al_count[$al_ID] -= 1
                If $al_count[$al_ID] = 0 Then _AdlibDisable($al_ID)
            ElseIf $al_count[$al_ID] > 0 Then
                $al_count[$al_ID] -= 1
                If $al_count[$al_ID] = 0 Then _AdlibResume($al_ID)
            EndIf
            $al_next[$al_ID] += $al_time[$al_ID]
        EndIf
    Next
EndFunc   ;==>__AdlibMain

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: __AdlibKill ( )
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: internal use only
    ;#  Example........: no
    ;#===========================================================#
#ce

Func __AdlibKill()
    _AdlibDisable()
    Global $al_func[1] = [0], $al_time[1] = [0], $al_current[1] = [0], _
            $al_next[1] = [0], $al_param[1] = [0], $al_count[1] = [0]
            $al_update = 0
EndFunc   ;==>__AdlibKill

#cs
    ;#=#Function#================================================#
    ;#  Name ..........: __Euclid ( $a, $b )
    ;#  Description....: Calculates the Greatest Common Divisor
    ;#  Parameters.....: $a = 1st Integer
    ;#                   $b = 2nd Integer
    ;#  Return Value ..: Returns GCD
    ;#  Author ........: jennico
    ;#  Date ..........: 4.11.08
    ;#  Remarks .......: internal use only
    ;#                   taken from _Primes.au3
    ;#  Example........: no
    ;#===========================================================#
#ce

Func __Euclid($a, $b)
    If $b = 0 Then Return $a
    Return __Euclid($b, Mod($a, $b))
EndFunc   ;==>__Euclid

#EndRegion;--------------------------Internal Functions

But once I ran my script I got this error:

C:\-Bilder-\Dropbox\AutoIt\Folder checker 2.0\_Adlib.au3 (139) : ==> Variable used without being declared.:
If $al_ID > $al_func[0] Or $al_ID < 0 Then Return 0
If $al_ID > ^ ERROR

 

And once again, thank you for your time.

Link to comment
Share on other sites

Tried your script with my copy and got no errors. Sorry I can't remember what I had changed (if anything).

 

dmob, I salute you!

This is working like a charm in my script!

What I can see that you've done is that you've used an older version of the _Adlib-UDF, but the important thing is that the functions are still intact and working the way I wanted them to.

Though I didn't feel like reading through the UDFs to look for differences at this time. Just happy it works ^__^

And just a sidenote:

The function _AdlibEnable won't take a parameter which was a variable equal to 0.

An easy workaround for me with my current skills was:

       _AdlibEnable("_Action", $Interval, -1, $var+1)
func _Action($var)
$var = $var-1

Once again, thank you o so much for taking your time with this matter. Very much appreciated!

Until next time!

zvvyt

Edited by zvvyt
Link to comment
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
 Share

×
×
  • Create New...