167
Variable Methods
AddVariable
AddVariable
AddVariable
AddVariable ( Name, Type,
( Name, Type,
( Name, Type,
( Name, Type, Default, Value, Persist )
Default, Value, Persist )
Default, Value, Persist )
Default, Value, Persist )
Creates a new Variable
Syntax
HRESULT AddVariable(
[in] BSTR Name,
[in] long Type,
[in] BSTR Default,
[in] BSTR Value,
[in] long Persist,
[out, retval] long VarId
);
Parameters
Name
[in] Name to give the newly added Variable.
Type
[in] Type of Variable to add.
Valid types are:
Type
Value Description
1
Number
2
Schedule
3
String
4
Range
Default
[in] Default value of the new Variable.
Value
[in] Current value of the new Variable.
Persist
[in] Set to 1 to make the Variable persistent, 0 if not.
VarId
[out, retval] ID for the new Variable.
Remarks
Default and Value
The returned value is a string that represents the stored value of the Variable. The string value will need to be
converted by the caller into the actual type, e.g. a Variable of type
long
.
The format for the returned string depends on the Variable’s type. In the examples below, %d represents an
integer, %s represents a string.
Type
Format
Example
Number
“%d”
“25”
String
“%s”
“This is a string”
Range
“%d to %d”
“1 to 35”
Schedule “%d:%d:%d” “17:35:02”