I think the problem is using array variables ... By creating proper byte variables everything works as I expect ...
I think the problem is using array variables ... By creating proper byte variables everything works as I expect ...
- Ipsa scientia potestas est -
if ByteCnt=2 how many times will it run through this for/next loop ?
FOR GP=0 to ByteCnt ' Clear array bytes 0 to ByteCnt
BytesIn[GP]=0
NEXT
when you set BytesIn[2] to 0 what var do you think will get clobbered
its not a Strange Variable Issue ... its a write to an out of bounds array index
Hmm I've changed the line as follows
And it works as expected ... Thank you for your answer Richard ..FOR GP=0 to ByteCnt-1 ' Clear array bytes 0 to ByteCnt
BytesIn[GP]=0
NEXT
Now can you explain what happens when it tries to clear a nonexisting variable ? It clobbers my DAT variable next as it should not , yet somehow it does .. ?
I think there is something happening on the background that is out of my knowledge ..
- Ipsa scientia potestas est -
from the manual
A single Array Variable can be visualized as a list of values. The variable name is
how you access the list, and a number –or index– is used to point to any single
value within the list.
The index value is enclosed in brackets and appended after the array variable's
name.
myarray[index] = 0
The index can be a literal number, a variable, or an expression.
For the following examples, an array named "stored" is used:
stored VAR WORD[8] 'Create an array named "stored"
with 8 elements.
Note that the 8 elements in our array are numbered 0 through 7. There is no
element-8. This is very important, because PBP doesn't place a limit at the end of
the array. If you write "stored[8]", PBP won't generate an error and you will be
accessing memory outside of the array. (The end of the array is stored[7] and there
is no stored[8].) This could have disastrous results and be very difficult to debug.
The elements of "stored" can be written individually:
stored[0] = 1260
stored[1] = 2500
Or, you might want to write values with a loop. You could read PORTB once per
second and save 8 readings:
FOR index = 0 TO 7 'Loop 8 times
stored[index] = PORTB 'Save value of PORTB
PAUSE 1000 'Wait a second
NEXT index 'Loop again
this is not just a pbp issue most 8 bit micro languages have the same limitation on array bounds checking ie . none at all
Thank you Richard , for the amazing explanations ... Good to know and keep such knowledges for the pic that is working on the background of my brain ..
- Ipsa scientia potestas est -
Bookmarks