reflect.Value.copyOf

Creates a new reflect.Value object from a copy of an expression.

Syntax

reflect.Value.copyOf(
     val any-type )
  RETURNS reflect.Value
  1. val is an expression. This is typically a literal value.
  2. any-type can be of a various kind of types.

Usage

The reflect.Value.copyOf() class method returns a new reflect.Value object, which is a copy of the expression passed as parameter. The reflect.Value object can then be used to call object methods to describe and modify the original value. Note that certain data types cannot be copied; these exceptions are detailed in the list below.

When the argument (expression or variable) is defined as a primitive data type, record structure or static array, the value is cloned to create the reflect.Value object: Any call to a reflection manipulation method will leave the source unchanged.

Exceptions:

Example

IMPORT reflect
MAIN
    DEFINE rec RECORD
               pkey INTEGER,
               name VARCHAR(50)
           END RECORD
    DEFINE val reflect.Value
    LET rec.pkey = 101
    LET rec.name = "Mike FITZPATRICK"
    LET val = reflect.Value.copyOf( rec )
    LET rec.pkey = 102
    LET rec.name = "Jessica PARS"
    DISPLAY "val pkey = ", val.getField(1).toString()
    DISPLAY "val name = ", val.getField(2).toString()
END MAIN
Shows:
val pkey = 101
val name = Mike FITZPATRICK