Page 1 of 1

How can i save the workflow in stendalone application?

Posted: Mon Nov 09, 2020 7:15 pm
by SEAL29
I tried>

Code: Select all

save stack "Database" as "/Volumes/Data/Database.livecode"

Code: Select all

save this stack
does not work, does not save changes.

Re: How can i save the workflow in stendalone application?

Posted: Mon Nov 09, 2020 7:18 pm
by dunbarx
Hi.

You don't have the executable as the stack you are trying to change, right?

Craig

Re: How can i save the workflow in stendalone application?

Posted: Mon Nov 09, 2020 7:24 pm
by SEAL29
Database is the stendalone application name.
The Database.livecode is what I made of stendalone application.

Re: How can i save the workflow in stendalone application?

Posted: Mon Nov 09, 2020 7:37 pm
by SEAL29
What script can I use to save the workflow in stendalone application?

Re: How can i save the workflow in stendalone application?

Posted: Mon Nov 09, 2020 7:58 pm
by FourthWorld
The User Guide reminds us that OSes prevent an executable from modifying itself (p513), with guidance on saving stack files separately from the executable:
Note: A stack file directly attached to a standalone application cannot have changes saved
to it. This stack is bound directly to the executable file that runs. The OS locks an
executable file while it is running. If you want to save changes in your standalone
application, split your stack up until multiple files. A common technique is to create a
"splash screen" stack that contains a welcome screen and then loads the stacks that make
up the rest of your application. These stacks are referenced as stackFiles on this pane in
the standalone settings screen. It is thus possible to automatically update these
component stacks, or to save changes to them. You may also want to consider creating
preference files in the appropriate location on your end user's system (see the
specialFolderPath function and query/setRegistry functions for more information).

Re: How can i save the workflow in stendalone application?

Posted: Mon Nov 09, 2020 8:58 pm
by dunbarx
Aha.

To make the User Guide simpler to understand, when you make your standalone, make the executable stack the frontStack. I believe you already do this.

There is a "Stacks" pane in the "Standalone Application Settings" in the "File" menu. Form there you attach one or more stacks to the executable stack. Then when you actually make the standalone, those "working" stacks can all be saved. You can also attach files in the "Copy Files" pane, and set your inclusions, which I recommend you do individually.

Craig

Re: How can i save the workflow in stendalone application?

Posted: Tue Nov 10, 2020 4:45 pm
by SEAL29
I don't understand this, i followed this description https://livecode.fandom.com/wiki/Standa ... n_Settings but i don't know how to save the changes. Why need a standalone application if you can't save in it?

Re: How can i save the workflow in stendalone application?

Posted: Tue Nov 10, 2020 5:29 pm
by FourthWorld
All operating systems prevent executables from modifying themselves.

So maybe the better question might be: how do applications save data?

We see that they save data to a variety of special folders, depending on what the data is, such prefs files, documents, and other application data.

LiveCode provides a function for getting the paths to the most commonly used folders, specialFolderPath. You can use that to clone your stack file on first launch, and open that for subsequent runs.

But you may also want to separate data from the user interface. This allows you to update the interface without altering the user's data.

There are many approaches possible, and the best one for your app will depend on the nature of your app. Can you tell us a bit about what it does?

Re: How can i save the workflow in stendalone application?

Posted: Tue Nov 10, 2020 5:49 pm
by SEAL29
This is a database of my movies and tv series with pictures and some text fields like Title, cast, etc.

Re: How can i save the workflow in stendalone application?

Posted: Tue Nov 10, 2020 8:36 pm
by dunbarx
Create, name and save two new stacks. Stack 1 will be the "splash" stack, that is, the executable which you cannot modify. Stack 2 will be your "working" stack.

Put some sort of simple handler in a button on stack 2, for example one that puts a random number into a field. In the stack script of stack 2, put something like this:

Code: Select all

on closeStackRequest
      save this stack
      pass closeStackRequest
end closeStackRequest
You can easily automate navigation to Stack 2, for example in the stack 1 card script, perhaps:

Code: Select all

on preOpenCard
      get specialFolderPath("documents") & "/" & "yourWorkingStack" & ".livecode"
      go stack it
end preOpenCard

or simply:

on opencard
   go stack "yourWorkingStack"
  close stack "yourSplashStack"
end opencard
Save everything.

With Stack 1 in front, in the standalone settings "Stacks" pane, click the "Add Stack File..." button and attach the Stack 2 stack file. Now make the standalone. Run the standalone by placing a random number into the field, and remember it. Quit the standalone. now re-open the standalone. You will see the new number in the field.

Not tested, but the general ideas should be OK. The working stack can have subStacks, and there is no limit to the number of stack files you can attach to stack 1.

Craig

Re: How can i save the workflow in stendalone application?

Posted: Tue Nov 10, 2020 9:24 pm
by SEAL29
Thanks. Now work with "splash" stack. Thanks for description.

Re: How can i save the workflow in stendalone application?

Posted: Tue Nov 10, 2020 11:12 pm
by dunbarx
Make the experiment. Get it to work at the basic level. Then get fancy.

Craig