Accessing Object Properties

23.08.2021

The objects saved in the project database, such as documents or diagrams, have a series of properties. For example, each object has a name or a creation date; data sets have a physical unit, etc. You can use FPScript for read access to these types of object properties. You can, for instance, query the unit name of a data set or the current cursor position in a diagram. To do this, use the following syntax:

[Object].Property[(Parameter1,..., Parameter n)]

Object is the path name of the object and Property is the name of the property that you want to access. If the object is not a data object, i.e. a data set or a formula, then you have to append the file name extension describing the object type to the object name. If you do not specify an object name, then the formula containing the FPScript code is accessed. To access certain objects, which depend on the context of the processed FPScript formula, use the This, ThisFPObject or ThisObject keywords. In the case of embedded FPScript you have to use the This keyword.

Diagram.2D.Name supplies the name of the 2D diagram Diagram as a string. Name in this case is the name of the property to be read and .2D is the file extension for the 2D diagram.

.\.FullName provides the absolute path name for the folder where the FPScript formula is located.

\.Comments provides the comments of the project database root folder.

.UnitY provides the physical unit of the Y component of the formula containing this FPScript expression.

You can also access object properties using a variable if you have already assigned an object reference to it:

Dim Obj = MyDataset As Object

Obj.CommentsX

Write-access to object properties is greatly reduced and only permitted for the header information of the formula containing the FPScript code. It is, however, preferred that you handle the corresponding entries in the Properties dialog box of the formula for these properties instead of writing these in the FPScript code. During each update process, formulas that use this type of write access are not considered up-to-date and thus must be recalculated each time. It makes more sense to have write-access to object properties in the embedded FPScript.

Instead of directly specifying the object path name or the property name, you can use the indirection operator, which uses a string containing the name. The parameter list is only required for properties that require additional parameter settings. To access the cursor position in a diagram within a worksheet, for example, you have to specify the number of the plane and the number of the cursor.

FPScript allows read access to all object properties that are defined in the FlexPro automation object model. It is used very frequently in embedded FPScript formulas, which are used, for instance, to label the axes in a diagram. Within FPScript formulas that you use for data analysis, such access is mainly targeting attributes and parameters of objects as well as cursors and markers in diagrams. You can access the FPScript expressions required for this through the Object Properties Wizard of the Formula Editor.

See Also

List of All Optional Properties in the Wizard

Share article or send as email:

You might be interested in these articles