BBjTemplatedString::getFieldAsNumber

Description

In BBj 7.0 and higher, this method returns the numeric value stored in a specified field of a BBjTemplatedString.

Syntax

Return Value

Method

number

getFieldAsNumber(string fieldname)

number

getFieldAsNumber(string fieldname, int index)

Parameters

Variable

Description

fieldname

The name of the field that is to be retrieved as defined in the template used when constructing the BBjTemplatedString.

index

The index of a repeating field.

Return Value

Returns the numeric value that is stored in the BBjTemplatedString.

Remarks

None.

Example

template$ = "name[5]:c(32*),context:u(2),code:u(1),id:u(2),objtype:i(2)"
dim A$:template$
B! = BBjAPI().makeTemplatedString(template$)
?"template for A$: ", FATTR(A$)
?"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$)
?B!.getFieldAsString("name",1)," = ", A.name$[1]
?B!.getFieldAsString("name",5)," = ", A.name$[5]
?B!.getFieldAsNumber("context")," = ", A.context
?B!.getFieldAsNumber("code"),   " = ", A.code
?B!.getFieldAsNumber("id"),     " = ", A.id
?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()
?
?B!.getFieldAsString("name",1)," = ", A.name$[1]
?B!.getFieldAsString("name",5)," = ", A.name$[5]
?B!.getFieldAsNumber("context")," = ", A.context
?B!.getFieldAsNumber("code"),   " = ", A.code
?B!.getFieldAsNumber("id"),     " = ", A.id
?B!.getFieldAsNumber("objType")," = ", A.objType

See Also

String Templates

BBjAPI

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.