end
Allows you to use the IF, ELSE, ELSEIF, and END commands to execute a group of commands conditionally. The execution of commands bracketed by IF and END depends on the value of an expression.
You can nest any combination of looping (FOR/END, WHILE/END) and conditional constructs (IF/ELSEIF/ELSE/END).
Note: | As with all Adams View commands, you can use the IF, ELSE, ELSEIF, and END commands on the command line, in macros, and in command files. |
Format:
end |
|---|
if condition = | (expression) |
elseif condition = | (expression) |
else | (optional) |
end | |
Example:
! Bodies
variable create variable=object_type string=(eval(DB_TYPE(.MDI.obj)))
if condition=(object_type == "marker")
interface command_builder command="marker modify marker" initial=(.MDI.obj)
elseif condition=(object_type == "point")
interface dialog display dialog=.gui.main_objecttable parameter="Points"
elseif condition=(object_type == "flexible_body")
interface dialog display dialog=.gui.flx_dia_panel parameter=(.MDI.obj)
! Constraints - complex joints
elseif condition=(object_type == "coupler" )
interface dialog display dialog=.gui.coupler_cremod parameter=(.MDI.obj)
elseif condition=(object_type == "gear" )
interface command_builder command="constraint modify complex_joint gear" initial=(.MDI.obj)
! Constraints - Higher Pair contact
elseif condition=(object_type == "curve_curve" )
interface command_builder command="constraint modify higher_pair_contact curve_curve" init=(.MDI.obj)
elseif condition=(object_type == "point_curve" )
interface command_builder command="constraint modify higher_pair_contact point_curve" init=(.MDI.obj)
end
The above example illustrates how to use ELSEIF to determine the type of object and then perform an operation on the object based on the object's type. The example assumes that an Adams View variable named .mdi.org exists and its type is database object.