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

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Timpraetor
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9
Joined: Thu Feb 04, 2010 7:12 pm

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

Post by Timpraetor » Fri Feb 12, 2010 12:36 am

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

Tim Jones
President / CTO
TOLIS Group, Inc.
http://www.tolisgroup.com
http://ww2.productionbackup.com

BvG
VIP Livecode Opensource Backer
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?

Post by BvG » Fri Feb 12, 2010 2:40 pm

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

mwieder
VIP Livecode Opensource Backer
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?

Post by mwieder » Fri Feb 12, 2010 6:52 pm

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

Janschenkel
VIP Livecode Opensource Backer
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?

Post by Janschenkel » Tue Feb 16, 2010 12:30 pm

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.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”