Referencing a panel element by a variable
Posted: Wed Mar 17, 2021 7:57 pm
Hello,
I'm making a tester that tests 12 devices at once, and I want my Interface Panel to have 12 buttons that I turn green or red depending on if a particular device passes or fails a standard test. Each of the 12 buttons corresponds to a device. Example Interface Panel included below.
Is there a way to accomplish this?:
for(i = 0; i++; i < 12){
if(a(i) and b(i) and c(i) and (d(i) > e(i))){
mystring = "IPButton"+i; // I try to make a string out of my index i
MyPanel.SetText(F(mystring), F("Device has passed the test!")); // the button related to device i is updated, if only (mystring) would evaluate to IPButton1
}
}
I want to chose to update a particular button based on the logic. There's a nontrivial amount of logic going into the decision to update each one and it's all exactly the same so I'd hate to have to copy it 12 times and end up maintaining 12 instances of the same logic just to point at the UI elements.
Thank you!
I'm making a tester that tests 12 devices at once, and I want my Interface Panel to have 12 buttons that I turn green or red depending on if a particular device passes or fails a standard test. Each of the 12 buttons corresponds to a device. Example Interface Panel included below.
Is there a way to accomplish this?:
for(i = 0; i++; i < 12){
if(a(i) and b(i) and c(i) and (d(i) > e(i))){
mystring = "IPButton"+i; // I try to make a string out of my index i
MyPanel.SetText(F(mystring), F("Device has passed the test!")); // the button related to device i is updated, if only (mystring) would evaluate to IPButton1
}
}
I want to chose to update a particular button based on the logic. There's a nontrivial amount of logic going into the decision to update each one and it's all exactly the same so I'd hate to have to copy it 12 times and end up maintaining 12 instances of the same logic just to point at the UI elements.
Thank you!