![]() |
![]() |
![]() |
![]() |
$print, $dprint, $save, and $save_usr
Synopsis
$print _[object]
$dprint [object]
$save _ [object]
$save_usr _[object]Description
These commands print an object's definition. With file redirection, you can use any of these commands to save the definition to a file.
The commands differ in the type of information they print:
$print Prints an object's definition, including program state, user state, and transient state.
$dprint Like $print, but also prints objects derived from the object's template.
$save Prints an object's definition, but only program state.
$save_usr Prints an object's definition, but only program state and user state. It does not include transient state.
State
State refers to how a characteristic of an object was established.
Program The characteristic is established by you, the programmer, either through V code or the Network Editor. For example, you create a UIfield object, set its x and y subobjects, and connect the value subobject to some other object. The new object, the values assigned to x and y, and the connection are all characteristics established under program state.
When you save an object's definition, you always want to save at least the characteristics established under program state. You can do this with the $save command.
User The characteristic is established through a user-interface object, such as a UIfield or UIslider widget. For example, the user enters a filename to read a data file. This action sets the filename value of some object (typically a subobject of a reader like Read Geom). The assignment is a characteristic established under user state.
When you save an object's definition, you may want to save both program state and user state. You can do this with the $save_usr command.
Transient The characteristic is established through a user function.
Setting the state
You can set the state explicitly with the $push command.
Examples
The following example uses add_num, an example object whose method adds subobjects src_1 and src_2 and places the result in subobject res:
OM(SingleWindowApp) -> USER.add_num add_num1;
OM(SingleWindowApp) -> $print add_num1
USER.add_num add_num1;
OM(SingleWindowApp) -> $dprint add_num1
USER.add_num add_num1 {
float+read+notify+req src_1<NEportLevels={2,0}>;
float+read+notify+req src_2<NEportLevels={2,0}>;
float+write+nonotify res<NEportLevels={0,2}>;
method+notify_val+notify_inst update = "add_num";
};
OM(SingleWindowApp) -> add_num1.src_1 = 1.0;
OM(SingleWindowApp) -> add_num1.src_2 = 2.0;
OM(SingleWindowApp) -> $print add_num1
USER.add_num add_num1 {
src_1 = 1;
src_2 = 2;
res = 3;
};
OM(SingleWindowApp) -> $save_usr add_num1
USER.add_num add_num1 {
src_1 = 1;
src_2 = 2;
};In the $save_usr command, notice how the assignment to res is not printed. That is because the assignment was made in transient state; that is, through a user function.
File redirection
You can save the object to a file
OM(SingleWindowApp) -> $save_usr add_num1 > /home/vdir/temp.v
![]() |
![]() |
![]() |
![]() |