Jump to content

Shared Variables


Recommended Posts

Is there a way to have 2 scripts running and have them use variables that are set in only one script?

For instance:

Script one:

$VAR = 0

While 1

$VAR = $VAR+1

Wend

Script two:

While 1

$GETVAR1=$VAR

Sleep 10000

$GETVAR2=$VAR

If $GETVAR1 = $GETVAR2 then

do something

endif

Wend

Link to comment
Share on other sites

  • 2 weeks later...

How? Named pipes? File Semephores? Temp files?

Get from where? Send to where? What if more than two processes were running and wanting to share information?

Hmm, a named pipe could work... I will investigate on the weekend.

The process that sends the value would create the pipe and put the result of the expression on it, and close/forget its end of it. The other process would look for the pipe with a timeout. If no value was forthcoming in time, set @Error to 6 for example. If it finds the pipe, take the value, close the pipe entirely and return the value.

Oh, yeah, this is UNIX feature. I don't know if Windows allows this. Oh, well I know how to find out.

Hopefully,

AutoItWinSetValue("Pipe Name", <exp[b][/b]ression>)
$x=AutoItWinGetValue("Pipe Name")

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Link to comment
Share on other sites

David, yes, Window's has named (and unamed) pipes. I've not used them, though. Thought about using them in a project... but I've not actually started that project so I've not done any reading on them.

Edit: I should also mention that I wouldn't mind seeing pipes so that there could be interprocess communication in a very clean way.

Edited by Valik
Link to comment
Share on other sites

True, but the environment is inherited from one process to its children. Named pipes can be used by anybody, related or not; you just have to know the name of the pipe.

Unnamed pipes are also parent/child communication only. :D

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

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