Automating placement of referenced image

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Automating placement of referenced image

Post by montymay » Sat Jul 26, 2014 5:23 am

I have a stack of cards, each card of which has the picture of a courtroom as the background. A judge's bench is in the center. The court has seven judges. Each card has fields that contain data about a particular case that one of the seven judges decided. I have a script that automatically creates the cards from a text file and puts the textual data about the case into the fields of each card. On each card I have been manually putting a picture of the judge who decided the case by using New Referenced Control -> Image. I am looking for a script that will automatically put a referenced picture of the correct judge at the correct location on the card when the card is created and the fields are populated, e.g., in English, if the judge is "Smith," put image "pics/Smith.png" at the correct location. I searched the forum and saw, set the filename of "image" to "smith.png", but what not sure what the object named "image" is. Image Area? Please forgive if I overlooked an existing discussion. Thanks you for any suggestions.

Monty

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

Re: Automating placement of referenced image

Post by Klaus » Sat Jul 26, 2014 12:35 pm

Hi Monty,

Code: Select all

## set the filename of "image" to "smith.png"
wrong syntax, the object descriptor is missing, so it should read:

Code: Select all

set the filename of IMAGE "image" to "smith.png"
Which will surely answer your question :D

But you would rather:

Code: Select all

set the filename of IMAGE "image" to "pics/smith.png"
8)


Best

Klaus

montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Re: Automating placement of referenced image

Post by montymay » Thu Aug 14, 2014 2:52 am

But what is the object referred to as IMAGE in the example and that has the name "image"? Is it an "image area", which is one of the tools on the tools pallette?

Monty

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: Automating placement of referenced image

Post by dunbarx » Thu Aug 14, 2014 3:46 am

Hi.

Would you have the same problem understanding this:

set the loc of "button" to "100,100"

This is missing the object descriptor, as Klaus says. Do you immediately see the issue?

The missing descriptor could be a name, a number, an ID, whatever:

set the loc of button 2 to "100,100"
set the loc of button "XYZ" to "100,100"

now hear this:

set the loc of button "button" to "100,100"

It is probably not good practice to use the default object name, but cannot hurt unless you let it. But in the example using "image", the case is the same. Don't let the name similarities get to you. But do know the difference.

Craig Newman

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: Automating placement of referenced image

Post by WaltBrown » Thu Aug 14, 2014 4:07 am

Monty,
Yes, it is an object you drag over from the ToolBar. "image" is the name of the object you wish to set to "pics/smith.png". Expanding on the answer, I created (which you may also do programmatically) an Image object named "MyPic". In a button I put:

Code: Select all

ask file "Get image file"
   if it is not empty then
      set the filename of image "MyPic" to it
   end if
Note that this may resize the image object, so you will have other tuning to do.
Walt Brown
Omnis traductor traditor

montymay
Posts: 145
Joined: Thu Jul 18, 2013 5:23 am

Re: Automating placement of referenced image

Post by montymay » Thu Aug 14, 2014 5:58 am

Thank you Klaus, dunbarx, and WaltBrown. I now understand how to automate the importation and placement of images of my judges, and If I set the correct image size of my photos in my photo editor, I won't need to scale them with code in the script.

Monty

Post Reply