$scalar
Retrieve a collection of all scalar members of a Struct, or assign a scalar value to a Struct.
Struct->$scalar
Return Values
Returns a reference to all scalar members of a Struct.
Value |
Error Constant |
Meaning |
---|---|---|
|
|
Tried to access members of a Scalar Struct, which has no members |
|
|
Tried to assign a non-scalar value to $scalar. The Struct is not changed in that case. |
Description
A Struct node can have one or more members that are scalar Structs. You can use $scalar to retrieve all scalar members of a Struct node (instead of iterating over them and checking $isScalar for each of them). You can also use $scalar to assign or change the scalar value of a Struct.
For more information, see Struct Leaves.
Example: Using $scalar
For example, given the following Struct (referenced by Struct variable vStruct):
[] [div] [h1] = "Example" "Text can be " [b] = "bold " "or " [em] = "italic"
the following code shows how you can use $scalar:
>variables struct vStruct, vScalar1, vScalar2 endvariables ... vScalar1 = vStruct->div->$scalar vScalar2 = vStruct->div->b->$scalar vStruct->div->$scalar = "Plain "
- vScalar1 refers to two
Scalar Structs:
"Text can be "
and"or "
- vScalar2 refers to one
Scalar Struct:
"bold "
- A new value is assigned to
$scalar, which is inserted at the position of the first scalar Struct in
vStruct. vStruct now has the following structure:
[] [div] [h1] = "Example" "Plain " [b] = "bold " [em] = "italic"
Version |
Change |
---|---|
9.5.01 |
Introduced |