Page 1 of 1

Open stack at given path

Posted: Mon Jul 29, 2013 4:17 pm
by doobox
I could well be barking up the wrong tree here, as i am not sure i can package a splash standalone and a main.livecode for the mac app store, but here are my thoughts.

Could i put main.livecode in the splash standalone resources folder, package it up and submit to mac app store.
Then on first launch of the splash standalone copy the main.livecode to the applications support folder (i guess i am staying within my sandbox here).
Then tell the launcher to open the newly created stack main.livecode now in the applications support folder.

First huddle i can't seem to find a solution for : How do i open a stack at a given path..?

I tested this but it does not work even outside of any sandbox environment :

Code: Select all

-- this is the splash launcher standalone that has had the main.livecode placed in it's resources folder
on openStack
   put the filename of stack "mainSplashLauncher" into tPath
   set the itemDelimiter to "/"
   delete the last item of tPath
   delete the last item of tPath
   put tPath & "/Resources/main.livecode" after tPath 
   go stack tPath
   close stack "mainSplashLauncher"
end openStack
So this does not open the main.livecode stack..?

Apart from this opening of a stack via a path to that stack (which id guess is doable.
Do you think i am on the right track for mac app store approval..?

Re: Open stack at given path

Posted: Mon Jul 29, 2013 8:48 pm
by Klaus
Hi Gary,

you might want to read this one:
http://forums.runrev.com/phpBB2/viewtop ... =8&t=15714

Best

Klaus

Re: Open stack at given path

Posted: Mon Jul 29, 2013 9:31 pm
by doobox
Thank you Klaus,

Your method looks really interesting and obviously works for you.
I dont need to check for updates as i want to be app store only, and they have a firm rule about apps downloading additional code.

I will need to sit and really absorb your method tomorrow and decide if i can swing it to work for me in an app store app.

Re: Open stack at given path

Posted: Tue Jul 30, 2013 5:36 am
by doobox
The method i have opted for is very similar and very much inspired by your method Klaus, and i can only hope this will fly in a Mac App Store sandboxed environment.

1: Created a launcher stack myApp.stack and imported my main app stack main.livecode into the cMainStack of the launcher stack

2: In the launcher stack openstack i have done...

check if there is an application support folder myApp for the launcher stack in the application support folder

IF THERE IS NOT A myApp FOLDER THEN
Create the myApp folder
check if there is a file main.dat in the myApp folder
if not then put the cMainStack of the launcher stack into myApp folder naming the binfile main.dat
put a plain text file in the myApp folder containing the current version number of the launcher app

IF THERE IS A myApp FOLDER THEN
check the version number from the text file in the myApp folder
if the launchers version number is smaller then put the cMainStack of the launcher stack into myApp folder naming the binfile main.dat (overwriting and updating the existing main.dat)

The only issue i see with this is that if i issue a mac app store update and include a new main.dat (my real application)
then all the changes the user previously made and were saved in the stack each closestack will be lost.
pretty big issue though..!
If i can save user created stuff out to text files or a database on each stackclose id be kinda defeating the purpose of doing this launcher method.

Re: Open stack at given path

Posted: Tue Jul 30, 2013 11:19 am
by Klaus
Hi Gary,
doobox wrote:...If i can save user created stuff out to text files or a database on each stackclose id be kinda defeating the purpose of doing this launcher method.
although being able to SAVE that namely stack is a nice side effect of this method, I would never do this!
It is a pain in the ass to "tranfer" all the "saved" stuff from the stack to a newer version of the stack!

The only purpose of my method is to be able to REPLACE that stack with a newer version if neccessary,
I still store all infos OUTSIDE of this stack because of above mentioned problem


Best

Klaus

Re: Open stack at given path

Posted: Tue Jul 30, 2013 11:33 am
by doobox
Year i normally save any preferences etc to an xml or sometimes just a plain text file and retrieve them each launch.

In the case of this app, the more the user uses the app there kinda creating there own user interface of graphical elements generated by the stack, so my initial thought was great i will just save the stack if i can
and the method were discussing is great for that, but does totally fall down when i start thinking updates. One update and there ui will evaporate.

So its back to working out a way to write out every new user created ui element to file somehow for me, the prospect seems daunting :-)

Re: Open stack at given path

Posted: Tue Jul 30, 2013 2:10 pm
by Klaus
Hi Gary,

another idea! :-D

If you separate the UI, the stack that the user will be able to save, from the logics/scripts,
maybe you could have 2 (TWO) stacks, one for the user and one with the scripts, that you can "start using".

This way you could update the script-stack whenever you want and leave the user stack savable but otherwise untouched
from any update, which may not neccessary at all. Know what I mean?


Best

Klaus

Re: Open stack at given path

Posted: Tue Jul 30, 2013 2:26 pm
by doobox
I know what you mean, and the thought crossed my mind.
But it's still slightly dangerous in respect of ever wanting to update the small amount of ui the stack comes with as new.

Imagine if you will, when ios7 comes out, old apps are going to look very dated.
That could happen in the near future to OSX.
Or imagine if i overlook some geometry bug or the like in the main stack and only get it reported after release.. eek..!
And if i go down this road i am locking myself in for the long haul.

I'd kick myself if the app became a real success and sold in the hundreds of thousands.
Thats after pinching myself if one of my apps ever sells in the hundreds of thousands :-)


Though it does appear to be quite complex for me to save out every time the user creates a new ui element
I think i should try and figure out a fluid way to do it.
And of course a quick way to write it back in at every launch.

