Page 1 of 1
Retrieving a List of Image Names in the Stack
Posted: Wed Jan 06, 2016 1:12 am
by deeverd
Hello Forum,
No doubt my question is a very basic one, but it's something I've wasted some hours on and don't know how to do...
How does one retrieve a list of the names of all image files that have been imported into a stack, and place that list of image file names into a field?
Basically, I want to allow users to import as many images (mostly .jpg) as they wish, and then press a button to have an image randomly displayed one at a time.
Also related to this question is how can the name of an imported image be put into a field the moment it is imported?
Thanks in advance for whatever advice anyone can give.
Cheers,
deeverd
Re: Retrieving a List of Image Names in the Stack
Posted: Wed Jan 06, 2016 3:04 am
by dunbarx
There are no dumb questions.
Only dumb answers.
An image is a control. You can always:
Code: Select all
on mouseUp
repeat with y = 1 to the number of images
put the name of image y into line y of fld 1
end repeat
end mouseUp
Craig Newman
Re: Retrieving a List of Image Names in the Stack
Posted: Wed Jan 06, 2016 3:10 am
by dunbarx
Hi again. Just read the last portion of your post.
Try this in the stack script:
Code: Select all
on newImage
put the name of last image into fld 1
end newImage
This is a cute ploy. The "newImage" message is sent whenever a new image appears. Like when you import one.
The "last" keyword is exploited here since any new image will automatically be placed in the highest layer. This can be used for all other controls, EXCEPT for groups. Groups do not behave, at least as of v.6.x. Why this should be so is a dumb question.
But here is a question that is not dumb. Why not improve that handler so it names the newly imported image to something other than the default?
Craig
Re: Retrieving a List of Image Names in the Stack
Posted: Wed Jan 06, 2016 3:19 am
by deeverd
Hello Dunbarx,
Thanks. I never realized to think of an image as a control, and that script works like a charm.
Just one other question. Below is a sample of script I use to import a photo to the active card. My question is, "When I import a photo onto a card, how do I get the name of that particular image file that I chose on my computer and have that name go into a field during the import process?"
Code: Select all
on mouseUp
answer file "Select a photograph for input:" with filter "Image files, *.bmp;*.gif;*.jpg;*.jpeg"
if it is empty then
exit mouseUp
else
import paint from file it
answer information "Your photograph has been successfully imported into your Photo Library." titled "Successful Image Import"
end if
end mouseUp
Thanks so much for your patience with my nescience (a polite educated word for "ignorance").
Cheers,
deeverd
Re: Retrieving a List of Image Names in the Stack
Posted: Wed Jan 06, 2016 4:01 am
by deeverd
Thanks again Dunbarx,
Just tried using your custom command, "put the name of last image into fld 1," and it was no surprise that it worked perfectly.
Has anybody told you lately that you're a genius?
Greatly appreciated,
deeverd