Is there a way to load a local image file?

Bringing your stacks to the web

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
keithglong
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 345
Joined: Sun Jul 03, 2011 2:04 am
Location: Gulf Breeze, Florida

Is there a way to load a local image file?

Post by keithglong » Mon Mar 21, 2016 4:43 am

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

keithglong
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 345
Joined: Sun Jul 03, 2011 2:04 am
Location: Gulf Breeze, Florida

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

Post by keithglong » Mon Mar 21, 2016 5:16 am

Hi Again,

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

- Boo

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1682
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

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

Post by [-hh] » Mon Mar 21, 2016 7:50 am

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).
shiftLock happens

keithglong
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 345
Joined: Sun Jul 03, 2011 2:04 am
Location: Gulf Breeze, Florida

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

Post by keithglong » Mon Mar 21, 2016 1:27 pm

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5938
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

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

Post by FourthWorld » Mon Mar 21, 2016 2:40 pm

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.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

keithglong
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 345
Joined: Sun Jul 03, 2011 2:04 am
Location: Gulf Breeze, Florida

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

Post by keithglong » Mon Mar 21, 2016 2:47 pm

Thanks Richard and -hh.

- Boo

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1682
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

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

Post by [-hh] » Mon Mar 21, 2016 3:19 pm

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).
shiftLock happens

keithglong
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 345
Joined: Sun Jul 03, 2011 2:04 am
Location: Gulf Breeze, Florida

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

Post by keithglong » Mon Mar 21, 2016 3:29 pm

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

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1682
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

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

Post by [-hh] » Mon Mar 21, 2016 3:40 pm

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
shiftLock happens

keithglong
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 345
Joined: Sun Jul 03, 2011 2:04 am
Location: Gulf Breeze, Florida

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

Post by keithglong » Mon Mar 21, 2016 3:52 pm

Gotcha; thanks Hermann.

- Boo

Post Reply

Return to “HTML5”