Page 1 of 1

SAVING DATA TO STANDALONE APPLICATION ISSUE

Posted: Mon Aug 12, 2024 12:43 am
by JLGMD1
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

Re: SAVING DATA TO STANDALONE APPLICATION ISSUE

Posted: Mon Aug 12, 2024 5:01 am
by dunbarx
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

Re: SAVING DATA TO STANDALONE APPLICATION ISSUE

Posted: Mon Aug 12, 2024 7:33 am
by SparkOut
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.

Re: SAVING DATA TO STANDALONE APPLICATION ISSUE

Posted: Mon Aug 12, 2024 5:51 pm
by jacque
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.

Re: SAVING DATA TO STANDALONE APPLICATION ISSUE

Posted: Wed Aug 14, 2024 1:06 am
by JLGMD1
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?

Re: SAVING DATA TO STANDALONE APPLICATION ISSUE

Posted: Wed Aug 14, 2024 1:13 am
by JLGMD1
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

Re: SAVING DATA TO STANDALONE APPLICATION ISSUE

Posted: Wed Aug 14, 2024 9:32 pm
by jacque
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.

Re: SAVING DATA TO STANDALONE APPLICATION ISSUE

Posted: Wed Aug 14, 2024 11:28 pm
by JLGMD1
Perfect. Thank you.