Page 1 of 1

Examples using "process" functions to manage back-end tool?

Posted: Fri Feb 12, 2010 12:36 am
by Timpraetor
Hi Folks,

I've looked through all of the resources that I can find, but I'm drawing a blank.

Can anyone point me to some example code that starts and communicates with a back-end command line tool using the "open process", "read from process", "write to process" and "close process" functionality?

Thanks,
Tim

Re: Examples using "process" functions to manage back-end tool?

Posted: Fri Feb 12, 2010 2:40 pm
by BvG
If it's a command line tool, you might better be served with the "shell" function.

Re: Examples using "process" functions to manage back-end tool?

Posted: Fri Feb 12, 2010 6:52 pm
by mwieder
...with the following caveats:

Shell is a blocking command, so if you don't want to wait for the external tool to finish you'll need processes. If that's not a problem then shell is the easier way to go.

You can tell whether a process is open by checking the openprocesses

...but...

open process tProcess for "read"
repeat while tProcess is in the openprocesses
read from process tProcess until cr
end repeat

will loop forever because it's always in the openprocesses, even after the process quits. Same thing with opening a process for "update".

Opening a process for "neither" removes the process from the openprocesses when it's done, but then you can't read any date from it.

Re: Examples using "process" functions to manage back-end tool?

Posted: Tue Feb 16, 2010 12:30 pm
by Janschenkel
As you never 'close' the process in Rev, it stays in the openProcesses global variable, regardless of the actual process having quit. So you should build a safeguard into your repeat loop, checking if 'it' (the place where the outcome of the 'read from process' is stored) contains an agreed upon 'end of work' symbol.

Jan Schenkel.