Jump to content

Run a bunch of Functions one after an other solutions


Go to solution Solved by water,

Recommended Posts

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

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

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)

userbar.png

Link to comment
Share on other sites

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

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 :D

Edited by SorryButImaNewbie
Link to comment
Share on other sites

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

  • Solution

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

:)

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

The most simple results need the most effort :)

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...