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
Examples using "process" functions to manage back-end tool?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 9
- Joined: Thu Feb 04, 2010 7:12 pm
Examples using "process" functions to manage back-end tool?
--
Tim
Tim Jones
President / CTO
TOLIS Group, Inc.
http://www.tolisgroup.com
http://ww2.productionbackup.com
Tim
Tim Jones
President / CTO
TOLIS Group, Inc.
http://www.tolisgroup.com
http://ww2.productionbackup.com
-
- VIP Livecode Opensource Backer
- Posts: 1236
- Joined: Sat Apr 08, 2006 1:10 pm
- Location: Zurich
- Contact:
Re: Examples using "process" functions to manage back-end tool?
If it's a command line tool, you might better be served with the "shell" function.
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Examples using "process" functions to manage back-end tool?
...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.
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.
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
Re: Examples using "process" functions to manage back-end tool?
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.
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com