reflect.Value.getFieldByName
Returns a field of a record, from the member name.
Syntax
getFieldByName(
name STRING )
RETURNS reflect.Value
- name is the name of the field in the
RECORD
structure. The field name is case sensitive.
Usage
The getFieldByName()
method returns a reflect.Value
object that
is a reference to the field, which corresponds to a member with the name passed as parameter, for
the record structure represented by this reflect.Value
object.
The name of the field (record member) is case sensitive. The parameter
passed to this method must match the name used in the RECORD
or
TYPE
definition. If the parameter does not match a record field name, the method
returns NULL
.
The reflect.Value
object used to call this method must have been
created with a RECORD
variable, or is a
reflect.Value
object returned from a method like getField()
, getFieldByName()
, getArrayElement()
, or
getDictionaryElement()
, and references a record structure.
The new reflect.Value
object references the original
variable: Any call to a reflection manipulation method modifies the underlying variable
directly.
Example
IMPORT reflect
MAIN
DEFINE rec RECORD
pkey INTEGER,
name VARCHAR(30)
END RECORD
DEFINE val reflect.Value
LET rec.pkey = 101
LET rec.name = "Mike FITZPATRICK"
LET val = reflect.Value.valueOf( rec )
DISPLAY "value = ", val.getFieldByName("name").toString()
DISPLAY "type = ", val.getFieldByName("name").getType().toString()
END MAIN
value = Mike FITZPATRICK
type = VARCHAR(30)