Self variables to Designer codes.
Posted: Mon Aug 25, 2014 1:45 pm
Suppose I have 10 boxes in my designer project, and I want to keep track of how many times each of them have been clicked.
code would be roughly:
Problem is, if i want each of the ten boxes to do the same, I have to write them each their own code with variables boxa, boxb, boxc...
What I would really like is to simply instead of choosing to "Run Code" to choose "Run Program".
And then this Program would have a comman something like:
Selfvariable box
And then it would simply refer to:
box = box+1
And each time I would click on any of these boxes, the program would take care of keeping track of the clicks.
Not only would this save time by not needing to write same code several times, but in addition, if I want to make even a minor change to my code, then i have to do it 10 times now, when instead, I could simply alter the code that contains the self variable command that understands to use its own variable for each object that program is used.
code would be roughly:
Code: Select all
OnCLick:
boxa=boxa+1
text="Total amount of clicks on box a = "..boxa
What I would really like is to simply instead of choosing to "Run Code" to choose "Run Program".
And then this Program would have a comman something like:
Selfvariable box
And then it would simply refer to:
box = box+1
And each time I would click on any of these boxes, the program would take care of keeping track of the clicks.
Not only would this save time by not needing to write same code several times, but in addition, if I want to make even a minor change to my code, then i have to do it 10 times now, when instead, I could simply alter the code that contains the self variable command that understands to use its own variable for each object that program is used.