huskies Posted March 5, 2011 Share Posted March 5, 2011 Hi I would like to run my GetData function that I wrote,the relevant parameter here is the last one, which indicates the time in seconds in should wait before running it self again. I haven't inplemeted this yet, so right now it's just a useless parameter. For example I would like to run GetData for technician1 once every 1460000 seconds and the same for technicians2 once every 2460000 seconds. I can't seem to come up with a way to add that within the function itself. Because if I am looping a fucntion, it will just sit there and wait and will not move onto the next function. Call ("GetData", technician1, 1460000) ;<-the last variable is the time I want the function to wait and then rerun itself Call ("GetData", technician2, 2460000) Call ("GetData", technician3, 1500000) Call ("GetData", technician4, 3000000) Call ("GetData", technician5, 4760000) Call ("GetData", technician6, 5230000) <It Shall Be Done> Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2011 Moderators Share Posted March 5, 2011 huskies,I would look at Adlib in the Help file. It allows you to run a function at a specified interval without having to call it specifically. By the way, you do not need to use Call in your posted code - it is only needed if you have the function name in a string variable. You just use the function name directly:GetData(technician3, 1500000) GetData(technician4, 3000000) ; This is when you would use it $sFunction = "GetData" Call (sFunction, technician3, 1500000) Call (sFunction, technician4, 3000000)All clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
huskies Posted March 5, 2011 Author Share Posted March 5, 2011 Hi Thanks for the reply, it does seem like a very good idea. However, it seems that in AdlibRegister , AdlibRegister ( "function" [, time] ), it doesn't give me an option to input parameters. So I can only do AdlibRegister ("GetData", 1460000) but I wouldn't be able to pass any parameters, such as the technician name. Is there a way to add that or do I have to add a functions for each technician? I want to avoid doing that because it will increase the file size. <It Shall Be Done> Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2011 Moderators Share Posted March 5, 2011 huskies, Just use some tiny wrapper functions like this: HotKeySet("{ESC}", "On_Exit") AdlibRegister("Tech1", 5000) AdlibRegister("tech2", 7000) While 1 Sleep(10) WEnd Func Tech1() _GetData("Tech1") EndFunc Func Tech2() _GetData("Tech2") EndFunc Func _GetData($sTech) ConsoleWrite("GetData was called with " & $sTech & " as a parameter at " & @SEC & @CRLF) EndFunc Func On_Exit() Exit EndFunc Will that do? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
huskies Posted March 5, 2011 Author Share Posted March 5, 2011 Thank you very much! That will do <It Shall Be Done> Link to comment Share on other sites More sharing options...
huskies Posted March 5, 2011 Author Share Posted March 5, 2011 I have a question, is the code While 1 Sleep(10) WEnd to keep the program from shutting itself down? I didn't add that in my code because I didn't know it's purpose and my program will just close itself without calling anything in Adlib <It Shall Be Done> Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2011 Moderators Share Posted March 5, 2011 huskies,Indeed it is - otherwise, as you have found, the script just ends. Every program, be it a simple AutoIt script or the Windows OS itself needs an idle loop to keep it active waiting for the next input. That is why there was a HotKeySet("{ESC}", "On_Exit") line to give you an elegant way to break out of the loop. As that question seems to indicate that you are relatively new to coding, could I recommend reading the Help file carefully (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) which will give you a good handle on how AutoIt code is structured. You might also consider looking at the excellent tutorials that you will find here and here - you can find other, rather more advanced, tutorials in the Wiki (the link is at the top of the page). M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
huskies Posted March 6, 2011 Author Share Posted March 6, 2011 Thank you so much for the tip and I will definitely look into the tutorials <It Shall Be Done> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now