IPB_Session interface:
GetFieldID method
Description
Obtains the internal ID of a class instance variable.
Syntax
GetFieldID(pbclass cls, LPCTSTR fieldName)
Argument |
Description |
---|---|
cls |
The class in which the field resides |
fieldName |
The instance member name, in lowercase |
Return Values
pbfieldID or 0xffff if a field ID cannot be found.
Examples
This function obtains the identifier of a class's visible field, if it exists, and uses it to set the value of the field:
void CallBack::f_setvisible(IPB_Session* session,
pbobject dwobj)
{
pbclass cls;
IPB_Value* pv;
pbfieldID fid;
pbstring strtmp;
bool isTrue;
pbboolean isNull;
cls = session-> GetClass(dwobj);
fid = session-> GetFieldID(cls, "visible");
if (fid == kUndefinedFieldID)
return;
isTrue = session-> GetBoolField(dwobj, fid, isNull);
if (isTrue)
session -> SetBoolField(dwobj, fid, false);
else
session -> SetBoolField(dwobj, fid, true);
return ;
}
Usage
GetFieldID is one of a set of functions that allows native code to access the fields of Java objects and get and set their values. You use GetFieldID to retrieve the value of a field, specifying the class name and the field name. The field ID returned can be used as an argument to the related functions.