op_anim_mgp_reg_set()
Abstract
Adds a primitive that assigns a value to a register to the specified macro.
Syntax
op_anim_mgp_reg_set (anmid, regid, regval)
| Argument | Type | Description |
|---|---|---|
anmid |
Anmid |
macro ID [This value is a numeric identifier which references an open animation macro, created via the KP op_anim_macro_create().] |
regid |
int |
macro drawing register ID [This value is a numeric code identifying the macro register to be set. The 26 macro registers named A-Z are identified by predefined symbolic constants listed in Table 42 on page 8.] |
regval |
void* |
value for assignment to macro register [Because macro registers can hold integer, double, or string (char*) values, this argument is declared as void*, but can be any of these three data types.] |
Return Type
void
no return value
Example
/** Construct a macro which depicts a field within a packet. **/
mid = op_anim_macro_create ("pk field");
/* Draw a rectangle fixed at (X,Y) which has width(W) = no. bits(B) x 8 */
op_anim_mgp_reg_set (mid, OPC_ANIM_REG_C_INT, 8);
op_anim_mgp_arop (mid, OPC_ANIM_REG_B_INT, OPC_ANIM_AROP_MULTIPLY,
OPC_ANIM_REG_C_INT, OPC_ANIM_REG_W_INT);
op_anim_mgp_rect_draw (mid, OPC_ANIM_COLOR_RED, OPC_ANIM_REG_X_INT,
OPC_ANIM_REG_Y_INT, OPC_ANIM_REG_W_INT, 15);
/* Draw the field name at (L,Y) where L = X + (W / 2) */
op_anim_mgp_reg_set (mid, OPC_ANIM_REG_C_INT, 2);
op_anim_mgp_arop (mid, OPC_ANIM_REG_W_INT, OPC_ANIM_AROP_DIVIDE, OPC_ANIM_REG_C_INT,
OPC_ANIM_REG_H_INT);
op_anim_mgp_arop (mid, OPC_ANIM_REG_X_INT, OPC_ANIM_AROP_ADD, OPC_ANIM_REG_H_INT,
OPC_ANIM_REG_L_INT);
op_anim_mgp_text_draw (mid, OPC_ANIM_ALIGNH_CENTER | OPC_ANIM_ALIGNV_BOTTOM |
OPC_ANIM_FONT_OPEN_10 | OPC_ANIM_COLOR_RED,
OPC_ANIM_REG_L_INT, OPC_ANIM_REG_Y_INT, OPC_ANIM_REG_S_STR);
op_anim_macro_close (mid);
Details
The regid argument of this KP takes a macro register ID symbolic constant, as listed under “Animation Macro Register Identifier Symbolic Constants—Integer Values“ on page 8. The value specified by the regval argument will be assigned to the indicated register during the macro invocation. This value is considered a constant within the macro definition, since all invocations of the macro will have the same value assignment.
Purpose
Provides a mechanism to internally set a macro’s register to a passed value, which is necessary to perform arithmetic operations within a macro involving constant values (the KP op_anim_mgp_arop() only accepts register arguments, and cannot be passed literal values).
Errors
- Recoverable Error: Animation macro ID (
<anmid>) is [out-of-range] [unrecognized]. (former case due toanmidargument value that is invalid, latter case to destroyed macro) - Recoverable Error: Animation macro register ID (
<regid>) is invalid. (due to an invalid value for theregidargument)
Reference
- Use the KP op_anim_mgp_arop() to perform an arithmetic operation involving registers within a macro
- Use the KP op_anim_macro_create() to create an empty macro
- Use the KP op_anim_macro_close() to indicate the completion of a macro definition
- Use the KP op_anim_igp_macro_draw() to invoke a macro within a viewer