Deploy several stacks as an application to android

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

gnor
Posts: 53
Joined: Fri May 08, 2020 10:32 pm

Re: Deploy several stacks as an application to android

Post by gnor » Thu May 12, 2022 10:46 am

Thanks Klaus!

in that case: capitals an umlauts makes few thousend of lines of code to check.
All of my stacks are vith umlaut.....
Thank you anyway

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Deploy several stacks as an application to android

Post by Klaus » Thu May 12, 2022 11:39 am

Hi gnor,

I did not mean that CAPITALS are a problem, only that you will have to take care of that fact! :-)

Code: Select all

...
go stack (specialfolderpath("resources") & "/Calendar.livecode")
## Works on Android
go stack (specialfolderpath("resources") & "/calendar.livecode")
## will not!
...
And "Find and replace..." in LCs EDIT menu will help you with changing the call of stacks with accents in their name.
But this will only affect when adressing FILENAMES in scripts, you can still address the stacks in scripts with their names with accents!

Best

Klaus

gnor
Posts: 53
Joined: Fri May 08, 2020 10:32 pm

Re: Deploy several stacks as an application to android

Post by gnor » Thu May 12, 2022 2:57 pm

Thanks Klaus!

So that means i have to check if the environment is mobile , then put the specialfolder stuff in there. Otherwise everything goes as is.

Thanks for your gteat help

Lot to do.

bwmilby
Posts: 438
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: Deploy several stacks as an application to android

Post by bwmilby » Thu May 12, 2022 3:29 pm

Should be able to use special folder path in either environment.
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Deploy several stacks as an application to android

Post by Klaus » Thu May 12, 2022 4:55 pm

Yep, as I wrote in my second posting:
...
Did you add these stacks via the "Copy files" tab in the "Standalone Application Settings..."?
If not, do so then you can access them in -> specialfolderpath("resources")

That specialfolder (resources) also works on the IDE, there it will point to the folder the current stack resides in,
So you can test everything also in the IDE.
...

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Deploy several stacks as an application to android

Post by jacque » Thu May 12, 2022 5:56 pm

You can avoid specialFolderPath when opening stacks if you set up the stackfiles in the mainstack. See "stackfiles" in the dictionary. In your case the path to the other stacks would be "/resources/otherstack.livecode"

To make this work in the IDE, create a folder named "resources" in the same folder as the mainstack and put all the extra stacks in there. In Copy Files in standalone settings, remove all the single stacks and include the resources folder instead.

After that you can refer to the extra stacks with only their short name in both the IDE and the standalone. As Klaus said, make sure capitalization matches in both the stackfiles and the scripts.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

stam
Posts: 2634
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Deploy several stacks as an application to android

Post by stam » Fri May 13, 2022 10:18 am

Thanks for the tip Jacque!

Can I ask though: on mobile this won't be an issue but on desktop how does this work for stacks that need to be in a writeable location?

My understanding is that many folders such as /Applications on MacOS are readonly and that stacks that need to be modified and saved can't be stored there. Does this not hold true for stacks within a folder inside the app folder or app bundle?

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Deploy several stacks as an application to android

Post by Klaus » Fri May 13, 2022 10:53 am

If you need to modify and save these external stacks, you need to copy them to the users documents folder on first launch of your app and open them from there. Same applies to the mobile platform!

On the Mac you could also use -> specialfolderpath("preferences") for this, we have write permissions there.
On Windows you can use -> specialfolderpath("support") which is the Win equvalent of above mentioned Mac preferences folder

Check the dictionary for more specialfolderpath() names.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Deploy several stacks as an application to android

Post by jacque » Fri May 13, 2022 5:33 pm

Can I ask though: on mobile this won't be an issue but on desktop how does this work for stacks that need to be in a writeable location?
The stackfiles is primarily for referencing stacks in a known location. If you copy stacks to a different location then you're back to using specialFolderPath, or alternately, set up the stackfiles to point to the location you will copy to. Then use specialFolderPath only to reference the original before copying.

Or, you can also change the stackfiles by script on the fly, though you'd need to do that every time the app launches since standalones can't be saved.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

stam
Posts: 2634
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Deploy several stacks as an application to android

Post by stam » Fri May 13, 2022 11:38 pm

Thanks Jacque,
I was just asking in case i'd missed a nice shortcut but probably not, it sounds like.

I hope you don't mind if i ask a slightly broader question on the topic:
In my current project i've taken a slightly different approach largely dictated by the large number of scriptOnlyStacks i've included and not sure if using stackFiles is the right way to go about it for at least some of these.

In brief:
I have scriptOnlyStacks that are static and part of the app (ie in a folder inside specialFolderPath("resources")).
I have scriptOnlyStacks that need to be in two different user-writeable locations on the end-user's system.

