Any graphic object can be assigned a name that can be used to identify that object. This is usually used let code identify the object. You can assign a name to an object using the Measurements Panel of the Object Inspector Panel).

To select an object by name use the object statement. This statement has one parameter—the name of the object to select. For example, to select an object named Swiss Cheese, use this procedure:

object "Swiss Cheese"

Once an object is selected with the object statement, the code can get information about or modify the properties of the object (see the objectinfo( function and the ChangeObjects statement. This example selects an object named Status Box and turns it red.

object "Status Box"
changeobjects "color",htmlrgb("FF0000")

Use the objectinfo( function to retrieve information about the selected object. This example displays a message with the color of a Traffic Light object, either red or green (this code assumes that any color that isn’t pure green is red).

object "Traffic Light"
message "Light is "+ifelse(objectinfo("color")=htmlrgb("00FF00","green","red")

This more complex example will switch the Traffic Light object between red and green. Each time you run the procedure the object color will toggle.

local redColor,greenColor
redColor = htmlrgb("FF0000")
greenColor = htmlrgb("00FF00")
object "Traffic Light"
changeobjects "color",ifelse(objectinfo("color") = redColor, greenColor, redColor)

It is possible to have two or more graphic objects on a form with the same name, but this is usually not a good idea. If the object statement finds more than one object with the same name it only select the first one it finds (the one closest to the back, i.e. with the lowest z order).

Note: You can also use the SelectObjects statement to select objects based on name, for example:

selectobjects objectinfo("name") = "Status Box"

Since the SelectObjects statement may select multiple objects, you cannot use the objectinfo( function to return information in that case. If you need to do so, use the ObjectNumber statement.