Sign in to follow this  
Followers 0
arcker

Execute a function and continue loop

11 posts in this topic

#1 ·  Posted (edited)

ok, i've another problem :

here is an example

while 1

;ping the machine

if @error then

_erreurtest

;and continue loop without waiting

else

;continue with the next machine

endif

wend

func _erreurtest(machine)

while 1

;testmachine until no error

wend

endfunc

any ideas ?

Edited by arcker

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
Share on other sites



in my limited experience and from what i've read the main script stops until the func ends. perhaps you will have to launch another script, just a thought.

Share this post


Link to post
Share on other sites

try adlibenable ("_erreurtest")

and adlibdisable ()

this should fit your needs

As far as I'm aware... doesn't the main script wait for the adlib to finish.

You could have the testing function as a seperate application which writes to a file.

or something like this for running a single command on a line

Func AutoItExecute($Cmd)

Run(@AutoItExe & ' /AutoIt3ExecuteLine "' & $Cmd & '"')

EndFunc

Or write several lines to a temp file in autoIT code and run it

Run(@AutoItExe & ' /AutoIt3ExecuteScript ' & @tempdir & '\temp.au3')

Share this post


Link to post
Share on other sites

well, i'm not sure, as far as i know adlib doesn't stop the script

he could do a 2nd exe as well, but i think he doesn't want it

If you try the below, you will only ever get one message box at a time, if it could run the 2 together you would expect that with the MAin message box up and OK not clicked that the Adlib message would keep popping up, but it doesn't which is why I think the main script stops while adlib is running and vice versa, so if the main script is waiting for a reply the adlib doesn't run until after the reply

AdlibEnable ( "adlib" , 500 )

For $i = 1 to  5
    MsgBox (0,"Main", "Main Script")
    Sleep (500)
    Next

Func Adlib()
    MsgBox (0,"Adlib", "Adlib Message")
    EndFunc

Share this post


Link to post
Share on other sites

ok adlib really stops the script after the timeout you can give! but i got 1 more suggestion:

store the non-pingable machines to a variable and run your test after every ip is pinged so you won't loose the time to ping the others

best way would be a 2nd script where you just run the ping for this machine

you can pass the ip via a hidden window/gui controlsettext - controlgettext

just another idea

if you need more specific help just ask

Share this post


Link to post
Share on other sites

Just to confirm the help file says..

Remarks

Every 250 ms (or time ms) the specified "function" is called--typically to check for unforeseen errors. For example, you could use adlib in a script which causes an error window to pop up unpredictably.

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.

Share this post


Link to post
Share on other sites

yes, the main script waits for adlib ending

i will try to create a second script, or gui hidden, or shown why not.

so i will try

when "ping error", call the second function

maybe i can try with different guys in the same script ? no it will not change anything i think


-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
Share on other sites

grrrr too boring, because i've to work with multiple guis

and how to retrieve information of another guy (i've tried with return, it works, but stop the function,that it normal !)

so, i want to retrieve information $retrieve=run(script)

if $retrieve="no more error" then ;change serveur status message


-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
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
Sign in to follow this  
Followers 0