Using local URLs

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Pebah
Posts: 23
Joined: Mon Aug 01, 2011 9:35 pm

Using local URLs

Post by Pebah » Mon Aug 15, 2011 8:39 pm

I'm trying to create URLs to picture files on the local hard drive. A Image folder exists inside the same folder as the stack. I'm finding the RunRev user guide to be inscrutable about designating the path to the file. Using "./Images/filename.png" doesn't work. Putting file into the same folder and using just "filename.png" doesn't work either. I tried the "binary:" thing also without success. I tried copying the URL in the Inspector for that image when it is displayed without luck either. Why is this so hard? Would it be too much to ask for a file browser palette that allows drag and drop creation of URLs?

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Using local URLs

Post by bangkok » Mon Aug 15, 2011 8:51 pm

This stack should help you.

-how to select a JPEG or GIF file from hard disk

-how to display it into an image object

-and therefore, how to deal with path
Attachments
SELIMAGE.zip
(938 Bytes) Downloaded 252 times

Pebah
Posts: 23
Joined: Mon Aug 01, 2011 9:35 pm

Re: Using local URLs

Post by Pebah » Mon Aug 15, 2011 11:14 pm

bangkok wrote:This stack should help you.

-how to select a JPEG or GIF file from hard disk

-how to display it into an image object

-and therefore, how to deal with path
Well, I had to disable part of the line that filtered the file type since it then greyed out all the possible images files in the file dialog:
answer file "Select a file " -- with filter "Web Graphics,*.jpg;*.gif;*.png"

Then it didn't show the relative file URL but the absolute URL (/Users/Peter/Projects/....icon.jpg). I'll keep working on this...

doc
Posts: 148
Joined: Fri Jun 09, 2006 4:30 pm

Re: Using local URLs

Post by doc » Tue Aug 16, 2011 2:30 am

Not for sure this is what you are looking for based on your description...
I've attached a zip file containing a stack that should properly display an image who's location in a sub folder is always relative to the location of the stack file or executable.

HTH,
-Doc-
Attachments
relative_image_path.zip
(4.56 KiB) Downloaded 253 times

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Using local URLs

Post by BvG » Tue Aug 16, 2011 5:08 am

for relative paths, you need to make sure the defaultfolder is set to what you want. this can be tricky, as it is different on mac os standalones (because bundles are folders). theres some additional paths that the engine automatically checks for stacks, but i think that does not apply to images. maybe the filename of the stack plays into it?
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Pebah
Posts: 23
Joined: Mon Aug 01, 2011 9:35 pm

Re: Using local URLs

Post by Pebah » Wed Aug 17, 2011 6:18 pm

doc wrote:Not for sure this is what you are looking for based on your description...
I've attached a zip file containing a stack that should properly display an image who's location in a sub folder is always relative to the location of the stack file or executable.

HTH,
-Doc-
That works!

"Effective filename" is the secret. Thanks!!!

Post Reply