SorryButImaNewbie Posted December 13, 2014 Share Posted December 13, 2014 Hello guys! I wanted to make the functions in my program interruptable with the help of the https://www.autoitscript.com/wiki/Interrupting_a_running_function . I use OnEventMode and I made the call functions, and everything works fine (I havent filled my functions with the hecessary flag checks during run time yet), after my consultation on the project with my boss he told me that I should also make a function that calls the relevant functions one by one. I wanted to do this with the flags makeing a Function like this: Func RunAll $f1run = True If $f1run = False Then $f2run = True EndIF If $f2run = false Then $f3Run = True Endif ;so on EndFunc All my $f(number)Run are global and set to false at the beginning of the script. When ever a function is called by setting its variable to True, the function itself sets it back to false after it run. When I run the code for some reason it doesn't run all the functions, it skips a few (like f1run, then f3run etc) I wasn't sure that my code would work properly anyway since the if starts when the variable of the previous function is false and all of these varibles starts as false alas I don't know if that is the origin of the problem. My most likely hipothesis about this is that the computer real time cloack (not sure if thats the correct name I mean the CPU timer that is also used the generate random numbers for example) is working in a way that its simply return to the not intended part of the code and since the If its checks first is false by default it runs that part. please asks anything about my code if you need more insight What do you think? whats your best practice method to develope something like this? Thank you for your help! Link to comment Share on other sites More sharing options...
SorryButImaNewbie Posted December 13, 2014 Author Share Posted December 13, 2014 I think the best way would be if ther is someway to varify if a functions has just "finished", I'm looking for something like that now, but if you have/know something like that pls shoot Link to comment Share on other sites More sharing options...
water Posted December 13, 2014 Share Posted December 13, 2014 Wouldn't one single variable be enough to determine if the next function should be run? Or do you need the status of already rn functions? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
SorryButImaNewbie Posted December 13, 2014 Author Share Posted December 13, 2014 I don't get it, can you show an example? (I tried to use my already existing variable, but no real reason is bhind that thinking) Link to comment Share on other sites More sharing options...
SorryButImaNewbie Posted December 13, 2014 Author Share Posted December 13, 2014 ohh you mean like a number var that starts from for example 1, and then every functions has a number and after every function run it simply add +1 to that variable causing it to run the next func? Link to comment Share on other sites More sharing options...
TheSaint Posted December 13, 2014 Share Posted December 13, 2014 I think we need to see more code, as I'm not entirely sure what you are aiming for? It may be, that the Adlib functions may be of assistance? It might be, that you need to wait on a return value from a running program? Run, RunWait, etc etc? Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
water Posted December 13, 2014 Share Posted December 13, 2014 (edited) Set the global variable which determines if the next function is to be run to True, the interruption function then sets it to False and all other functions are not processed then.Func RunAll $bRunFunc = True Func1() If Not $bRunFunc Then Return Func2() If Not $bRunFunc Then Return Func3() If Not $bRunFunc Then Return ; Etc EndFunc Func Interrupt() $bRunFunc = False EndFunc Edited December 13, 2014 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
SorryButImaNewbie Posted December 13, 2014 Author Share Posted December 13, 2014 (edited) I think we need to see more code, as I'm not entirely sure what you are aiming for? It may be, that the Adlib functions may be of assistance? It might be, that you need to wait on a return value from a running program? Run, RunWait, etc etc? My code is like : arrays, global variabels at the top amongst them there are the function calling variables, all false then comes a bunch of functions that are doing actual work. Then a Grp of functions that only sets the variable of a funcrun to true then a while WEnd loop with a sleep(50) for the "empty run" and checks for the function runs variables Like this: ;Includes Opts Global $fTestRun = False ;others like this ;Functions to call (the ones that actually works with the different windows etc) Func TestRun() $fTestRun = True EndFunc ; This function is called by a button on my form built by ISN AutoIT Studio While 1 ;üres járat a GUIformnak + Run flagek kezelése Sleep(50) If $fTestRun Then Test() EndIf ; the other functions WEnd Hope this is okey (RunWait only works with other programs, I need exactly that but for my functions) Water Set the global variable which determines if the next function is to be run to True, the interruption function then sets it to False and all other functions are not processed then. Func RunAll $bRunFunc = True Func1() If Not $bRunFunc Then Return Func2() If Not $bRunFunc Then Return Func3() If Not $bRunFunc Then Return ; Etc EndFunc Func Interrupt() $bRunFunc = False EndFunc wouldn't this try to run all the functions simulteniously? Also I tried to use the method I described above ($newvar = 1, then adding +1 after every run makeing it call the next function) this caused it to try to run all the functions togeather, wasn' t nice, this is why I'm writing back so slow Edited December 13, 2014 by SorryButImaNewbie Link to comment Share on other sites More sharing options...
water Posted December 13, 2014 Share Posted December 13, 2014 wouldn't this try to run all the functions simulteniously?No, as AutoIt does not allow multitasking the functions are executed one after the other. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
SorryButImaNewbie Posted December 13, 2014 Author Share Posted December 13, 2014 It tried to run my functions simultaniously 0.o (I'm going home now from my workplace, I will come back here within an hour from home! thank you for your help so far guys!) Link to comment Share on other sites More sharing options...
SorryButImaNewbie Posted December 13, 2014 Author Share Posted December 13, 2014 Hi! "No, as AutoIt does not allow multitasking the functions are executed one after the other." Doesn't this mean that I can just create a function like this: Func AllFunc func1() func2() func3() ... EndFunc Didn't even consider this as an option, I can try it because I cant reach my code from home... Link to comment Share on other sites More sharing options...
Solution water Posted December 13, 2014 Solution Share Posted December 13, 2014 (edited) Your code executes Func1 then Func2 and then Func3. It tried to run my functions simultaniously 0.o You can only run external programs simultaniously Run("program1.exe") Run("program2.exe") Run("program3.exe") Does not wait for the execution of program1.exe to end but starts program2.exe and program3.exe immediately. Edited December 13, 2014 by water SorryButImaNewbie 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
SorryButImaNewbie Posted December 15, 2014 Author Share Posted December 15, 2014 This seems to work as you said, thank you! Link to comment Share on other sites More sharing options...
water Posted December 15, 2014 Share Posted December 15, 2014 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
SorryButImaNewbie Posted December 15, 2014 Author Share Posted December 15, 2014 Still I'm somewhat proud of myself that I managed to run multiple functions with some If loops + flags for functions magick Nice to know that the solution was the most basic, most simple thing that I probably should tried first... Link to comment Share on other sites More sharing options...
water Posted December 15, 2014 Share Posted December 15, 2014 The most simple results need the most effort TheSaint 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki 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