array problem
udi
Posts: 107
I have a problem with doing an array of integer.
I declared the array:
INTEGER CODE [4]
And I want that if code[index] is null, insert a number. And after the array is full I want to send something and then I want to clear the array.
How can I check if the array is null? And how can I clear the array?
Thanks for any help that leads me in the right direction. Examples are very much appreciated
I declared the array:
INTEGER CODE [4]
And I want that if code[index] is null, insert a number. And after the array is full I want to send something and then I want to clear the array.
How can I check if the array is null? And how can I clear the array?
Thanks for any help that leads me in the right direction. Examples are very much appreciated
0
Comments
code[index] can't really be null. At initialization it will be equal to 0 until modified to some other value. If 0 is a valid number then checking to see if its 0 won't tell you if its been made equal to 0 or is still 0 from initialization.
Paul
Depends on how you want to define it. I think of the control character as nul, and null is no value, not even 0.
That works and is what I end up doing if I need to do some math on the values. If its just being stored to send off as a command I will use characters rather than integers. That way you can use the integer 0 as nul and don't have to deal with sintegers.
ie:
char CODE [4]
CODE[1] = 0 // no value received
CODE[1] = '0' // contains the value of ascii zero
It also makes 'clearing' the array a little simpler without needing a for loop.
CODE = "$00,$00,$00,$00"
Paul
For all intents in NetLinx it does, since NetLinx initializes numeric variables to 0. Many programming languages do not though, and it means nothing has been assigned ... so if you try using it, you wind up with whatever value was sitting at that memory address. That's how those "null pointer" exploits work, they finagle a way to access memory they shouldn't be able to.