I am still learning Pic Basic Pro and have come up with a problem in understanding Arrays!
From the manual I understand how to define the Arrays name and size eg. sharks VAR BYTE [10] gives an Array with 10 elements and I think I understand how to access the elements. BUT what I am baffled about is the method of loading the data I want into the array?
I mean to say, continuing the manuals shark theme, if I wanted the array to consist of tiger, great white, lemon, nurse etc, what is the actual syntax I would use to make the array and where would this line/s be placed? IE inside the main, before main or after main?
I'm not sure that PBP allows multidimensional arrays! An array of strings has usually two dimensions ie. names[10][string length] . To do this you will need to make n' arrays of fixed length ( longest text ) and initialize them individually (laborious) The easiest way for you to do this is with the lookup command
Code:
For B = 0 to 5 ' Count from 0 to 5
LOOKUP B,[“Hello!”],B1 ' Get character number B from string to variable B1
array[B] = B1 ' Send character in B1 to array
Next B ' Do next character
hi Al,
This runs in Oshonsoft, had to make a few changes.
Code:
AllDigital
Dim n As Byte
Dim result As Byte
TRISB = 0
main:
For n = 0 To 7
result = LookUp(1, 2, 4, 8, 16, 32, 64, 128), n
'PAUSE 1000
PORTB = [B][COLOR=Red]RESULT[/COLOR][/B]
Next n
Goto main
End