Hi guys,
I'm extremely, extremely new to LiveCode and programming in general and would like some help with something. I'm writing a psychology experiment in which we rate people's reactions to pictures that are flashed quickly. I have two folders on my Mac that contain the pictures we intend on using, and I'd like to be able to get my program to select one picture from one folder, display it for, say, 100 milliseconds, then do the same for the other folder before the participant responds. How would I go about doing something like this? Thanks for the help.
random selection from image folders
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: random selection from image folders
The best way to start is to make a list of the actions you'll need to perform. Don't worry about syntax, just use plain language. The more detailed, the better. So:
Get a list of all the images in folder 1.
Store it somewhere.
Get a list of all the images in folder 2.
Store it somewhere else.
Check for a click on a button or some other trigger.
Look at all the images in first variable and choose one at random.
Show it on screen.
Set a timer.
When the timer goes off, remove the image.
Stop the timer.
Select a random image from the second list.
Show it on screen.
Set a timer.
When the timer goes off, remove the image.
Do what's needed to get a user response.
I've left out some things, like how to know whether you've shown one or two images so far. Also, you''ll need to decide how to store the list variables (hint: use script locals, since you only need to retrieve the lists once per LC session. No need to repeatedly read the folder contents.)
Then you start working your way down the list and try to script each action. You'll probably get stuck, and when that happens just ask and we'll help. Don't be shy, we all started out this way.
Hints for getting the contents of a folder:
the defaultFolder
the files
filter (use this to remove files from the list that aren't images)
Get a list of all the images in folder 1.
Store it somewhere.
Get a list of all the images in folder 2.
Store it somewhere else.
Check for a click on a button or some other trigger.
Look at all the images in first variable and choose one at random.
Show it on screen.
Set a timer.
When the timer goes off, remove the image.
Stop the timer.
Select a random image from the second list.
Show it on screen.
Set a timer.
When the timer goes off, remove the image.
Do what's needed to get a user response.
I've left out some things, like how to know whether you've shown one or two images so far. Also, you''ll need to decide how to store the list variables (hint: use script locals, since you only need to retrieve the lists once per LC session. No need to repeatedly read the folder contents.)
Then you start working your way down the list and try to script each action. You'll probably get stuck, and when that happens just ask and we'll help. Don't be shy, we all started out this way.
Hints for getting the contents of a folder:
the defaultFolder
the files
filter (use this to remove files from the list that aren't images)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com