Open a stack from a Standalone

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 382
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Open a stack from a Standalone

Post by maxs » Sun Feb 05, 2017 8:32 pm

I'm trying to build a standalone shell that will open a stack in the same folder on my computer.

This code does not seem to work.

put the longfilepath of me into ThisLoc
put (ThisLoc & "/" & "Classroom Control Center") into ThisWindow
Open stack ThisWindow


Am I missing something?

Max

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2006
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Open a stack from a Standalone

Post by jmburnod » Sun Feb 05, 2017 11:37 pm

Hi Max,
Filename of a standalone is different filename of a stack because a standalone is a package and packages are different in OS X and WIndows.
You can use this function to get the path of the folder where is your stack or standalone.

Code: Select all

function getMyStackFolderPath
   put the effective filename of this stack into rMainStackFolder 
   put the platform  into tPlatForm
   put the environment into pEnv
   put the itemdel into OID
   set the itemdel to "/"
   put the num of items of rMainStackFolder into nbF
   if tPlatForm = "MacOS" then 
      if pEnv = "standalone application" then
         delete item (nbF-3) to nbf of rMainStackFolder
      end if
      if pEnv = "development" then
         delete last item of rMainStackFolder
      end if
   else
      delete last item of rMainStackFolder
   end if
   set the itemdel to OID
   return  rMainStackFolder
end getMyStackFolderPath
You have to consider that some messages like preopenstack, openstack... are catched by the mainstack if they are not in the stack script.

Best regards
Jean-Marc

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 382
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Re: Open a stack from a Standalone

Post by maxs » Mon Feb 06, 2017 1:13 am

Thanks Jean-Marc, Thanks for the function.

I got the function working. I know I have the correct pathame but the stack is not opening,
"Classroom Control Center" is the mainstack name, spelling is correct.

I wrote
on mouseUp
put getMyStackFolderPath(rMainStackFolder) into ThisWindow
put ( ThisWindow & "/" & "Classroom Control Center") into ThisWindow
Open Stack ThisWindow
end mouseUp

I also tried "Open ThisWindow" and "Open Window ThisWindow" I put the code into a button. Did I do something wron

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2006
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Open a stack from a Standalone

Post by jmburnod » Mon Feb 06, 2017 10:28 am

Hi Max,
There is no param for getMyStackFolderPath function.
Please try this:

Code: Select all

on mouseUp
   put getMyStackFolderPath() into tMyFolder
   put "MyStackToOpen.livecode" into tNameStack -- You have a stack called "MyStackToOpen.livecode" in folder tMyFolder
   put tMyFolder & "/" & tNameStack into tPathStack
   Open Stack tPathStack
end mouseUp
Jean-Marc

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 382
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Re: Open a stack from a Standalone

Post by maxs » Fri Feb 10, 2017 5:39 am

Thank you Jean- Marc

I forgot the the name of a stack can be different than the display name of a stack.

It opens now, as well as opening another can of worms.

Max

Post Reply

Return to “Mac OS”