John Kauffman
11-21-2010, 09:21 PM
I seem to be using an array member that does not exist.
This is a test - I am trying to figure out why this happens. I don't need a fix. I know I can fix it by changing the code.
I believe I am following the information of bottom of page 210
The sequence of events, as I understand them:
I create an array of MyNumbers[7] so the members are named MyNumbers[0] ... [6]
I create a variable with the number of elements ArraySize = 7
I use a loop to fill the array from MyNumbers[0] to MyNumbers[7]
The filling and reading of MyNumbers[7] seems to work, even though there should only be members named MyNumbers[0] to MyNumbers[6].
What is happening that SPIN / Prop does not choke on filling an array variable that (I think) does not exist?
Thanks.
CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000
VAR
long MyNumbers[7] ' create array of longs: 7 members, numbered 0 to 6
long ArrayIndex ' used for loops - current index of MyNumber array
long ArraySize 'used for loops - number of members in array (=7)
OBJ
VgaText : "VGA_Text.spin"
PUB Start
ArraySize := 7
VgaText.Start(16)
''''''''''''''''''''''''
' * keep simple * seed array of 7 members with values 0...6, so index = value
repeat ArrayIndex from 0 to (ArraySize-1)
MyNumbers[ArrayIndex] := ArrayIndex
''''''''''''''''''''''''
'( debug display)
' next line expects to set up a failure
' by over-running number of members in array
' n.b. NOT using 'to ArraySize-1'
repeat ArrayIndex from 0 to ArraySize ' should try to fill a [7] which does not exist
MyNumbers[ArrayIndex] := ArrayIndex
' Above: ? On list iteration, how can a value be put in MyNumbers[7] that does not exist?
vgaText.dec(ArrayIndex)
vgaText.str(STRING(" holds "))
vgaText.dec(MyNumbers[ArrayIndex])
' Above: ? how can Prop return a value that is beyond range of array
vgaText.out(13)
WaitCnt(clkfreq*1/1 + cnt)
This is a test - I am trying to figure out why this happens. I don't need a fix. I know I can fix it by changing the code.
I believe I am following the information of bottom of page 210
The sequence of events, as I understand them:
I create an array of MyNumbers[7] so the members are named MyNumbers[0] ... [6]
I create a variable with the number of elements ArraySize = 7
I use a loop to fill the array from MyNumbers[0] to MyNumbers[7]
The filling and reading of MyNumbers[7] seems to work, even though there should only be members named MyNumbers[0] to MyNumbers[6].
What is happening that SPIN / Prop does not choke on filling an array variable that (I think) does not exist?
Thanks.
CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000
VAR
long MyNumbers[7] ' create array of longs: 7 members, numbered 0 to 6
long ArrayIndex ' used for loops - current index of MyNumber array
long ArraySize 'used for loops - number of members in array (=7)
OBJ
VgaText : "VGA_Text.spin"
PUB Start
ArraySize := 7
VgaText.Start(16)
''''''''''''''''''''''''
' * keep simple * seed array of 7 members with values 0...6, so index = value
repeat ArrayIndex from 0 to (ArraySize-1)
MyNumbers[ArrayIndex] := ArrayIndex
''''''''''''''''''''''''
'( debug display)
' next line expects to set up a failure
' by over-running number of members in array
' n.b. NOT using 'to ArraySize-1'
repeat ArrayIndex from 0 to ArraySize ' should try to fill a [7] which does not exist
MyNumbers[ArrayIndex] := ArrayIndex
' Above: ? On list iteration, how can a value be put in MyNumbers[7] that does not exist?
vgaText.dec(ArrayIndex)
vgaText.str(STRING(" holds "))
vgaText.dec(MyNumbers[ArrayIndex])
' Above: ? how can Prop return a value that is beyond range of array
vgaText.out(13)
WaitCnt(clkfreq*1/1 + cnt)