We're going to make a copy of a stack, but only if another copy of that stack doesn't exist. LiveCode has a nice if there is a…
function, which was made for times like this!
First, we will create the stacks we'll need by following these steps:
LaunchStack
. Save it somewhere other than your computer's Documents
folder.AppStack
. Save it in the same folder as the first stack.LaunchStack
stack and name it in a way that makes it very easy to recognize. Do the same for the AppStack
stack.openStack
handler in the stack script of LaunchStack
:on openStack set the defaultFolder to specialFolderPath("Documents") if there is not a file "AppStack.livecode" then put the filename of this stack into masterfile set the itemdelimiter to "/" put "AppStack.livecode" into the last item of masterfile --put specialFolderPath("engine") & "/AppStack.livecode" into masterfile put specialFolderPath("Documents") & "/AppStack.livecode" into appfile put URL ("binfile:" & masterfile) into URL ("binfile:" & appfile) end if go stack specialFolderPath("Documents") & "/AppStack.livecode" answer the filename of this stack end openStack
Before trying the stacks on a device or in the simulator, we'll try them as desktop stacks by following these steps:
Documents
folder; there should not be an AppStack.livecode
file in this folder at the moment.LaunchStack.livecode
file. If you find that LiveCode doesn't launch this way, make sure that you have the associated .livecode
documents to be opened with LiveCode. If you are using more than one copy of LiveCode, say you're trying the Community version and the Commercial version, you can drag the stack file onto the copy of LiveCode that you're intending to use.Documents
folder; there now should be an AppStack.livecode
file with the time when the file was created that matches the current time.Documents
folder.Now, follow these steps to try our stacks on a mobile device or an iOS Simulator:
put specialFolderPath…
line from the LaunchStack
stack script that you entered in step 4.AppStack.livecode
stack (not the one that was created with the previous test).We set up our app to copy the main application stack in the documents area on the device, so that we'll be able to make changes and save those successfully. If you happen to test on iOS and Android, you will see quite different looking paths for the stack. LiveCode takes care of finding these special folders for us.
Check whether you just happen to know this or use this question as an excuse to read the release notes and dictionary! Which of these is not a specialFolderPath
type?
Answer: 1
The specialFolderPath
types Home
and Desktop
are not used by Android and Desktop
is not used by iOS. 0x000e
sounds suspicious, but is actually the specialFolderPath
entry for My Videos
under Unix! None of the systems have a Users
entry.