Getting File Path for external loaded stack

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dave_probertGA6e24
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 328
Joined: Mon Dec 05, 2011 5:34 pm
Contact:

Getting File Path for external loaded stack

Post by dave_probertGA6e24 » Thu Dec 19, 2013 8:04 am

Hi All,

Not really sure if the title actually means much!

Basically I'm doing a little personal App (for iOS on an iPad - locally loaded - NOT App Store) that will:
Ask for a filename
do a

Code: Select all

go URL "https://dl.dropbox.com/u/9999999/"&filename&".livecode" 
This then downloads the livecode file and runs it as a stack (substack maybe!). Local testing shows that the base 'loader' App is still there and the new 'external app' can be closed with a "close this stack" call without disturbing the main App.

This is so that I can develop simple tools and test them on the ipad without having to compile stuff or any such process. Just edit and save into my local dropbox folder and let it synch - then run the ipad app to load it.

All in all this works Very well. Been using it for a month now with no problems.


Now to the question/problem.

I would like to save a settings file (basic text) that I can load up next time I run the 'external' app.
But, when I ask for the effective filename of this stack (from within the external app) I get nothing. An empty string.
Also asking for just the filename produces nothing.
Also asking for the specialFolderPath("documents") gives nothing.
Actually all the path giving stuff I can think of produce nothing!!! Which is a bit difficult to use for the path to save a file to.

Has anyone else tried something similar? Has anyone got any ideas about how to get the path to a writable documents folder? Is the stack actually downloaded or just loaded into memory?

Has anyone done a similar remote 'livecode' file loader that also uses resources (images/sounds/etc).

Any hints/tips would be welcome at this point.

Cheers,
Dave
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Getting File Path for external loaded stack

Post by Klaus » Thu Dec 19, 2013 1:33 pm

Hi Dave,

yes, a stack that has been loaded over the net does NOT have any filename.
You need to save it to disk by yourself and whereever you like to (and are allowed to!)

This way it is also difficult to use any referenced media!
So I usually put everything into the stack.

But I don't understand this one:
Also asking for the specialFolderPath("documents") gives nothing.
"specialfolderpaths" are NOT stack specific in any way, if you mean that!?


Best

Klaus

dave_probertGA6e24
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 328
Joined: Mon Dec 05, 2011 5:34 pm
Contact:

Re: Getting File Path for external loaded stack

Post by dave_probertGA6e24 » Fri Dec 20, 2013 3:39 am

Hi Klaus,

Thanks for the info. I guess I'll modify the tool to actually copy the file to the device (into a temp location) and run it from there.

The test file I did was quite simple - it basically just created a string with a list of all the different types of path bits I could think of and dumped that string into a field - nothing more.

All the 'specialFolderPath' calls returned empty from within it. This file was the one loaded from the net.

I agree that the specialfolderpath should not be specific to a stack, but to the environment. But it still came back empty when called from the net-loaded stack. I guess it's a 'minor' bug - nothing that is likely to cause any major problems for anyone ;)

If I get this tool working nicely then I'll drop a copy up here for everyone to play with. It's kinda useful for collaborative design work too. One person creates the layout and then hands over the reigns to the coder - both can study the running state at any time without the need to load the IDE.

Anyway - thanks again.

Cheers,
Dave
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Getting File Path for external loaded stack

Post by Klaus » Fri Dec 20, 2013 1:14 pm

Hi Dave,

hm, just made a test, loaded a stack from the net, it had ONE button and ONE field:

Code: Select all

on mouseup
  put specialfolderpath("documents") into fld 1
end mouseup
After I clicked I saw the correct path to my docs folder in that namely field!
So this IS an environment thing and not a stack specific thing!

So what did you exactly try?


Best

Klaus

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Getting File Path for external loaded stack

Post by Mark » Fri Dec 20, 2013 1:44 pm

Dave,

When you download a stack from a server and then "go" to it, the stack exists in memory only and not on disk. That is why it doesn't have an (effective) filename.

You can use specialFolderPath("documents") to save files. If you need to know the exact location of the standalone app, you can use specialFolderPath("engine"). You might also add a handler to the standalone:

Code: Select all

global gStandaloneLocation
on startUp
  put the effective filename of me into gStandaloneLocation
  pass startUp
end startUp
After this handler runs, you can use gStandaloneLocation to get the effective filename. This should be the same as specialFolderPath("engine") & slash & the filename of this stack.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

dave_probertGA6e24
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 328
Joined: Mon Dec 05, 2011 5:34 pm
Contact:

Re: Getting File Path for external loaded stack

Post by dave_probertGA6e24 » Sat Dec 21, 2013 6:51 am

Hi Klaus and Mark,

Ok guys - I found the problem. I had used single quotes around the folderIdentifier - ie. specialFolderPath('documents'). Livecode does not complain about this but simply ignores the string and returns empty.

When using double-quotes - all is fine.

Yet another case of being caught out by my day job as a PHP programmer.

Thanks all,

Dave
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Getting File Path for external loaded stack

Post by Mark » Sat Dec 21, 2013 2:05 pm

Hi Dave,

Since you seem to be an experienced programmer, I think I should point out that the string isn't really ignored. with explicitVariables set to false, LiveCode interprets strings that aren't variables as... strings, even without quotes. If you use single quotes, those are simply considered part of the string. The string used as a parameter for the specialFolderPath function and LiveCode returns empty because LiveCode can't find a return value for this string, not because it would ignore the string.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: Getting File Path for external loaded stack

Post by William Jamieson » Mon Jan 25, 2016 7:59 am

Hey Dave, I know it has been a while since this post, but I figured it would be worth asking to see if you still have the iOS launcher stack. It sounds really convenient, as I borrow my friends apple pc just to test iOS apps.

Please let me know. Thanks!

-Will

Post Reply