How to get image from folder
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
How to get image from folder
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
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
Re: How to get image from folder
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: How to get image from folder
Welcome to the forum!
And please check these stacks to get started:
http://www.hyperactivesw.com/revscriptc ... ences.html

And please check these stacks to get started:
http://www.hyperactivesw.com/revscriptc ... ences.html
Re: How to get image from folder
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.
Re: How to get image from folder
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
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
Re: How to get image from folder
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.
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.

Re: How to get image from folder
Hi feelself,
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
Sorry but I think it does. The start of your problem is the path to your image.the lesson and tutorial is not about my question
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!
Re: How to get image from folder
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.
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.

Re: How to get image from folder
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
pathToImage would be what you are trying to construct above but
OK still not putting an image into a field, you will have to drag an image object onto your card (and call it "picture").
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
You are close but this may helpput "file://"&specialfolderpath("desktop") & "/doctor/" & the selectedtext of me & ".jpg" into fld "picture"
Code: Select all
set the fileName of image "picture" to pathToImage
Code: Select all
put "specialfolderpath("desktop") & "/doctor/" & the selectedtext of me & ".jpg" into pathToImage
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: How to get image from folder
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 ?
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 ?
Re: How to get image from folder
The only way I know is "imageSource".
You'll need some text in the field.
Simon
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!
Re: How to get image from folder
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. will put the image of that jpg file into the image area on your card.
Does that make sense?
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"
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/
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/
Re: How to get image from folder
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 ?
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 ?

Re: How to get image from folder
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
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
Best
Klaus
"Clearvoyance" is already on the TO-DO list

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

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
Klaus
Re: How to get image from folder
Hi Klaus:
Sorry for late reply, Thank u so much.
Seems better now.
Sorry for late reply, Thank u so much.
Seems better now.