Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Gets or sets the value for a specified item in a struct.
Syntax
public anytype value(str fieldName, [anytype value])
Run On
Called
Parameters
- fieldName
Type: str
The name of the item to get or set the value for.
- value
Type: anytype
The value to assign to the item; optional.
Return Value
Type: anytype
The value of the specified item.
Remarks
An exception is raised if there is no item with the specified name in the struct. The name of an item in a struct may be retrieved by using the Struct.fieldName method.
You can add a new item to a struct and assign a value to it at the same time by using the Struct.add method. To assign a new value to an item based on its position in the struct, use the Struct.valueIndex method.
Examples
The following example creates a struct with two items in it and then uses the value method to assign values to those two items.
{
Struct s = new Struct ("str name; int age");
// Set the values
s.value("name", "Jane Dow");
s.value("age", 34);
// Print the values
print s.value("name");
print s.value("age");
pause;
}