indexOf Bug?
-
Shouldn't the code in this snippet print out the index of “Button1”?
I only get -1const buttons = Content.getAllComponents("Button"); Console.print(buttons.indexOf(Button1, 0, 0));
Snippet:
HiseSnippet 815.3ocsVstaSCCE1tqYhVtHlDO.QSBoVzzTRWnqUSH55MnB5VEcLw+FtNNqVKwNJwYrJDuP7Tvy.OI7a9CXmj0Kzns0NQpTUN9b9N9SemiONCB3XRXHO..KdxDeB.9HsgSXhwsFinLPu1.3C0NLH.M4DRn.zbhOJLjXCfvMdiJ.Xg7f3me85lHWDCSlsD.bJmhIum5QEyVcPi2Qcc6hrImP8lKZqF8vbVKtKORRlMzL.9H7EnyIGgTgkSC7VT3X.7EZlUq3ruo0H4u5UpZgF4TynloY85HRcGREaqp3ZHCKC.byN1TAOXn.IHgxj1jaOY3X9WXIavozP5HWhxvDLTtyIKCZMl5ZO3ZkID.f4GLSm1HQmdlVepMc55yzqmF6PeFh4EMXtahRlq.kfyQo7ITZKsg3.puXlmj5WOlfD3fj0l4oRRrfbOGp0hKifI10CcAoafzXJhRUML1QW9W4CJVTVeBE5ihDB4K5uR+ZXmSDG551h64yYR6vRa2LNlsUfjAExcI65GPYhRof2kxrIWcrSoj.M2QWtKFkKefSDCKnblNmcDWPNlUpbwuVrPwuUT+ec43joOEoB3ttjfLcqZ5BtIfkXQdiHA6neIxMhLMPoHuXkay6VkCmnQyEHm0iQEG6SRs6xcsUUD06KWmAohrpILkgxPEw06mjVuSDQ.UljBZoJJHl9yeXDrBvqb+fu28CtUFv+Xu1HAR02mJHRQxmDHnpZArM4R4jljSAEzZSBuPv8iUrzdR462AM6poa4ObaLYpQiO2.rRYpxRYRC98DQXExxdYjketxYwJir763AwKM+PN4haG4hDKNNSMnO0g7jxByPTyIXgTwj4uHXElwYbiy3tqTbKsATAdb1bLWFbT1F8+fio2L7XsNNNDrXFAyq08Sq60.2x1+AdjfxNuORDPkEZsih7FJuAESj6NiQbCU06bpllDaCksRAFRX1wF+Q9j5zTYCScZdsSfGBGvOCmb.Vc2yChWQxIV7cyEz5qr0yXnim7pvyv3ES0R.qrt.2acAZst.e45Br55Bb+0EXsaGn5KUNLRv8RN1..8GzIdNKD1ggjcfwcqf+hUq+NB
-
@Oli-Ullmann You haven't declared "Button1". Your array contains objects, not component names.
So this would work
Console.print(buttons.indexOf(buttons[0]));
But this wouldn't
Console.print(buttons.indexOf("Button1"));
-
@d-healey
Hey David,
Thanks, that makes sense!Is there a way to find a specific object within an array, or do I have to declare it with a variable first?
-
@Oli-Ullmann you could check for the id of that object
-
@ustk
But how? -
const buttons = Content.getAllComponents("Button"); for (b in buttons) { if (b.getId() == "Button1") Console.print(buttons.indexOf(b)); }
-
@ustk
Great, I didn't think of that. Thank you very much! :-)