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 value.

The original expression (or variable value) is cloned to create the reflect.Value object: Any call to a reflection manipulation method will leave original expression (or variable) unchanged.

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