if - else in for loop help
-
I have an interface with 2 buttons and 1 knob. If any of the 2 buttons is pushed, I'd like to hide the knob.
I've created a function that will show/hide the knob, as well as a for-loop that contains the button array for triggering the control callback, but it doesn't function as I thought it would. Only button 2 hides the knob.
Anyone see my mistake?HiseSnippet 971.3ocsV01aaaCDlx1ZaVstnEX+.HxmjQSCj85KCHKXtwIYvnKoF0sYCnnnfQhJlHRjFTTsyHH+0F5Oo9OX6HkjkrqxK1.UeR7t643yc73cbrT3SSRDRjU62NeFEYce6Iy4poCmRXbznCPVOv9XRhhJwYh1e9LRRBM.YY07OzBrZ2BY995uuOIhv8okhPnSELe5exhYpRoiG7JVTzQj.5aYwUr9oCF4K3CEQhTfOMs8PyH9WPNmdBQaVCaj0ObX.SIjSTDEMArYeQv7ISEelmY+orD1YQT8hdnIfixDiFNkEELtHVSPHqViKi7lYQ9OaeLKfsPdYF3gFE3RDUyAVMVlRsVhR8tNJcjHJP6fqgdVUnWqL58H6I9R1LUoFM2tm8HNb3DRfzdUZkYKpwmaZOT.VvU6DStfdjDVr.g6y871F+LOut61woiCj7ST3OQj38SUJAuGdObA3yopgh3YBNrvcqb8aowsJp92Bp9aU+t8RojLGv99aYK2tiC959tk88CqrwuhKN65CRi1bx1wgwiXbJNLk6qXBNVvyYjFrTD45Wfbav2QoztcbtLipgBI1kg2yaWLC+aUC2chn7yUSA4O9wcyL9xxviEhcqX76YePyvS0N2sKdu8v85VZ7kKmVLjemDnNrfegjnDZ2cWX0Uk.nfl0vSJY5RNxI2cs63bkIacmC37sZkfLQeLX1pgjnnyfd.tqlsgs+JyNUdbbhPQeM2sqykNsc.NsppvvZ0k6vHprV05NTxaBnKOM9Lpr3PuvP3Z6x8Et2cqufeVoXECE7Qbl50yn4qK6bn0kE0EZ8PKB1phJiwpRMgVMlUJ5aaLgxup.snZlaN7mxzf5A4MnxNoPLfissyO1PlrS0ACn0.d+0.9jHV.UZf+i1lZ2Z.+tQGPTDce173AhwYTohoOorNf9IXnUVW211GPStPIlYB37a3vg6cHj+Gjks0eA61b8O+aFoWCOzW6gBRe5f4KV7k3A2fmpIAT5mAU8C5cCPe6bFXZmHHMhnVdDndVetBn9eoYM54I7DlZd02BrFyE8pctXu5J+tiz8Q1iYJ+o0y2F0vWnT36MeyekQG6CCCo9pRx1x9n+dSeRwZPk2HRUL94GSTRltz7jz3IvCs7o.S3bXDftJsgtHMasmdsNyLgxCLK9O3KWYO8Zqbk8JThhI9RwG8ytZpeGyOYj.bhadBWa3sjvZ7h6j11d63ghgmW8Qeecp3I.2qGS+M.yurAXd5Ff4Ya.lmuAXdwFf4WuQL5W19xTkHN6ZBHX7gldiVVGxIPUlohD8+zepCAE
-
Looks like if I change my function to this it works
inline function onButton1Control(component, value) { Knob1.showControl(true); for (i =0; i < ButtonArray.length; i++) { if (ButtonArray[i].getValue() == 1) { Knob1.showControl(false); } } };
but still not sure why the original wouldn't work
-
@dustbro said in if - else in for loop help:
If any of the 2 buttons is pushed, I'd like to hide the knob.
that's not clear to me... Do you mean the knob should be hidden as long as a button is still ON?
What if the two are ON?
What if clicked OFF? -
This is how I would do it. Note that the buttons have
saveInPreset
set to false.HiseSnippet 866.3ocsV09SZCDF+JR2FcCyLYeeM9IHnFvotkvVFxaKDmJYnlkXLli1C3hs20b8paDi+us+j1+AaOWagVb.S9f8KjmW98b+tm2N5J3VDeet.ok6rwdDj1qz6MlIG0XDlxPcZhzVW+XrujHLiTUerG12mXizzV6KJEZ4xhB+98mqicvLKRhJD5BN0h7UpKUlnsasinNNsw1jynto7duZcr3rFbGd.vm0zKi7vV2fGRNAqbKiNR6YsroRtnmDKI9Hsr041i6Mh+CVj+WP8o8cHJgJndPfhT2l6XqXrRKpwHpic2I2aeDDktIYg0hxBuQ+XpMcp9jrwqCMXlfHc9PKyxnWkzzq7imdZonW1H5sgdOKA0SlXQwsWp2gAEpAXnDjlVQ9hx71L5M3fGL4Nt3aHsEfvTDENnb4sL2ub4hUyaj2.JD9RyawByiX79UL+j4DnCIxFbWONCDJrYn0MUXRPTOPJ4rCEB7X.2kWAFMWzWdiAbgYAJ3X4plTyOZtK7SoREyabWDrTQ6R5UKjHQtsYoBzRUJVr57vtiuBASJ3NMvNN8glqBbVjOUhMTrpw8p6Ok4PYDyAALKIkyLeneErlbzaA2Ym.RBgCSI63Ck8I9VY6HWplKuw8USEyS3RxorBEMtyHmw8FlOzzfAy0VbbcHh4ZVMUIVFvBr.29DwDlOwQn8Z19W8E2+ld7xJpfjxQNqCiJO0ivVTWMJtJp5uiYE3pLr6d83t6dNTah.Qgl3mqGlUQgDN89Ez4cZhk3IgAhHbJdDgjpt.ZMI2B6ehFZxo2j3eij6AGzzFG3RN6gFUlCOzb5w0bzOmdj+57ZiSDFVyGeKoCqqf.8VpYMzJE4cSEYzEoir6Rib1+ahJIt0RGWz40P+65DXoF2NvAKmcSmZ8drAn8YlUJp0FLepbb50+OIq+drzcC8tTo0n4y2LyguPKySMeieLIudqACHVxDxlUu82e5e4.8MdfjxFdLVJnPCg9IAt8f2VsH.SXLhiZDWKiZXLRtrRVkY5QX1gB+A9hMVQIqEarxDiHWrkfesUzHr54pWDpA3DK7U6bvee.jMmN6p3sK7F50VVpDw1.ymOhcWYDuakQr2JiX+UFwAqLh2uxH9vRPn9CKGFH4tQiEfhtsB2Ypo0hggtpvNPzeAHQ3xRA
-
@d-healey with your solution, if you click ON both of the buttons, and click OFF any off them, the knob comes back
-
@ustk If either of the buttons = value, the knob is hidden. Otherwise the knob is shown.
-
@ustk said in if - else in for loop help:
if you click ON both of the buttons, and click OFF any off them, the knob comes back
That still might work. the buttons would be set to momentary.
-
I assumed you wanted a way for the knob to be shown again?
-
@dustbro David has a good question, if set to momentary, I guess a new click bring it back?
-
Not sure it is what you want but...
HiseSnippet 889.3ocsVEtaSCCD1ocFnEFhIwCfU+UpzVU5.FHMgnacqnpQGUT1DRHDxMwc0ZI1UNNCpl16FOR7F.mcRVxftosJsz+z6N+c96Ne2YOTI8YwwRExo1mmOigbdBdzbgdZ2oTt.0eOjySwCnwZlhjpZ24ynwwr.jiS02aT3TaEj862uaWZHU3yJTgPGK49rOvi35BsC6b.OLrGMf8YdToU+xN88khtxPYBvmpXOzLp+ozSXGRMKqBF47f8C3ZoZjlpYwHmU1UFLezT4ODoq+XdLebHyHzFMBbTp5dxv.CiMZQcmxCCFlG2wHvKCKxBUSyBOGOfGvuTeQ13YVCjBDkyGNUtI50tL87t8zyoD8VIkdqgG4q3yzEVLb6w39B3fZBENBJSqz0hpLnBtqDVgP2JhdJqmBDtDg6VddqSdkmWysWst4GbTDqImQUjcSzZoXGkhNm7VxWy8wILcWYzLo.Dbajtn1MZt9p0IW22MAcyFM+11WciOPHG2F1xECyZsQNc4hPtfQljH70bofHEYLx.VICc8yQtN36vDVyUqedJU4SHtopNuf6E+ytOshgiwbW0lrQlVfQtMNK8XsQSCWLHtvPnK.gIREwcLgKJmCaRF2J1DIVm0kFFNFJyc+WB2baabUJfNTpYeT31r940qU+h5j+0zjIKzVl+BYpEZ1zCptIfthjnwLUdZKegPw3Uq1wWe0d4lQ+zCyRKTJ5K35ONiIttd.TVE.zMTMiUv+z1dgml0Kjl8PbnjuFNKUhrTt77Hzc.9l2A3iB4ALkE9Cw1ZiE.9n96Q0TSKcV7.w3LlRyMoOm8XmAyJSavqg2iEepVNyFvYEtPJ9VDx+7xs7WG0YdgvIc3wCjQfenJPsSEzcxwaVxwniK63n6fiWPZpvscJ6VzQcNKu.xoJ5+mABShkAIgT8UGOatSJy.TEek4flYchXtdd46rtWlYeao6Z3gbs+zEy2JKfuPsy8MeytAbU79Slv70EjcEbuub+ecG5SxDMWbx.pVwgZC7gIQifGD3y.lHDrPyjFnFy.0J6YjMYlQLQfU3OvWlw1FYmLisyMhhn9J428S6kM2w9HqFfSB6SMpAu4AjIW1Diwds7PQvU+e222jJ1.39hwr4Rf4EKAlWtDXd0RfYqk.yqWBLu4FwXd00NIZYTZaBnX391goNN6KnPUlshD8WSza3gC
-
Think I understood... You want the knob to come back on button release, following your code...
In this case this one line does the same thing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