Array base problem
Posted: 07 October 2008, 4:24 AM
In the following code I was getting errors that looked like a wild pointer. When I manually specified the bases of the 2 arrays everything worked fine. If I let it use the default base (which should be 1, right?) then the subroutine would not work. It is acting as if the array base is not 1, maybe it is acting as if the array base is zero.
I searched all the files in the project and I never used "Option Base" at all.
Is this an issue with the compiler or do I have a programming bug somewhere?
-Tony
I searched all the files in the project and I never used "Option Base" at all.
Is this an issue with the compiler or do I have a programming bug somewhere?
-Tony
Code: Select all
Private Sub RangerTask()
Dim Range_Cmd(1 to 2) as byte
Dim Readings(1 to 3) as byte
'this does not work:
'Dim Range_Cmd(2) as byte
'Dim Readings(3) as byte
Dim Result as Integer
Dim Reg as byte
Do
Range_Cmd(1) = CmdReg
Range_Cmd(2) = RangeCmd
Result = I2CCmd(1,SRF08_ADDRESS, 2, Range_Cmd,0,0)
Call Delay(0.070)' 70mS wait for ranging to complete; 65ms min
Reg = LdrReg
Result = I2CCmd(1,SRF08_ADDRESS,1,Reg,3,Readings)
'Bytes: Light, Range_Hi, Range_Lo
Light = Readings(1)
Range = Cint(MakeWord(Readings(3), Readings(2)))
Loop While (RangerEnable)
End Sub