I am lazy and have put all the SoS into a single folder on my dev system and the IDE access them from there (mainly so it's easier to work on them in an external script editor - VSCode - where i can just open this folder and all SoS are available immediately) - so in total the app needs to reference stacks in 3 locations in the standalone, but only 1 in the IDE.
On the standalone's first run on the end-users system, the splash stack copies the files out to each of the user-writeable locations needed (if they don't already exist)

To aid with loading all these SoS, on startup i load a dedicated SoS (filepath is hardcoded to a folder inside specialFolderPath("resources")), with functions that returns a 'location' for each of these 3 "folders" depending on whether i'm in the IDE (where all files are in the same folder) or will return the correct destination folder on end-users system (3 folders) if running on a standalone and a handler to load these scriptOnlyStacks either as backscripts, behaviours or libraries.

I guess i could use stackFiles for the static scriptOnlyStacks. My current implementation does work really quite well as is, but i suppose doing this would reduce the length of code which may be a good thing in the long run. Or maybe not - perhaps debugging 2 years from now may be more straightforward if all the files are referenced in code instead of only half of them. Any views on this?

As i do edit these in VSCode, on returning to LC i have a handler than closes them all, removes them from memory and then reloads them to bring the edits in - i take it this should be doable for any stacks references in the stackFiles? Or will removing them from memory with the 'delete' command remove these from stackFiles?

Many thanks
Stam

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Deploy several stacks as an application to android

Post by jacque » Sat May 14, 2022 6:47 am

@stam, my first thought is that your system works, you're used to it, and it meets all your needs, so I don't see any reason to change it. Stackfiles are an optional shortcut. The purpose is only to make stack references shorter in your scripts so you don't have to keep typing full file paths, and since your paths change depending on the platform and target locations, it probably isn't worth it to rewrite things. Stackfiles are most useful when the referenced stacks always remain relative to the mainstack.

If you do want to try it, you might use stackfiles as a shortcut to the stacks stored with the standalone, or to the folder with all your script-only stacks, so you don't have to use specialFolderPath when using them in the IDE or when copying them elsewhere in a standalone. On the other hand, you've already got a working system so the typing is already done. It's really just a scripting convenience.

Stackfiles are a property of the stack, so they are permanent. Deleting a stack from memory won't change the stackfiles; they are stored like any other property. You can access the list in the stack's property inspector.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

gnor
Posts: 53
Joined: Fri May 08, 2020 10:32 pm

Re: Deploy several stacks as an application to android

Post by gnor » Thu May 19, 2022 9:59 am

Hello everyone !

There is one more problem i'm facing here.

I'm able to deploy my app to android now , followed your advises, but answer dialog shows a strange behavior.
I have the navigation between stacks as you suggested : go to stack (resources...etc) using the copy file option as you said in standalone settings.
In standalone settings a have clicked all inclusons for ask and answer dialogs as well...
I have not changed any of my scripts except the one related to navigations...
If i navigate from the deployed stack to another, on the new stack an answer dialog pops up, clicking "ok"
takes me back to the deployed stack.
Something i missed, what is it?
Thanks

gnor
Posts: 53
Joined: Fri May 08, 2020 10:32 pm

Re: Deploy several stacks as an application to android

Post by gnor » Thu May 19, 2022 2:23 pm

hello!

I m happy that i have found the solution: "start using this stack" needs to be in openstack handler in the deployable stack script, as you have mentioned earlier.
Thanks

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Deploy several stacks as an application to android

Post by Klaus » Thu May 19, 2022 2:44 pm

gnor wrote:
Thu May 19, 2022 2:23 pm
hello!
I m happy that i have found the solution: "start using this stack" needs to be in openstack handler in the deployable stack script, as you have mentioned earlier.
Thanks
Exactly! :-)

gnor
Posts: 53
Joined: Fri May 08, 2020 10:32 pm

Re: Deploy several stacks as an application to android

Post by gnor » Mon May 23, 2022 10:16 am

Hi everyone!

I'm writing this problem here, because might be related to the earlier posts...

I've changed everything in my project, according to the above posts in order to deploy to android.
I've checked everything in the ide and checked how it runs in android. Everything went well...
I have not changed anything in my scripts or elswhere since then, only next day open the stack as before in the ide, run it, and finally trying to navigate to another stack,
the following message pops up in every seconds:
"An error has occured in behavior for the column template: Cant find stack" even if i set my ide to development, still coming up every second.
this line in script editor of C:\Users\user\AppData\Roaming\RunRev\Components\LiveCode Community 9.6.3\Toolset\palettes\revdatagridlibrary\behaviorsdatagridbuttonbehavior.livecodescript

## Create
repeat for each line theColumn in pColumns

As i mentioned, since everything went fine, i have not touched anything. This morning i open the app, and that message goes and goes on.

Anybody has an idea why?

Thank you

Post Reply

Return to “Android Deployment”