Open a LC document using a standalone

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

Re: Open a LC document using a standalone

Post by Klaus » Wed May 09, 2018 1:18 pm

jmburnod wrote:
Wed May 09, 2018 1:07 pm
Hi Klaus,
I'm a little confused about copy files tab where I can read:
non-stack files in the application
Kind regards
Jean-Marc
Doesn't matter, also works with Livecode files. :-)

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

Re: Open a LC document using a standalone

Post by jacque » Wed May 09, 2018 9:25 pm

maxs wrote:
Wed May 09, 2018 1:00 am
Hi Klaus,

Yes, This is how I originally had it. The stack.livecode ("Testb") was included in the Splash.livecode ("Testa") via the "Copy files" tab , before making the standalone

So the Splash.livecode standalone would create a stack.livecode in the documents folder that was completely empty.

The url("binfile:...) into url ("binfile:...) only made an empty copy of a file.

SO why doesn't the work? Why is the file empty? Did you see may examples files. It seems I followed your directions completely but the file is still empty.
Densely yours, Max
Most likely the file paths are incorrect, as Richard noted. It sounds like you have the setup correct:

StackA will be the standalone, with all standalone options filled out in Standalone Settings.
StackB is the data stack to be included with the build. It is listed in the Copy Files pane of Standalone Settings.

When LC builds the standalone, anything in Copy Files is put into a folder named "resources" which the standalone builder creates. The correct path to that folder and its file is: specialFolderPath("resources") & "/stackB.livecode"

Since files can't be saved inside the application folder, you need to copy StackB to a writeable location. That can be the desktop ("specialFolderPath("desktop")) or documents, or some other places. Let's assume you want it to go to Documents: specialFolderPath("documents")

So the copy mechanism is:

Code: Select all

put specialFolderPath("resources") & "/stackB.livecode" into tSourcePath
put specialFolderPath("documents") & "/stackB.livecode" into tDestPath
put ("binfile:" & tSourcePath) into ("binfile:" & tDestPath)
Note that special folder paths are lower-case, and the whole path structure must be inside parentheses so it will evaluate correctly.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Re: Open a LC document using a standalone

Post by maxs » Thu May 10, 2018 12:14 am

Hi Jacque

I'm so impressed with myself that I came to the same conclusion today. It may be an incorrect path or name. Now I will try testing it out. Thanks, Max

Max

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Re: Open a LC document using a standalone

Post by maxs » Thu May 10, 2018 1:29 am

Breakthrough:

I did it.

Here are the 4 major errors I made:

The resource file name needed to be the same as the document file name. (I had the Standalone file as the app resource name. I never understood that they are basically the same file. )
There were uppercase letters.
I needed to delete ".livecode" from the file name of the embedded resource stack.
I could not find any documentation on this in the Livecode library.

Thanks to Jacque and Klaus for following through with me. This was really a difficult process for me to understand.

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Re: Open a LC document using a standalone

Post by maxs » Thu May 10, 2018 1:39 am

postscript

THe forums have become the basic lifesaver for my most urgent problems I have making app, thanks to a few really kind people.

Nevertheless, it is insanely difficult to get clarifications of things when communication is not back and forth as easily as it is with talking or chatting.

I would gladly pay for the instant gratification of instant communication, if that ever became available. But I can understand why people giving help prefer it this way.

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

Re: Open a LC document using a standalone

Post by jacque » Thu May 10, 2018 6:22 am

Bravo! So glad you got it working. When you're first starting there's a lot to learn, but soon things will feel commonplace. The "eureka" moment at the end of a long struggle can be a giddy reward though.

One advantage of written explanations is that others who follow can find answers. But I do understand that it's often easier to talk through issues where clarifications can be more immediate. Many of the old-timers here would probably be available for consulting work if it comes to that.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Open a LC document using a standalone

Post by jacque » Thu May 10, 2018 5:44 pm

You know, looking at my example script I see that I omitted the URL keyword. Did it work as written? It should have been:

put url ("binfile:" & tSourcePath) into url ("binfile:" & tDestPath)

We all have blackouts occasionally I guess. You can't trust anyone these days. :)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Re: Open a LC document using a standalone

Post by maxs » Mon Aug 24, 2020 11:15 pm

It looks like I had the exact same problem 2 years ago. How do I open an editable LC document using a standalone on a Mac?

Im still lost. Copying it into the Standalone renders in uneditable.

