Page 1 of 1
Cross-platform executable launching
Posted: Mon Dec 13, 2010 5:20 am
by Malteser
Second issue from me in the span of a few days. This is really going well for me.
Three signifigant chunks of my program require a specific executable to be run and actions performed on it during runtime (the latter of which is done externally).
However, file extensions are obviously different per-platform and so I was wondering how this is done (as I'm not a Mac or Linux user by any means, but the program certainly needs to ensure some compatibility).
Would this be anywhere near or am I way off?
Code: Select all
if the platform is "MacOS"\
then open file "xyz.app"
else if the platform is "Win32"\
then open file "xyz.exe"
else if the platform is "Linux"\
then /*open file "ohgodIdon'tknowwhattoputforLinux" */
/* How to go about permissions? */
Re: Cross-platform executable launching
Posted: Mon Dec 13, 2010 11:42 am
by WaltBrown
Hi Malteser,
Did you check out the "shell" function? I'm not sure you want to use "open", as it sounds like you want to execute external applications, not open their files.
Walt
Re: Cross-platform executable launching
Posted: Mon Dec 13, 2010 12:32 pm
by Malteser
On closer inspection it looks like I should be looking at the Shell command instead - thanks for the suggestion. The Dictionary examples are slightly vague - are there any more specific examples I can find of how it's used? Tried a quick search but I couldn't find anything completely related to RunRev's usage.
Specifically, running an executable located in the same folder as RunRev's program across all three platforms.
Re: Cross-platform executable launching
Posted: Mon Dec 13, 2010 12:37 pm
by WaltBrown
Try something simple first like:
Code: Select all
if the platform is "Win32" then put shell("dir") into fld "fSomeField"
else put shell("ls") into fld "fSomeField"
Basically, whatever you can type on the command line can be put in quotes and used in the shell command. Shell returns whatever stdout gives it. There are quite a few more complex examples scattered throughout this forum.
Re: Cross-platform executable launching
Posted: Mon Dec 13, 2010 12:47 pm
by Malteser
Testing out the example on an empty card explained it all perfectly, thanks very much! I'll try and find some mention of the Mac and Linux sort (the RunRev dictionary mentions UNIX filepaths but sadly I'm one of those silly Windows users.

)
Re: Cross-platform executable launching
Posted: Mon Dec 13, 2010 12:50 pm
by Janschenkel
If the executables are command-line applications, then the
shell function is the way to go.
However, if these are interactive tools with a GUI, you should look at the
launch command.
HTH,
Jan Schenkel.
Re: Cross-platform executable launching
Posted: Mon Dec 13, 2010 2:54 pm
by Malteser
Essentially, all of the files I need to launch are in the same directory as the RunRev file. (Basically, it runs the "patch_up.exe" executable and then launches the actual "toolset_up" executable once that's finished -the patch changes aren't permanent so this is necessary at every startup.) Ideally, that should mean I don't have to add too much on finding the current directory - or is checking in the same folder when a dir isn't specified only default behaviour on Windows?
Is it simple enough of a problem that simply going:
Code: Select all
get shell("start patch_up.exe")
get shell("start toolset_up.exe")
Would work perfectly for this situation, or do UNIX and Mac systems need some other edits? I'm a little disappointed in myself in that I seem to be progressing slower than usual with RunRev so far, but I'll put it down to how different the syntax is!
On a side note, and mostly out of sheer curiousity, why does:
Work fine, and yet:
Not function at all? From what I read on the RunRev Dictionary the 'get' command doesn't appear to be relevant.
Re: Cross-platform executable launching
Posted: Mon Dec 13, 2010 5:03 pm
by Klaus
Hi all,
no need for shell or something actually, just use Livecode:
...
launch document "Name of app or exe or whatever"
...
Best
Klaus