cloneobjects
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

- activeobjectaction -- allows a procedure to communicate with the object on the current form that is currently being edited (if any).
- changeobject -- modifies the properties of one object in a form.
- changeobjects -- modifies the properties of one or more objects in a form.
- cloneform -- copies all of the objects in a form (optionally, with modifications) into the active form.
- closeactiveobject -- closes any object whose text is currently being edited.
- datamode -- switches a form from graphics mode into data mode.
- deleteobject -- deletes the specified object from the current form.
- deleteselectedobjects -- deletes selected objects from a form.
- draggraybox -- facilitates dragging something around in a form window.
- dragtext -- starts drag-and-drop of text.
- formcleanview -- cleans up extraneous NSView objects in the current form.
- formxy -- programmatically scrolls a form to a new position.
- graphicsmode -- switches a form into graphics mode.
- info("activeobject") -- returns the name of the currently active text editor or word processor object (if any).
- info("activeobjectid") -- returns the object ID of the currently active text editor or text list object, if any.
- info("activesuperobject") -- returns the name of the currently active text editor or word processor object, if any.
- info("click") -- returns the location of the last mouse click in screen relative coordinates.
- info("clickedobjectid") -- returns the object ID of the clicked object.
- info("focusobject") -- returns the name of the currently active text editor or word processor object, if any.
- info("focusobjectid") -- returns the object ID of the currently active text editor or text list object, if any.
- info("scrollpoint") -- returns the distance the current form is scrolled horizontally and vertically.
- magicformwindow -- designates an open window as the temporary active window for the purposes of info( functions and graphic statements.
- magicwindow -- designates an open window as the temporary active window for the purposes of info( functions and graphic statements.
- magnification -- changes the magnification of a form.
- Modifiable Object Properties -- describes the properties of graphic objects that can be modified by a program (dimensions, color, font, title, etc.).
- newformobject -- creates a new graphic object in a form.
- object -- selects an object (based on the object name).
- objectaction -- allows a procedure to communicate with an object on the current form.
- objectid -- selects one graphic object in the current form based on an ID number.
- objectinfo( -- returns information about a graphic object: its location, size, color, font, etc.
- objectinfoarray( -- builds a text array of form object properties
- objectnumber -- identifies one graphic object from a set of selected graphic objects in the current form.
- openasyncprogresswindow -- opens a floating progress window for asynchronous operations (urltask(, timers).
- progressalert -- displays a progress alert if an operation is going to take a long time.
- progressbar -- updates a progress bar on the current form.
- selectallobjects -- selects all the graphic objects in the current form.
- selectnoobjects -- unselects all the graphic objects in the current form.
- selectobjects -- uses a formula to select one or more objects in the current form.
- startgraphicschange -- adds undo support to a procedure.
- Text Display Programming -- programming a Text Display Object.
- Text Editor Programming -- programming a Text Editor Object.
- textlisttableoptions -- sets up text list table options
- Web Browser Programming -- programming a Web Browser Object (including JavaScript).
- xytoxy( -- converts a point or rectangle from one co-ordinate system to another.

History

Version | Status | Notes
10.0 | Updated | New in this version.