cloneobjects
PROPERTY
,
VALUE

The cloneobjects statement duplicates objects in a form (with modifications).


Parameters

This statement has two parameters:

property – the object property (color, font, etc.) to modify. See Modifiable Object Properties for descriptions of the different properties that can be modified. Standard properties can be specified in either upper or lower case, but native properties are case sensitive.

value – The new value for this property. Note: Instead of specifying the property names and values as separate parameters, you can specify multiple properties with a dictionary. See the main text below for more information.


Description

This statement clones selected objects in a form. Usually a procedure will use the SelectObjects statement to select the objects before cloning them. This example assumes that the current form has a row of objects inside an object named RowArea (see Object Names). The procedure copies the objects, making a second row just below the existing row.

local rowRectangle
rowRectangle = objectinfo("rectangle","RowArea")
// select objects in row
selectobjects unionrectangle(objectinfo("rectangle"),rowRectangle)=rowRectangle
cloneobjects "rectangle",rectangleoffset(objectinfo("rectangle"),rheight(rowRectangle),0)

You can specify multiple property/value pairs in a single cloneobjects statement, like this:

cloneobjects property1,value1,property2,value2,property3,value3

Here’s a more complicated example. Suppose the current form contains a row of text editor objects for editing line item fields, perhaps Qty1, Product1, Price1 and Total1. This procedure will create a second row 2 points below the current row, with the field names adjusted to Qty2, Product2, Price2 and Total2.

local rowRectangle,rowNumber
rowNumber = 1
selectobjects objectinfo("fieldname") endswith str(rowNumber)
rowrectangle = objectinfo("boundary")
cloneobjects "rectangle",rectangleoffset(objectinfo("rectangle"),rheight(rowRectangle)+2,0),
    "fieldname",replace(objecinfo("fieldname"),str(rowNumber),str(rowNumber)+1)

With slight adjustments this procedure could be modified to make rows 3, 4, 5, etc. (Further modifications would be required if you wanted to go past 9, perhaps changing the endswith operator to a regular expression (see regexmatch), like this:

selectobjects objectinfo("fieldname") regexmatch "[a-zA-Z]+"+str(rowNumber)+"$"

You can also specify the properties with a dictionary, as shown below:

local rowRectangle,rowNumber
rowNumber = 1
selectobjects objectinfo("fieldname") regexmatch "[a-zA-Z]+"+str(rowNumber)+"$"
rowrectangle = objectinfo("boundary")
cloneobjects initializedictionary(
    "rectangle",rectangleoffset(objectinfo("rectangle"),rheight(rowRectangle)+2,0),
    "fieldname",replace(objectinfo("fieldname"),str(rowNumber),str(rowNumber)+1))

The two previous example perform the exact same modification to the selected objects. The advantage of using a dictionary is that you can prepare it in advance in a variable, and then use it over and over again (possibly adjusting it with the changedictionaryvalues( function).


See Also


History

VersionStatusNotes
10.0UpdatedNew in this version.