Navigation: ABC Library Reference > ConstantClass > ConstantClass Methods >====== Init (initialize the ConstantClass object) ====== | |
Init( [termination] )
Init | Initializes the ConstantClass object. |
termination | An integer constant, variable, EQUATE or expresssion that controls when the Next(FILE) and Next(QUEUE) methods stop processing the constant data. If omitted, termination defaults to Term:Ushort. Valid termination values are Term:Ushort, Term:Byte, Term:EndGroup, andTerm:FieldValue |
The Init method initializes the ConstantClass object.
The termination parameter provides two important pieces of information to the ConstantClass object: it tells the ConstantClass object whether there is a non-repeating item count declared at the beginning of the constant data (describes the structure of the constant data), and it tells the ConstantClass object how to recognize the end of the constant data. Valid termination values are:
Term:Ushort | The GROUP declares a USHORT containing the item count–stops reading when item count reached. |
Term:Byte | The GROUP declares a BYTE containing the item count–stops reading when item count reached. |
Term:EndGroup | The GROUP does not declare an item count'stops reading at end of GROUP structure. |
Term:FieldValue | The GROUP does not declare an item count'stops reading when it finds the TerminatorValue within the constant data. |
Implementation:
The Init method CLEARs the TerminatorValue property. The Init method allocates memory and should always be paired with the Kill method, which frees the memory.
EQUATEs for the termination parameter are declared in ABUTIL.INC:
ITEMIZE(1),PRE(Term)
EndGroup EQUATE !Stops reading at end of GROUP
UShort EQUATE !Reads number of items specified by USHORT at start of group
Byte EQUATE !Reads number of items specified by BYTE at start of group
FieldValue EQUATE !Stops when specified value is found in first AddItem field,
!only first 32 chars are compared
END
Example:
Const.Init(Term:BYTE) !Initialize the Const object,
!the first BYTE contains item count
Const.AddItem(ConstType:PString, LangQ.Text)
!Describe constant structure and variables to accept the values
Const.AddItem(ConstType:PString, LangQ.Repl)
Const.Set(Spanish) !pass the constant data to Const object
Const.Next(LangQ) !copy all constant items to the LangQ
Const.Kill !shut down Const object
See Also: Kill, Next, TerminatorValue