Jump to content

Recommended Posts

Posted

I am writing a library function that I wish to use with other scripts. The function performs some actions, waits for a little while, then should run a custom action specified by the calling script. I want to pass a callback function to the library function so it can run the caller's callback at the appropriate time.

How could I do this?

Thanks.

  • Moderators
Posted

I may not be following... does Call() help you?

I'm sure I'm not following either... You may want to look at Command Line Parameters and or EnvGet/EnvSet ... maybe even in the AutoIt Beta the StderrRead/StdoutRead/StdinWrite options

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

I may not be following... does Call() help you?

Call() was exactly what I was looking for. Thanks!

Along the same lines, is there a way to have a function run asynchronously from the rest of a script? Basically, I'd like to start a function which has an infinite loop that checks certain conditions, but at the same time, have another infinite loop running doing other things.

Is that possible?

Thanks again.

Posted

No "threaded" solution... but look at AdlibEnable()

Lar.

Just remember that the adlib (who came up with that name)? function will block execution of the main loop.

AdlibEnable("cbAdlib", 333)
loopit()
exit
Func loopit()   
   while 1
      ConsoleWrite("loopit - Before" & @LF)
      sleep(50)
      ConsoleWrite("loopit - After" & @LF)
   wend
EndFunc
Func cbAdlib()
   ConsoleWrite("cbAdlib - in" & @LF)
   sleep(300)
   ConsoleWrite("cbAdlib - out" & @LF)
EndFunc

You could take a look at the CoRoutine samples and create somthing running in diffrent processes.

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