BBjTemplatedString::setFieldValue

Description

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

Syntax

Return Value

Method

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)

Parameters

Variable

Description

fieldindex

The index of a repeating field

fieldname

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

value

The value which is to be placed into the BBjTemplatedString.

Return Value

None.

Remarks

This method actually accepts a byte array for this parameter. BBj automatically converts any BBjString or String passed in to a byte array.

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.