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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share