Any ideas? Max

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

Re: Open a LC document using a standalone

Post by Klaus » Tue Aug 25, 2020 10:45 am

Everything here in this thread is still valid, so what is your problem exactly?
Basically you do:

Code: Select all

...
put specialFolderPath("resources") & "/stackB.livecode" into tSourcePath
put specialFolderPath("documents") & "/stackB.livecode" into tDestPath

## Check fi stack is already present:
if there is not a file tDestPath then
   put URL("binfile:" & tSourcePath) into URL("binfile:" & tDestPath)
end if

## This is the important line, we have to open THIS stack of course:
GO STACK tDestPath
...

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Re: Open a LC document using a standalone

Post by maxs » Tue Aug 25, 2020 5:23 pm

Hi Klaus,

I used "copy files" to add the stack to the standalone, and I included the code you recommended to the openstack handler, changing the name to "Open Workshop". (Stand Alone stack name)

It opened a copy of this stack that has no icon images, and when I reopen the stack, it does not save any text I typed into a field. (If I copy the stack to Stack: Stack files in the application", then the stack opens with the icons displayed. )

--put specialFolderPath("resources") & "/Open Workshop.livecode" into tSourcePath
--put specialFolderPath("documents") & "/Open Workshop.livecode" into tDestPath
I also tried it with
put specialFolderPath("documents") & "/Spolin Workshop.livecode" into tDestPath. with the same results.

Any ideas?
Also, this issue is extremely important to me. I'm sorry to burden you with this. Let me know if I should look elsewhere for help. My best Max

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

Re: Open a LC document using a standalone

Post by jacque » Wed Aug 26, 2020 7:07 pm

You can't save changes to the standalone, only to other stacks the standalone opens. So the name of the stack you copy to the documents folder must be the name of the stack you included in Copy Files.

Basically, any standalone, including all the files saved with it, can't be altered. But copying a mainstack out of the standalone bundle to a writeable location like Documents will allow it to be saved.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Re: Open a LC document using a standalone

Post by maxs » Wed Aug 26, 2020 8:37 pm

HI Jacque,

Thanks so much for helping out here.

Yes, I have a stack outside the standalone that the standalone can open. Yes, I copied the stack to pre-standalone version using copy files.

The standalone will open the stack, but not allow me to save any changes to that stack. So I am sure I am doing something wrong.

Max

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

Re: Open a LC document using a standalone

Post by jacque » Wed Aug 26, 2020 9:21 pm

How are you saving the stack? It might be useful to see the script that does that.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Open a LC document using a standalone

Post by SparkOut » Wed Aug 26, 2020 9:43 pm

Just to be clear, when you set the standalone builder settings to include the separate stack with the "copy files" tab, that separate stack gets included as part of the standalone bundle. You can open the file from the relative location in specialFolderPath("resources"). Very often, you will find the typical install location of a standalone is not writable.
So having bundled your stack with the standalone for deployment, you would need to ensure that it is copied from "resources" to a writable location, such as "documents" or other application data/preferences folder. You can check on first run whether the file exists in that location, and only copy if it doesn't, so that you don't overwrite previously saved data.
So forgive me if I am suggesting what you have already done, but I don't see any explicit indication above that you have made this copy of the stack to a writable location, and it could be the (relatively) simple answer. Or not :)

maxs
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 421
Joined: Sat Jun 24, 2006 12:02 am
Contact:

Re: Open a LC document using a standalone

Post by maxs » Wed Aug 26, 2020 11:55 pm

Hi SparkOut,

Ok I made sure the livecode document was in the "documents" folder, and that I included it in the standalone using "Copy Files" .

So I made the standalone and now the standalone will open but the stack with all the icons missing and new text in text files will not save when the stack is reopened. It may have to do with the possibly incorrect code below. I have no idea what this code means. (binfile, URL,). Max :cry:

on Openstack
--open stack "Spolin Workshop.livecode"
put specialFolderPath("resources") & "/Spolin Workshop.livecode" into tSourcePath
put specialFolderPath("documents") & "/Spolin Workshop.livecode" into tDestPath

## Check if stack is already present:
if there is not a file tDestPath then
put URL("binfile:" & tSourcePath) into URL("binfile:" & tDestPath)
end if

## This is the important line, we have to open THIS stack of course:
GO STACK tDestPath
end Openstack

Post Reply

Return to “Talking LiveCode”