Launch another app from my standalone

Scott Morrow scott at elementarysoftware.com
Sun Aug 30 19:34:33 EDT 2009


Hello Adrian,

I've sort of re-written what Len suggested but without using a  
separate function or handler.  You can just put the whole thing in  
where you need it.  Eventually you may want to break out pieces of  
your code by using custom functions and commands but this should work.

Scott Morrow

Elementary Software
(Now with 20% less chalk dust!)
web       http://elementarysoftware.com/
email     scott at elementarysoftware.com
------------------------------------------------------------------------------------------------------------------------------

put the filename of this stack into tFilePath --tFilePath contains the  
full path to the mainstack
put the itemDelimiter into tOldItemDelimiter -- remember what it was  
so we can set it back

set the itemDelimiter to slash -- "/"  this is the character that  
divides the path up for example--> C:/aFolder/anotherFolder/ 
aFileOrProgram

-- because "/" is now the itemDelimiter
-- aFileOrProgram would be the last item ( item -1 ) in tFilePath
-- on Windows, the path to the standalone,
-- or in the rev IDE the path to the stack file,
-- is the last item ( item -1 ) of tFilePath
-- the path to the folder enclosing the stack file or MyStandalone.exe
-- is the second to the last item of tFilePath <second to the last is  
not rev code>
-- we want to put the name of the application you want to launch
-- after the enclosing folder
-- However
-- on Mac OSX, if this code is being executed from a standalone  
application,
-- then the path to the folder enclosing the standalone is different
-- the fileName of this stack (tFilePath) will look something like:
--   /Macintosh HD/Applications/MyStandalone.app/Contents/MacOS/ 
MyStandalone
-- which makes the enclosing folder item -5 of tFilePath
-- so we will need to know which platform we are on
-- in order to determine what part of the path to use

if (the platform is "MacOS") AND (the environment is not  
"development") then  -- Mac Standalone
   put item 1 to -5 of tFilePath &"/"&  "theAppName.app" into tAppPath
else -- Windows or rev IDE
   put "theAppName.exe" into item -1 of tAppPath -- example--> put  
"Photoshop.exe" into item -1 of tFilePath
end if

-- in your code, replace theAppName.exe  or   theAppName.app
-- with the actual name of the program you want to open 
-- Keep it inside quotation marks

launch tAppPath

set the itemDelimiter to tOldItemDelimiter -- tidy up


-------------------------------------------------------------------------------
-- here it is one more time without all the comments
-- watch line wraps in the email
-------------------------------------------------------------------------------
put the filename of this stack into tFilePath
put the itemDelimiter into tOldItemDelimiter
set the itemDelimiter to slash
if (the platform is "MacOS") AND (the environment is not  
"development") then  -- Mac Standalone
  put item 1 to -5 of tFilePath &"/"&  "theAppName.app" into tAppPath
else -- Windows or rev IDE
  put "theAppName.exe" into item -1 of tAppPath -- example--> put  
"Photoshop.exe" into item -1 of tFilePath
end if
launch tAppPath
set the itemDelimiter to tOldItemDelimiter -- tidy up



More information about the use-livecode mailing list