Path to a Copied File in Mac Standalone

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
icouto
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 92
Joined: Wed May 29, 2013 1:54 am

Path to a Copied File in Mac Standalone

Post by icouto » Tue May 13, 2014 7:38 am

I am developing a stack that is a GUI for a command-line tool, for MacOS X. I want to include the command-line tool itself with my standalone build.

I have added the command-line tool file in the "Copy Files" pane of the Standalone Application Settings dialog. When I build the standalone, it is indeed being copied into the bundle - it puts it right the same sub-directory as the main executable for the app. The questions that I have are:

1) How can I find the complete file path to the included file? I need to reference is on several shell() calls in my scripts![/1]
2) When I'm writing my scripts in the LiveCode IDE, I will have to use a certain path in shell() for the command-line tool. Once that tool is bundled in the standalone, the path will change. How will shell() know whether it's running from the IDE, or from a standalone - and adjust its path accordingly?

Or, is there an easier way to do this that I'm missing?...

Any guidance would be much appreciated.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Path to a Copied File in Mac Standalone

Post by Klaus » Tue May 13, 2014 11:57 am

Hi Igor,
1) How can I find the complete file path to the included file? I need to reference is on several shell() calls in my scripts!
Ever right-clicked a Mac APP bundle and checked its content? :D
...

Code: Select all

## Gives the absolute pathname to the standalone (mainstack)
put the effective filename of this stack into tRuntime
set itemdel to "/"
put empty into item -1 of tFile
put tFile & "/" into tPathToYourCopiedFiles_including_CLI
...
2) When I'm writing my scripts in the LiveCode IDE, I will have to use a certain path in shell() for the command-line tool.
Once that tool is bundled in the standalone, the path will change.
How will shell() know whether it's running from the IDE, or from a standalone - and adjust its path accordingly?
SHELL() will only know this fact if you tell it! :D

Code: Select all

...
if the environment = "development" then
  ## do IDE stuff and supply IDE pathnames
else
  ## Do RUNTIME stuff, see above...
end if
... 
Best

Klaus

icouto
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 92
Joined: Wed May 29, 2013 1:54 am

Re: Path to a Copied File in Mac Standalone

Post by icouto » Tue May 13, 2014 2:29 pm

Klaus, you're a gem: the effective filename and the environment were exactly what I was looking for!

Thank you so much! :-)

Side note: man, you've helped SO MANY people in these forums! You're amazing!

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Path to a Copied File in Mac Standalone

Post by Klaus » Tue May 13, 2014 4:18 pm

Yeah, isn't that suspicious somehow? :D

Post Reply