Pass Variable Between Pubs in Realtime - Forum

Forum Navigation
You need to log in to create posts and topics.

Pass Variable Between Pubs in Realtime

Does anybody know of a way to pass a variable from one running NB exe to another in realtime?

I need to be able to have one running program generate a variable and pass that data to another running program where the second one can perform an action straight away.

I've played with the [CommandLine] and CommandLine_OnChange; however there are limitations especially when there are spaces within the variable data.

Suggestions?

@pauljonestindall

I've played with the [CommandLine] and CommandLine_OnChange; there are limitations especially when there are spaces within the variable data.

Perhaps you could have the sending program do a FileWrite of the variable data ... and then invoke the receiving program with a simple notification ... which would then know to FileRead the just-stored variable data (and also clear/delete this content).

If there is the possibility of multiple programs (say A and B and C) sending data to program Z, each of the sending programs could FileWrite to a different file ... and the command line parameter would indicate so e.g.  ...

ProgramAHasDataForYou, ProgramBHasDataForYou etc.

or

CheckFileAForNewData, CheckFileBForNewData etc.

 

@gaev

Yes. I think this may be the way to go.

Thanks for the suggestion.

@gaev

However, how can I pass a variable to a NB program running on another computer?

@pauljonestindall

how can I pass a variable to a NB program running on another computer?

Since, as far as I know, you can not have a program on one computer initiate a program on another, you would need an intermediate step.

Let us say that Program A is running on Computer A and Program B is running on Computer B

1) Program A would do the FileWrite commands to a location on the "shared disk space"

2) Program B ...

- at start up, would do a StartTimer function that would repeatedly check for the presence of the shared file

... or better still ...

- would initiate a "monitor program" on Computer B that would run the Timer object

It would be prudent for all sending and receiving programs to have their own "message log" files ...

Timestamp : Sent/Received : Message content

... just in case 'shit hits the fan'.

@pauljonestindall Hello!
In one of my projects (parental control) I stored a text file on the FTP server. From any computer or phone I could change this text file, and the program on the child’s computer regularly checked the contents of this file and either allowed to use the computer further, or turned it off.

I agree with Gaev.
A shared file (on the local computer or server) is probably the simplest thing you can think of.

@pauljonestindall In our software BiblioControl we use a UDP plugin to control a bunch of computers running a VisualNEO Win application from a server computer running another VisualNEO Win application. The server sends data through UDP to the target client wich is listening to any message that comes from the server. The communication is in both ways as the client can send a response to the server. Although we use an old plugin from Alberto Meyer, I'm sure the new asUDP 2.1 plugin from @as3856 would do the job too.

Vadim has reacted to this post.
Vadim

@pauljonestindall

I call it Blob in a Bottle....

A Remote program sends a text file to a specific directory, either on the same computer or via ftp like this:

FileWrite "[AppDataPath]subremote.tmp" "All" "AGoSubName"

(AGoSubName or anything else is the name of a subroutine in the Master program.)

The Master program has a Timer that searches for subremote.tmp every second. When it finds it, it runs the file's contents (AGoSubName in this case) as if it were the name of a subroutine

FileExists "[AppDataPath]subremote.tmp" "[subR]"
If "[subR]" "=" "True"
FileRead "[AppDataPath]subremote.tmp" "1" "[i]"
FileErase "[AppDataPath]subremote.tmp"
GoSub "[i]"
EndIf

The Master program does exactly the same with a different filename

FileWrite "[AppDataPath]submaster.tmp" "All" "AnotherGoSubName"

And the Remote program also has a Timer that looks for submaster.tmp every second and executes it as a subroutine when it finds it....

Variables between two programs, like a blob in a bottle.

..

I use this simple method to send info between two apps (Master and Remote) for a video stabilizer I am working on now.

 


 

I should mention that the hpwRemote plugin is used to remote-access between multiple VisualNeo-apps.

hpwRemote - VisualNEO. Cross-platform App Development Tool for Windows

HPW's neobook page (hpwsoft.de)

 

 

 

Vadim has reacted to this post.
Vadim