13. Creating Dynamic Frames : How You Can Manipulate Data in Dynamic Fields : How You Can Access Individual Cells of a Dynamic Table Field : How You Can Set and Get Values with Dynamic Expressions
 
Share this page                  
How You Can Set and Get Values with Dynamic Expressions
You can use the following methods to get and set values in the field referenced by a dynamic expression:
GetValue to obtain the value from the field
SetValue and Assign to change values in the field
The GetValue method reevaluates the expression that was specified when the DynExpr object was created and places the value of the dynamic expression in the specified variable.
For example, to get the value of a dynamic expression that was created for a field whose data type is money, create a money variable and invoke DynExpr's GetValue method to get the value from the dynamic expression and load it into the money variable.
The following statement performs this operation:
status = dexp.GetValue(value = byref(money_var));
If the GetValue method succeeds, status is set to ER_OK; if it fails, it is set to some other integer value.
Setting a value in a dynamic expression works similarly. Use DynExpr's SetValue method to load a value from a valid OpenROAD expression into a dynamic expression.
The following code sets the value of the dynamic expression from a variable parameter to the SetValue method:
status = dexp.SetValue(value = money_var);
Like the GetValue method, the SetValue method sets status to ER_OK if successful; if it fails, it sets status to some other integer value.
The SetValue method is valid only if the expression specified when the dynamic expression was created was not a computed expression. The GetValue method is valid only if the expression specified when the dynamic expression was created represents a field or table field cell.
You can get a value from a dynamic expression and assign a new one in a single step using the Assign method. For an example of using the Assign method, see How You Can Get Values from Unknown Fields (see How You Can Get Values from Unknown Fields).