AnyLogic - make many edit boxes visible depending on variable

Viewed 13

Here is a simplified example of my problem: enter image description here

I want to make the edit box 1 or 2 visible, depending on whether a checkbox of box 1 or box 2 is checked. The variables "variableCheckbox1" and "variableCheckbox2" are connected to the respective ceckboxes.

I have written a function as shown in the picture. The function is called from the EditBox 1 ("Enabled"). This is a possible solution for ONE box each.

Does anyone have an idea if there is a more elegant way to do this for a very high number of checkboxes / edit boxes? A possible solution would be to write a function with a switch case for each variable in my model, called from each box. A very inelegant solution would be to make a single function for each box, but I don't consider that a good way.

2 Answers

If you want this for a large number, turn the entire setup into its own agent type: Checkbox and editbox. Instantiate as needed, you can add a parameter to specify what this is about exactly...

This would be the most generic and powerful approach...

if this works for you, you can use replications for checkboxes and editboxes and associate them together through the index... and then just add the code in the visible field of the edit box... Of course you will have to determine their positions programatically

enter image description here

Related