ON/OFF with Variables
bgrebner
Posts: 1
What do ON or OFF do to a variable if the variable is an array? I need to set all elements of an array to zero in response to a button event. Would something like ARRAY ="0,0,0,0" be the best way to do this in a single line?
0
Comments
I must not know or remember a simple way to do this I tried ARRAY[]={0,0,0,0,0} and a multitude of other things. Perhaps someone else knows the stupid-simple way. Failing that...
you could do several things.
grunt-n-groan method...
or you could put the thing in a for loop if it's a big array.
There's several ways to skin that cat. Hopefully someone will chime in with the easy ARRAY= whatever it is to get it done...
Every little problem like this is an opportunity to create a standard routine:
This solution feels a little clumsy and is a waste of memory but it works well.
Your method uses less memory, less code and less processor than mine, so it's not "wasteful" at all. Sometimes solutions like that are the best approach.
But of course your solution isn't generalised in application so "clumsy" is OK by me 8^)