Operator Type:
Operator Scope of Action:
Operator Purpose:
Operator First Added:
Operator in Current Baseline:
Operator Last Altered:
Operator Has Optional Arguments:
Function [other Function type actions]
Item [operators of similar scope]
Document configuration [other Document configuration operators]
v9.2.0
Baseline
As at baseline
createAttribute(nameStr[, dataType])
The operator createAttribute(name[, type]) can create a new user attributes. If an attribute of the same nameStr already exists, the operator has no effect and returns false
. Otherwise, a new user attribute is created. The nameStr argument is case-sensitive and should use the capitalisation as for the desired attribute. Thus nameStr values of Test
and test
result in different attributes called 'Test' and 'test'.
Optionally, a dataType argument may be supplied to determine the data type of the new attribute. Recognised values for dataType include: string
, number
, boolean
, date
, color
, interval
, file
, list
, set
, url
, and dictionary
. If no dataType valued is supplied, Tinderbox creates a String-type attribute. The dataType argument is case-sensitive: number
produces a number type attribute, but Number
would result in a (default) string type attribute.
A basic example using just the nameStr argument, results in a new String-type attribute called 'MyList':
$MyBoolean = createAttribute("SomeList");
But, in the example above, the chosen name for the new attribute indicates the intended data-type should be of List data type. Therefore, use of the optional dataType argument would make more sense to signal user intent to Tinderbox more clearly:
$MyBoolean = createAttribute("SomeList", "list");
Again, the action results in a new String-type attribute called 'SomeList'.
Note that action code cannot alter the new attribute's name or type, nor delete the attribute. This can be done but only via the User attribute inspector.
Some other aspects of the attribute, e.g. default value) can be changed after the attribute is created, using attribute(). Here below, a number-type attribute is created, its default is set and then a value is applied:
createAttribute("Tester","number");
attribute("Tester")["default"] = 10;
$Tester = 1000;