How should I pass variables between independent parallel tcl procs/scripts

64 views Asked by At

I have an obsolete, mission critical application that runs gui displays with tcl behind some items (some aren't as complex)

I am trying to get some gui elements to pass flags around to switch certain displays off, or switch modes.

Globals, and upvar 0 don't seem to work. Any ideas?

1

There are 1 answers

1
Donal Fellows On

If they're in separate processes, you're talking doing Interprocess Communication (IPC). That's a big topic!

If you aren't needing to communicate that much with high degrees of synchrony, an easy way is to use an SQLite database. All processes can open it and do transactions in it to store and retrieve data and so on. Very convenient... especially as you can also use third-party tools to have a look at that shared state.

If they're all using Tk then maybe you can use send? It's easy, but only turns itself on when security settings are just right. I've done nothing with that mechanism for years...

Otherwise, a local socket (on localhost) ia fast on most platforms, or you can use pipes (including named pipes). That gets you a communication channel (bidirectional in the case of a socket) that you can use. The comm package in Tcllib builds on top of that.

To synchronise a variable, use a write trace to work out when to update the other side.