Box Visibility Based on IF Statement


Recommended Posts

Howdy,

I am trying to get an edit box to be visible under certain criteria.

The "Component" Box in the attached image writes to a channel called "Component_Type". I only want the "BRAKE WO" edit box to be visible if the user selects some of the options in the drop down component list.

My current code is as follows:

 

if (COMPONENT_TYPE[0] = "desired_component")
Component.BRAKE_WO_BOX.visible = 1
else
Component.BRAKE_WO_BOX.visible = 0
endif
 

However it doesn't seem to work. (This has been inserted into the visibility option of the edit box). If you guys could provide some guidance that would be great. Both on how to get it working, and how to include a few options for the 'desired components' within the if statement.Capture.PNG.5933d3fcf40ca05077139b9be076cb47.PNG

 

Link to comment
Share on other sites

  • 4 weeks later...

You want to put that code in the Event for COMPONENT_TYPE so that it gets executed whenever component_type changes.  The visibility option for the edit box needs to be an expression, so as an alternative to the if() statement in the Event, you could just put this:

COMPONENT_TYPE[0] == "desired_component"

in the Visible expression.  Whenever you see "Expression" you should think a "formula" that returns a value.  In this case, if the value it returns is non-zero, it is true and the component is visible.  If it is 0, it is not visible.  Also note that you need to use == for comparison. A single = is assignment.

Of course the Event version gives you the ability to then do other stuff depending on what component_type is selected. 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.