Page 1 of 1

Is there a way to load a local image file?

Posted: Mon Mar 21, 2016 4:43 am
by keithglong
Hi All,

I have just started to experiment with HTML5 in LiveCode and have a quick question. When I save my test stack as an HTML5 standalone, and run it from the output folder on my computer, all works well.

Is there a way to load an image file (i.e., that's located locally in the same output folder as the standalone) into a variable? I can't seem to get access to files in the folder. (Perhaps it is not even possible, but I just thought I would ask.)

Thanks,

- Boo
Gulf Breeze, Florida

Re: Is there a way to load a local image file?

Posted: Mon Mar 21, 2016 5:16 am
by keithglong
Hi Again,

I presume LiveCode HTML5 apps only have access to the /boot/standalone folder?

- Boo

Re: Is there a way to load a local image file?

Posted: Mon Mar 21, 2016 7:50 am
by [-hh]
Yes.
In the Standalone Application Settings" you have a tab "Copy Files" for that.
That "added" file and folder structure is put into /boot/standalone/.
You can use that just as a usual filesystem, it is one, a virtual one within the zip! (Call the "full Path" when setting filename of an image or set first the defaultfolder and use the file's name only.)

I have a demo called "Copy Files" for that in my standalones "experiments".
Both "GIFCinema"- experiments contain moreover a "File-Browser" for browsing the whole virtual filesystem (use button "SetFile..." there), substituting in some sense "answer file".

Of course you can also use the revzip-library for adding files to the standalone.zip without recompiling (if you know what you're doing, what is the case with you, I presume).

Re: Is there a way to load a local image file?

Posted: Mon Mar 21, 2016 1:27 pm
by keithglong
Hi -hh,

Thanks for your prompt reply. Yep, I was aware of that, but I was hoping for a solution by which users could select an image on their own systems. (Not images distributed with the app.)

Yesterday I checked out some of your examples, including "GifCinema." Nice work; nice work indeed. (Thanks for sharing.)

Because LiveCode HTML5 is still evolving, I wonder if we will eventually have the ability to select files on the local system? I do know that due to security reasons that might not be the case, but I think I have seen HTML5 apps that allow users to select files (as long as the users have to physically "click" to select them). If eventually possible, the files could then be added to the /boot/standalone folder (which is essentially a sandbox).

Thanks,

- Boo
Gulf Breeze, Florida

Re: Is there a way to load a local image file?

Posted: Mon Mar 21, 2016 2:40 pm
by FourthWorld
keithglong wrote:Because LiveCode HTML5 is still evolving, I wonder if we will eventually have the ability to select files on the local system? I do know that due to security reasons that might not be the case, but I think I have seen HTML5 apps that allow users to select files (as long as the users have to physically "click" to select them). If eventually possible, the files could then be added to the /boot/standalone folder (which is essentially a sandbox).
HTML provides an input type of "file" which does what you describe. The challenge here is that LiveCode stacks running in the converted-to-JavaScript LC engine when using the HTML5 export option aren't HTML per se, but remain in a LiveCode-specific format. Effectively the output is a JavaScript version of the LC engine working on its binary stacks files pretty much as it does in standalones.

This allows most LiveCode scripts to work well, but it also means that browser-native things like HTML form elements exist outside of what the LiveCode-engine-as-JavaScript can currently handle, since the LC engine only works on LC objects.

At some point I'd guess they'll need to enhance the exporter to substitute raw HTML for some elements of a converted stack, so we can better integrate stacks with browser-native features like this one.

I'm not sure how or when that'll happen, though.

Re: Is there a way to load a local image file?

Posted: Mon Mar 21, 2016 2:47 pm
by keithglong
Thanks Richard and -hh.

- Boo

Re: Is there a way to load a local image file?

Posted: Mon Mar 21, 2016 3:19 pm
by [-hh]
You effectively want/need the "URL"-syntax,
no matter if file ("Text") or binfile ("image"),
which is in turn based on "waiting":
Not (yet) implemented.
Peter wrote a lot to that in other posts (mainly use-list).

Re: Is there a way to load a local image file?

Posted: Mon Mar 21, 2016 3:29 pm
by keithglong
Hi -hh,

Yeppers, I believe I read some of that. However, I am working locally (i.e., the files are on my computer, not on a Web server). I am experimenting locally because I have a project that will require such. Perhaps even using url/binfile to save a file locally entails "wait," albeit it would not be much of a wait.

Thanks again,

- Boo

Re: Is there a way to load a local image file?

Posted: Mon Mar 21, 2016 3:40 pm
by [-hh]
Hi -Boo,
your standalone is running in a web-browser (it needs, when using Chrome or Opera, also a local webserver running). What is "local" or not is a decision of the browser/webserver and for accessing that decision Peter needs, as far as I understand, native JS (and kind of "wait").

Currently (as of < 8.0.0-rc1), TMHO, the one and only way to communicate with the HTML5 standalone is the "Ask"-Dialog.

Hermann

Re: Is there a way to load a local image file?

Posted: Mon Mar 21, 2016 3:52 pm
by keithglong
Gotcha; thanks Hermann.

- Boo