SAVING DATA TO STANDALONE APPLICATION ISSUE

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
JLGMD1
Posts: 4
Joined: Mon Aug 12, 2024 12:03 am

SAVING DATA TO STANDALONE APPLICATION ISSUE

Post by JLGMD1 » Mon Aug 12, 2024 12:43 am

Two stacks
BEAKEREXPEDITESLAUNCH4 (splash stack)
BEAKEREXPEDITES3 (main app)

Tried the splash card method using a button with the script below to launch the main app in the stand alone application. The stand alone app builds without an issue. New data that is entered in fields in the main app are not saved on CloseStack in the standalone app.

Button script in BEAKEREXPEDITESLAUNCH4 (splash stack)
on mouseUp
set the itemDelimiter to "/"
if the environment is "standalone application" then
get the effective fileName of this stack
set the defaultFolder to item 1 to -2 of it
if there is a stack "BEAKEREXPEDITES3" then
open stack "BEAKEREXPEDITES3"
close stack "BEAKEREXPEDITESLAUNCH4"
else
answer warning "stack " & the defaultFolder & "BEAKEREXPEDITES3 not found"
end if
else
get the effective fileName of this stack
set the defaultFolder to item 1 to -2 of it
open stack "BEAKEREXPEDITES3"
go to stack "BEAKEREXPEDITES"
close stack "BEAKEREXPEDITESLAUNCH4"
end if
end mouseUp

The main app (BEAKEREXPEDITES3) script contains

On CloseStack
Save this stack
Pass CloseStack
End CloseStack

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9951
Joined: Wed May 06, 2009 2:28 pm

Re: SAVING DATA TO STANDALONE APPLICATION ISSUE

Post by dunbarx » Mon Aug 12, 2024 5:01 am

Hi,

Is the "splash stack" in its own stack file? And is the "main" stack in its own stack file as well? And now is the main stack then attached to the splash stack via the "Standalone Settings" of the splash stack?

Please let us know...

Craig

SparkOut
Posts: 2887
Joined: Sun Sep 23, 2007 4:58 pm

Re: SAVING DATA TO STANDALONE APPLICATION ISSUE

Post by SparkOut » Mon Aug 12, 2024 7:33 am

What platform are you running the standalone on? Where is it placed? There are lots of locations where write permissions will not normally be available as standard.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7303
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: SAVING DATA TO STANDALONE APPLICATION ISSUE

Post by jacque » Mon Aug 12, 2024 5:51 pm

Mac app bundles cannot save to themselves. To save the main stack it has to be moved out of the bundle and into a writeable location like the documents folder or the app support folder. Apple prefers the app support folder.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

JLGMD1
Posts: 4
Joined: Mon Aug 12, 2024 12:03 am

Re: SAVING DATA TO STANDALONE APPLICATION ISSUE

Post by JLGMD1 » Wed Aug 14, 2024 1:06 am

Thanks. The issue seems to be on the Mac only. The Windows standalone app build works well and new data is saved to the data stack. However, it is not working on the Mac OS. How do I move it from the bundle to the Apple support folder?

JLGMD1
Posts: 4
Joined: Mon Aug 12, 2024 12:03 am

Re: SAVING DATA TO STANDALONE APPLICATION ISSUE

Post by JLGMD1 » Wed Aug 14, 2024 1:13 am

Hi,

Is the "splash stack" in its own stack file? And is the "main" stack in its own stack file as well? And now is the main stack then attached to the splash stack via the "Standalone Settings" of the splash stack?

Please let us know...

Craig

Yes both the "splash stack" and the "main" stack are separate stack files and the "main" stack is attached to the "splash stack" in the "Stand Alone" settings. The issue seems to be on the Mac only. The Windows standalone app build works well and new data is saved to the data stack. However, it is not working on the Mac OS. Another reply to my post stated that I should move the "main" stack to the Apple support folder and out of the bundle. - Jorge

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7303
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: SAVING DATA TO STANDALONE APPLICATION ISSUE

Post by jacque » Wed Aug 14, 2024 9:32 pm

JLGMD1 wrote:
Wed Aug 14, 2024 1:06 am
Thanks. The issue seems to be on the Mac only. The Windows standalone app build works well and new data is saved to the data stack. However, it is not working on the Mac OS. How do I move it from the bundle to the Apple support folder?
The main stack in the bundle would only be used as a resource on first launch. After it is moved to the support folder, the copy is where the app should read and write to the stack. So you need to check if the copy exists when the standalone is launched, and do the copying if the file isn't there.

From the top of my head, untested:

Code: Select all

on openStack -- in the script of card 1 of the splash stack
  put specialFolderPath("support") & "/main.livecode" into tMainStack
  if there is no file tMainStack then
    put url ("binfile:" & specialFolderPath("resources" & "/main.livecode") into url ("binfile:" & tMainStack)  
  end if
  -- any other commands
end openStack
If you like, you can set a global variable to the new file path so you don't have to recreate the path every time you need to access the copy, but it's up to you. Also, Apple prefers that you create a folder inside the support folder, named for your app, and place app-specific files inside that folder. It isn't required, but if you want to do that then add a "create folder" command to the above and change the file path to include the new folder name.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

JLGMD1
Posts: 4
Joined: Mon Aug 12, 2024 12:03 am

Re: SAVING DATA TO STANDALONE APPLICATION ISSUE

Post by JLGMD1 » Wed Aug 14, 2024 11:28 pm

Perfect. Thank you.

Post Reply

Return to “Mac OS”