Page 1 of 1

Open a stack from a Standalone

Posted: Sun Feb 05, 2017 8:32 pm
by maxs
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

Re: Open a stack from a Standalone

Posted: Sun Feb 05, 2017 11:37 pm
by jmburnod
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

Re: Open a stack from a Standalone

Posted: Mon Feb 06, 2017 1:13 am
by maxs
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

Re: Open a stack from a Standalone

Posted: Mon Feb 06, 2017 10:28 am
by jmburnod
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

Re: Open a stack from a Standalone

Posted: Fri Feb 10, 2017 5:39 am
by maxs
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