Jump to content

Recommended Posts

Posted

Hi
 

Assume I have:

AdlibRegister("_Print",250)

func _Print()
.
.
.
.

endfunc

while 1
    if cond1 then

    elseif cond2 then
    
    elseif cond3 then
    
    elseif cond4 then
    
    elseif cond5 then
        _Print(".....")
    endif

    sleep(100)
wend

 

I assume:

_Print gets executed every 250ms..

Occasionally, if cond5 is valid, _Print gets executed as well.

Here are my questions:

1. What will happen to _Print if said function takes longer than 250 ms to complete?

a) Will Autoit execute the 2nd _Print call?

b) Or will autoit ignore the 2nd _Print call while _Print is still being executed?

2. script is executing _Print due to cond5, then AdLibRegister triggers a _Print call. what will happen?


Second Concern:
In the following simple for loop, what will happen to $i if somewhere in my script, (perhaps AdLibRegister) I have another for $i loop.. 
 

for $i = 1 to $files[0]


next

a) Will $i in the 1st for loop get corrupted by the 2nd loop?

In Perl I can do something like:

for(my $i = 0; $i <= 100; $i++) {
...
}

Is there an Autoit equivalent to it? wherein I can define the variable within the for statement?

 

thanks
 

Posted (edited)

I would suggest disabling Adlib when you enter the function then re-enable when you leave.

That however, depends on your requirements...

2nd concern, use another variable ($x, $j) for other ForNext loop.

Edited by dmob
  • 7 months later...
Posted

A revisit:

Using this script as reference.

func _sub1 ()
....
endfunc

func _sub2 ()
....
endfunc

Adlibregister("_sub1", 250)
Adlibregister("_sub1", 500)

while 1
......
wend

 

1. Adlibregister is not forking/multithreading. Therefore, if a function is triggered by an adlibregister, the while loop is paused.

2. assume: while performing _sub1, _sub2 was triggered; _sub1 is interrupted and autoit begins execution of _sub2. Once _sub2 ends, autoit goes back to executing _sub1.

3. IF however _sub2 takes longer than 250ms, adlib could trigger _sub1 again. In this case, there are now _sub1, _sub2 and _sub1 "adlib-ed" (should be avoided using suggestions by dmob and vip).

Let me know if these are correct.

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
×
×
  • Create New...