heres an example of just one of the ui elements a allow a user to create, and would need to be written out somewhere and there could potentially be hundreds of these elements in time.

Code: Select all

on createNewBucket
   lock screen
   // new round rect background template
   put the number of groups of group "buckets" + 1 into tNewGroupId
   create group ("bucket" & tNewGroupId) in group "buckets"
   set the behavior of group ("bucket" & tNewGroupId) to the long id of button "deleteBucket" of stack "behaviours"
   set the layerMode of group ("bucket" & tNewGroupId) to "dynamic"
   create graphic "Background" in group ("bucket" & tNewGroupId)
   set the layerMode of graphic "Background" of group ("bucket" & tNewGroupId) to "dynamic"
   set the style of graphic "Background" of group ("bucket" & tNewGroupId) to roundrect
   set the roundRadius of graphic "Background" of group ("bucket" & tNewGroupId) to 20
   set the opaque of graphic "Background" of group ("bucket" & tNewGroupId) to true
   set the width of graphic "Background" of group ("bucket" & tNewGroupId) to 200
   set the height of graphic "Background" of group ("bucket" & tNewGroupId) to 200
   put "254,105,22" into tDarkOrange
   put changeRgbShade(tDarkOrange, 1.8) into tLightOrange
   set the fillGradient["ramp"] of graphic "Background" of group ("bucket" & tNewGroupId)  of me to 0,tLightOrange,255 & return & 1,tDarkOrange,255
   set the fillGradient["type"] of graphic "Background" of group ("bucket" & tNewGroupId)  to "linear"
   set the fillGradient["from"] of graphic "Background" of group ("bucket" & tNewGroupId)  to the left of graphic "Background" of group ("bucket" & tNewGroupId) , the bottom of graphic "Background" of group ("bucket" & tNewGroupId) 
   set the fillGradient["to"] of graphic "Background" of group ("bucket" & tNewGroupId)  to the left of graphic "Background" of group ("bucket" & tNewGroupId) , the top of graphic "Background" of group ("bucket" & tNewGroupId) 
   set the fillGradient["via"] of graphic "Background" of group ("bucket" & tNewGroupId)  to item 1 of the loc of graphic "Background" of group ("bucket" & tNewGroupId) , the bottom of graphic "Background" of group ("bucket" & tNewGroupId) 
   set the foregroundcolor of graphic "Background" of group ("bucket" & tNewGroupId)  to "#999999"
   // create image cutter graphic
   create graphic "Cutter" in group ("bucket" & tNewGroupId)
   set the layerMode of graphic "Cutter" of group ("bucket" & tNewGroupId) to "dynamic"
   set the style of graphic "Cutter" of group ("bucket" & tNewGroupId) to rectangle
   set the opaque of graphic "Cutter" of group ("bucket" & tNewGroupId) to true
   set the width of graphic "Cutter" of group ("bucket" & tNewGroupId) to 180
   set the height of graphic "Cutter" of group ("bucket" & tNewGroupId) to 180
   set the backgroundColor of graphic "Cutter" of group ("bucket" & tNewGroupId) to "#ffffff"
   set the linesize of graphic "Cutter" of group ("bucket" & tNewGroupId) to 0
   set the loc of graphic "Cutter" of group ("bucket" & tNewGroupId) to the loc of graphic "Background" of group ("bucket" & tNewGroupId)
   // temp image
   create image "placeholder" in group ("bucket" & tNewGroupId)
   set the layerMode of image "placeholder" of group ("bucket" & tNewGroupId) to "dynamic"
   set the width of image "placeholder" of group ("bucket" & tNewGroupId) to 180
   set the height of image "placeholder" of group ("bucket" & tNewGroupId) to 180
   set the borderWidth of image "placeholder" of group ("bucket" & tNewGroupId) to 0
   set the imageData of image "placeholder" of group ("bucket" & tNewGroupId) to the imageData of image "temp" of stack "imageLib"
   set the loc of image "placeholder" of group ("bucket" & tNewGroupId) to the loc of graphic "Background" of group ("bucket" & tNewGroupId)
   // create bucket label
   create field "Label" in group ("bucket" & tNewGroupId)
   set the layerMode of field "Label" of group ("bucket" & tNewGroupId) to "dynamic"
   set the loc of field "Label" of group ("bucket" & tNewGroupId) to item 1 of the loc of graphic "Background" of group ("bucket" & tNewGroupId),item 2 of the loc of graphic "Background" of group ("bucket" & tNewGroupId) + 120
   put "Bucket" && tNewGroupId into field "Label" of group ("bucket" & tNewGroupId)
   set the textStyle of field "Label" of group ("bucket" & tNewGroupId) to "bold" 
   set the textAlign of field "Label" of group ("bucket" & tNewGroupId) to "center" 
   set the textSize of field "Label" of group ("bucket" & tNewGroupId) to 12
   set the opaque of field "Label" of group ("bucket" & tNewGroupId) to false
   set the showBorder of field "Label" of group ("bucket" & tNewGroupId) to false
   set the traversalOn of field "Label" of group ("bucket" & tNewGroupId) to false
   if the number of groups of group "buckets" > 1 then
      repositionBuckets
      positionFirstBucket tNewGroupId
   else
      positionFirstBucket tNewGroupId
   end if
   unlock screen
end createNewBucket
Thanks for your thoughts though Klaus.