Assignment (FPScript)

23.08.2021

Assigns a value to an object property, a variable or a component, or a list element within it.

Syntax

Target = Expression

or

[ Target )., Target], ...] ] = List

The syntax of the Assignment function consists of the following elements:

Element

Description

Target

An expression that refers to a variable, a component in a variable, or an object property of the formula in which the statement is used.

Expression

Any expression whose value is to be assigned.

Target1...n

Several expressions that refer to a variable, a component in a variable, or an object property of the formula in which the statement is used.

List

Any expression that results in a list whose elements are to be assigned.

Remarks

To delete a variable, it can be assigned the value Empty. If you assign a value to a component of a signal, a signal series or a space curve, its data type and data structure must be chosen in such a way that the value modified in this way has a valid data structure when viewed as a whole. You can assign the value Empty, for instance, to the Z component of a space curve. The remaining X and Y components then form a signal. You cannot, however, assign any data series with strings to the Y component of a signal, for instance, because this data type for signals is not allowed.

The assignment to object properties is greatly reduced and only permitted for the properties UnitY, UnitX, UnitZ, CommentsY, CommentsX, and CommentsZ of the formula containing the FPScript code.

Use the second form of the assignment in order to assign individual variables to the elements of a list. If you specify more variables than there are list elements, then Empty will be assigned to the excess variables.

Notes:

Use the Dim statement to declare a variable and assign a value to it at the same time.

You should use the assignment to object properties of the formula only when absolutely necessary. In general, it is preferable to change the respective attributes in the formula's Properties dialog box. Write access to the object properties makes sense for embedded FPScript if Unit Manager is disabled. An FPScript expression on the "Data" tab of a 2D diagram's Properties dialog box could look like this, for instance: .Unit = "%"; Signal * 100. / Maximum(Signal). Using this calculation, the physical unit changes here. Using write access under Unit Property ensures that the correct unit is displayed in the legend.

If Unit Manager is enabled, the expression should be written in such a way that the result is provided in the correct unit, such as: Unit<%>Unit<1>(Signal / Maximum(Signal)).

If you use the path name of a data object in FPScript, it will be interpreted as a value and not as an object reference. Use the Set statement or the As Object keyword to assign an object reference.

Available in

FlexPro View, Basic, Professional, Developer Suite

Examples

Sig = Smooth(Sig, 3)

Smoothes the signal stored in Sig .

List.[1n] = 1

An assignment to the second element in the list stored in List .

Sig.X = (10, 0 s, 0.1 s)

Replaces the X component of the signal stored in Sig with ten points.

.UnitX = "ms"

Changes the physical unit of the X component in the header information of the formula in which the statement is located.

[y, x, z] = List

Assigns the variables y, x and z to the first three elements of the list.

 

See Also

Set Statement

As Object Keyword

Dim Statement

Indexed Assignment

Share article or send as email:

You might be interested in these articles