How to get image from folder

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
feelself
Posts: 8
Joined: Wed Aug 28, 2013 9:11 am

How to get image from folder

Post by feelself » Fri Nov 08, 2013 4:57 am

Anyone knows how to get image from folder, i totally new for this software, and i have refer to internet to use

put "file://"&specialfolderpath("desktop") & "/doctor/" & the selectedtext of me & ".jpg" into fld "picture"

but only can see the
file:///Users/student/Desktop/doctor/Jack .jpg in my field instead of picture.

Can someone give me a hint, thanks

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: How to get image from folder

Post by Simon » Fri Nov 08, 2013 6:27 am

Here is part 1 of the lesson.
http://lessons.runrev.com/s/lessons/m/4 ... ers-part-1

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

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

Re: How to get image from folder

Post by Klaus » Fri Nov 08, 2013 12:43 pm

Welcome to the forum! :D

And please check these stacks to get started:
http://www.hyperactivesw.com/revscriptc ... ences.html

feelself
Posts: 8
Joined: Wed Aug 28, 2013 9:11 am

Re: How to get image from folder

Post by feelself » Fri Nov 08, 2013 7:13 pm

Thank simon and klaus, but the lesson and tutorial is not about my question. Seems cannot solve it. :(
Last edited by feelself on Wed Nov 13, 2013 5:43 am, edited 2 times in total.

jsburnett
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 121
Joined: Fri Mar 09, 2007 9:47 pm

Re: How to get image from folder

Post by jsburnett » Mon Nov 11, 2013 9:16 pm

feelself,

I'm not trying to be a know-it-all, but I've had the same issues and frustrations.

What I've found helpful is to actually follow a script and see what information is given and in what format for example the "defaultfolder" - assign that to a variable and either 'put' the variable into the message box or a field or view it after setting a breakpoint in the script. You might be surprised at how this may help you see a format issue, or sometimes livecode has trouble 'executing' your instructions in a single step, and you may have to breakup your line of code into more than one line (see 'do' in the dictionary)

Your on the right track, but I see obvious issues with trying to put an image (.jpg, .png) etc in a text field - and certainly reviewing some to the examples in the lessons, or as I have suggested, breaking down each step, 'watch it work step by step' by inserting a breakpoint in your script, and reviewing the dictionary (ie, type in 'image' into the dictionary - and just read a few of the search results to see if your on the right track..) or the "users guide" may be helpful.

This is an old post, so you've probable solved the issue by now, but I hope this helps. Let me know if does.
John

feelself
Posts: 8
Joined: Wed Aug 28, 2013 9:11 am

Re: How to get image from folder

Post by feelself » Wed Nov 13, 2013 5:38 am

Thanks, John.
It's very appreciate for you to help me in this issue. But May be i still too fresh in this coding software. i don't know how to set the picture folder into variable, and also i haven't found any useful information in dictionary when i browse the "image".
I think i need to read the tutorial about the image first. :D

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: How to get image from folder

Post by Simon » Wed Nov 13, 2013 6:01 am

Hi feelself,
the lesson and tutorial is not about my question
Sorry but I think it does. The start of your problem is the path to your image.

Only the start, using a field for an image can be done but not what you want. I'm thinking you want an image to be displayed?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

feelself
Posts: 8
Joined: Wed Aug 28, 2013 9:11 am

Re: How to get image from folder

Post by feelself » Thu Nov 14, 2013 2:49 am

Hi Simon
Sorry, may be i haven't explained my question in a proper way, yes, i want the picture in the selected folder to be displayed in the field. :D

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: How to get image from folder

Post by Simon » Thu Nov 14, 2013 2:54 am

Ok just one more time...
You want an image in a field?
Normally one wants it in an image object.

Just wanted to check I had it right.

The lesson I posted shows how to select the correct folder to select the image.

Simon
Edit: OK let me add more information
put "file://"&specialfolderpath("desktop") & "/doctor/" & the selectedtext of me & ".jpg" into fld "picture"
You are close but this may help

Code: Select all

set the fileName of image "picture" to pathToImage
pathToImage would be what you are trying to construct above but

Code: Select all

put "specialfolderpath("desktop") & "/doctor/" & the selectedtext of me & ".jpg" into pathToImage 
OK still not putting an image into a field, you will have to drag an image object onto your card (and call it "picture").
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

feelself
Posts: 8
Joined: Wed Aug 28, 2013 9:11 am

Re: How to get image from folder

Post by feelself » Thu Nov 14, 2013 3:59 am

Hi Simon
Thanks for your reply.
Ya. i wanted to display the image into the field
Is it possible to have the image display in the field without dragging the image object into the card ?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: How to get image from folder

Post by Simon » Thu Nov 14, 2013 4:05 am

The only way I know is "imageSource".
You'll need some text in the field.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Newbie4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 332
Joined: Sun Apr 15, 2012 1:17 am
Contact:

Re: How to get image from folder

Post by Newbie4 » Thu Nov 14, 2013 5:18 am

I think that you are getting confused by the different types of fields. Normally you put text into a text field and images into an image field ("image area")
Instead of using a text field, drag an "image Area" from the tool palette.

That image area has a number of properties which you can find in the Dictionary. (Open up the dictionary and click on the image icon in the left column to see all the properties of it.) The one you are interested in is the property - "filename". You want to set that property to your image's filename/location

if you have a balloon jpeg that you want to show up in your field - image "myPicture"
e.g.

Code: Select all

set the filename of image "myPicture" to "/Users/admin/desktop/doctor/balloon.jpeg"
will put the image of that jpg file into the image area on your card.

Does that make sense?
Cyril Pruszko
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/

feelself
Posts: 8
Joined: Wed Aug 28, 2013 9:11 am

Re: How to get image from folder

Post by feelself » Thu Nov 14, 2013 6:49 am

Hello Newbie4
It comes that i have got wrong fields, thanks for your suggestions. But can i combined the scrolling list field with the picture display, this mean when i choose the people in the list, the picture area will show his/her image.
I have tried to use the command "selectedtext of me" but cannot see the image, any idea of this ? :D

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

Re: How to get image from folder

Post by Klaus » Thu Nov 14, 2013 12:45 pm

Please post the script(s) that you tried so far, we need more info to be able to help you!
"Clearvoyance" is already on the TO-DO list 8)

What I understood so far:
1. You have a "list field" with some names in it
2. When the user clicks a line, you want to display the corresponding image from a folder
Correct so far?

Question:
Did you already create an IMAGE object that will display your image?
That is of course mandatory!

If yes, then this script in the list field will do the trick:
"userimage" is the name of the image I use in this example, you will need to replace it with
the name of YOUR image that is supposed to display the image corresponding to the "clicked" name 8)

Code: Select all

on mouseup
  put the selectedtext of me into tName
  ## I may be super (too) cautious, but old habits... :-D
  if tName <> EMPTY then
     set the filename of img "userimage" to (specialfolderpath("desktop") & "/doctor/" & tName & ".jpg")
  end if
end mouseup
Best

Klaus

feelself
Posts: 8
Joined: Wed Aug 28, 2013 9:11 am

Re: How to get image from folder

Post by feelself » Thu Nov 21, 2013 4:32 am

Hi Klaus:
Sorry for late reply, Thank u so much.
Seems better now.

Post Reply