TOC PREV NEXT INDEX

copy_on_change

Synopsis

make a one-way connection between two primitive objects

module copy_on_change {
int+read _trigger;
prim+read+req _input;
boolean+read on_inst;
prim+write _output;
};

Description

copy_on_change is used to make a one-way connection between two primitive objects. Any changes made to the object input parameter are copied to output . Changes made to output do not modify input .

When this module runs, it is equivalent to executing the V statement:

output = input;

This allows input and output to be set to any type of data as long as the values can be converted normally.

If you want to perform more than one assignment when an input changes or you want to change an object to a different value than input, you can use the parse_v module.

Input

trigger

This parameter is set to trigger copying input's value to output's value even if input has not changed. You do not normally need to set this parameter.

input

This parameter can be connected to any primitive object, scalar, or array. When its value changes, it is copied to output .

on_inst

If this parameter is non-zero, the copy is performed when the object is instanced. Otherwise, the copy is only performed when the value explicitly changes.

Output Port

output

This parameter can be connected to any primitive object, scalar, or array but it should be a compatible type to the value connected to input . The object connected to this parameter's value is modified when the value of input changes.

Example

This example shows a UIbutton being used to toggle the visibility of a UIfileDialog. When the button is pressed its do parameter is changed. This parameter is connected to the input parameter of copy_on_change which copies that value to output. The visible parameter of the UIfileDialog object is connected to this output. When it is non-zero, the UIfileDialog object appears. When the OK button of the UIfileDialog is pressed, it sets visible to 0 again. The copy_on_change module does not propagate that change back to the do parameter of the UIbutton.

UIshell UIshell;
UIbutton UIbutton {
parent => <-.UIshell;
};
GMOD.copy_on_change copy_on_change {
input => <-.UIbutton.do;
};
UIfileDialog UIfileDialog {
visible => <-.copy_on_change.output;
};

File


TOC PREV NEXT INDEX