Sign in to follow this  
Followers 0
zasxes

Shared Variables

8 posts in this topic

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

Share this post


Link to post
Share on other sites



I figured I could do that I just wanted to do it all in memory

Share this post


Link to post
Share on other sites

Now THERE's a good idea .. yes, we could have AutoItWinSetValue and AutoItWinGetValue ..

Awesome!

:D:huh2::)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
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...

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