Language Reference Guide : 4. System Classes : Scope Class : CreateDynExpr Method (Scope)
 
Share this page                  
CreateDynExpr Method (Scope)
The CreateDynExpr method creates a dynamic expression on a specified scope object.
This method has the following syntax:
DynExpr = Scope.CreateDynExpr(string = string[, datatype = byref(varchar(256))]
          [, errors = byref(StringObject)])
This method has the following parameters:
string
Represents a syntactically valid OpenROAD expression. The string is evaluated within the context of the named scope. Identifiers appearing within the string must also be defined in a symbol table associated within the scope. The string cannot contain any invocations of procedures or methods. There are no other restrictions on the expression.
datatype
Specifies that the datatype of the compiled expression should be returned. The returned datatype includes nullability and is in script declaration format, for example:
varchar(32) not null
stringobject
integer2
myuserclass
This enables the datatype of variables declared in the script—and system, global, field, and attribute variables—to be determined at runtime. For example, after the following statement:
mydynexpr = curframe.Scope.CreateDynExpr(string='curframe', datatype=Byref(datatype));
the value of datatype is:
frameexec
Note:  The returned datatype name may be a synonym of the declared datatype, rather than the matching name; for example, a declared datatype of "smallint" will be returned as "integer2".
errors
Specifies that compilation errors should be returned
When this method is invoked on a scope, the DynExpr object created is usable only for the lifetime of the scope. If the scope represents an event block, field script, frame, or procedure, then any attempt to use the DynExpr object after the event block, field script, frame, or procedure terminates causes a runtime error.
If the specified context is invalid, or if the specified string cannot be compiled, the CreateDynExpr method returns a null. To obtain a listing of compilation errors, specify the optional errors parameter. If compilation errors occur, the CreateDynExpr method creates a string object containing the errors and sets the variable specified by the errors parameter to point to that string object. If no compilation errors occur, the CreateDynExpr method sets the variable specified by the error parameter to null.
For more information about using this method, see How You Can Create a Dynamic Expression and How You Can Get Values from Unknown Fields in the Programming Guide.