BBjTemplatedString
Description
In BBj 7.0 and higher, this object provides the functionality of the traditional templated string and can be used throughout BBj in places where a templated string can be used.
Creation
BBjAPI > BBjTemplatedString
A BBjTemplatedString object is created through the following BBjAPI method:
Return Value |
Method |
---|---|
BBjTemplatedString |
makeTemplatedString(string p_template) |
Methods of BBjTemplatedString
Return Value |
Method |
---|---|
void |
clear() |
byte[] |
fattr() |
number |
getFieldAsNumber(string fieldname) |
number |
getFieldAsNumber(string fieldname, int index) |
byte[] |
getFieldAsString(string fieldname) getFieldAsString(string fieldname, int index) |
byte[] |
getFieldAttribute(string fieldname, string attributename) |
int |
getFieldLength(string fieldname) |
int |
getFieldRepeat(string fieldname) |
int |
getFieldTerminator(string fieldname) |
byte[] |
getFieldType(string fieldname) |
byte[] |
|
byte[] |
|
int |
getTerminatedFieldNumber(string fieldname) |
int |
getTerminatedFieldOffset(string fieldname) |
boolean |
isFieldByteSwapped(string fieldname) |
boolean |
isFieldEOSTerminated(string fieldname) |
boolean |
isFieldLongSwapped(string fieldname) |
boolean |
isFieldPadded(string fieldname) |
boolean |
isFieldTerminated(string fieldname) |
boolean |
isFieldTerminatorEscaped(string fieldname) |
boolean |
isFieldWordSwapped(string fieldname) |
void |
setFieldValue(string fieldname, string value) |
void |
setFieldValue(string fieldname, number value) |
void |
setFieldValue(string fieldname, int fieldIndex, string value) |
void |
setFieldValue(string fieldname, int fieldIndex, number value) |
void |
setString(string value) |
Remarks
Several BBjTemplatedString methods whose value is documented as a string is actually a byte array (byte[]). For normal BBj code, this is completely transparent to the user. BBj converts as necessary between byte[] and string. When a value is passed directly from a BBj method to a Java structure, the Java structure gets the raw internal data format, which in this case happens to be a byte[]. If it is critical that the value being passed to the Java structure be a string, then using the STR() function or string variables as intermediaries to force the byte[] to a string can be used.
Constants
None.
Example
rem ' BBjTemplatedString template$ = "name[5]:c(32*),context:u(2),code:u(1),id:u(2),objtype:i(2)" dim A$:template$ B! = bbjapi().makeTemplatedString(template$) print "template for A$: ", fattr(A$) print "template for B!: ", B!.fattr() A.name$[1]="aaa" A.name$[5] = "eee" A.context = 22 A.code = 3 A.id = 44 A.objType = 55 B!.setString(A$) print B!.getFieldAsString("name",1)," = ", A.name$[1] print B!.getFieldAsString("name",5)," = ", A.name$[5] print B!.getFieldAsNumber("context")," = ", A.context print B!.getFieldAsNumber("code"), " = ", A.code print B!.getFieldAsNumber("id"), " = ", A.id print B!.getFieldAsNumber("objType")," = ", A.objType B!.setFieldValue("name",1,"XXX") B!.setFieldValue("name",5,"ZZZ") B!.setFieldValue("context",66) B!.setFieldValue("code",7) B!.setFieldValue("id",88) B!.setFieldValue("objType",9) A$ = B!.getString() print B!.getFieldAsString("name",1)," = ", A.name$[1] print B!.getFieldAsString("name",5)," = ", A.name$[5] print B!.getFieldAsNumber("context")," = ", A.context print B!.getFieldAsNumber("code"), " = ", A.code print B!.getFieldAsNumber("id"), " = ", A.id print B!.getFieldAsNumber("objType")," = ", A.objType |
See Also
BBj Object Creation and Assignment
See the BBj Object Diagram for an illustration of the relationship between BBj Objects.