Navigation: ABC Library Reference > ConstantClass > ConstantClass Methods >====== AddItem (set constant datatype and target variable) ====== | |
AddItem( datatype, target )
AddItem | Sets the (repeating) constant datatype and its corresponding target variable. |
datatype | An integer constant, variable, EQUATE or expresssion that identifies the datatype of a repeating constant within the constant GROUP structure. Valid datatype values are ConstType:Cstring, ConstType:Pstring, ConstType:Byte, ConstType:Short, ConstType:Ushort, and ConstType:Long. |
target | The label of the variable that receives the constant value. |
The AddItem method sets a (repeating) constant datatype and its corresponding target variable. Use multiple calls to the AddItem method to “describe” the constant data structure as well as the target variables that receive the constant data.
Implementation:
You should call AddItem for each repeating datatype declared in the constant GROUP structure. The Next method processes the constant data items described by the AddItem calls.
EQUATEs for the datatype parameter are declared in ABUTIL.INC:
ITEMIZE(1),PRE(ConstType)
First EQUATE
Cstring EQUATE(ConstType:First)
Pstring EQUATE
Byte EQUATE !1 byte unsigned integer
Short EQUATE !2 byte signed integer
UShort EQUATE !2 byte unsigned integer
Long EQUATE !4 byte signed integer
Last EQUATE(ConstType:Long)
END
Example:
Errors GROUP,STATIC
USHORT(Msg:RebuildKey) !begin first item
PSTRING('Invalid Key') !end first item
USHORT(Msg:RebuildFailed) !begin second item
PSTRING('Key not built') !end second item
END
ErrorQ QUEUE
ID LONG
Text CSTRING(255)
END
CODE
!The following describes the Errors GROUP and its corresponding target variables
Const.AddItem(ConstType:Ushort, ErrorQ.ID) !USHORT constant maps to error ID
Const.AddItem(ConstType:PString, ErrorQ.Text)!PSTRING constant maps to error text
See Also: Next