Arraywrite can't write word variables?
Hello.
As PBP manual states, page 35. It is possible to write word-size variables into word size array, using arraywrite statement. There is even an example.
Code:
stored VAR WORD[8]
ARRAYWRITE stored, [1260,2500,10000,0,0,100,200,400]
However, it does not works! When I try to add it into my code (which is empty and has only variable and pin defines), I'm getting the following error:
Only BYTE datatype with constant offset allowed.
The chip is 16F886 and no other code is loaded.
Any ideas?
Re: Arraywrite can't write word variables?
You are using con or byte variable to read from the array.
Ioannis
Re: Arraywrite can't write word variables?
I'm not reading anything :)
the above quoted 2 line code from manual gives that error.
There is no more code in the program.
Re: Arraywrite can't write word variables?
Hmm, I can't test this right now but I think, perhaps, that particular line of example code is in error - which would be unfortunate, it being in the manual and all...
If you look at section 5.5 you'll find:
Quote:
ARRAYWRITE
ARRAYWRITE ArrayVar, {Maxlength, Label,}[Item...]
Write one or more Items to byte array ArrayVar using SEROUT2 modifiers.
ARRAYWRITE allows the writing of formatted data to a byte array which can then
be output by other compiler commands, such as I2CWRITE, to write to a serial
LCD, for example.
Arraywrite is good when you want to do conversions to ASCII etc but loading constant values to an array is better done the old fashioned way, it's way more efficient:
stored[0] = 1260
stored[1] = 2500
and so on.
/Henrik.
1 Attachment(s)
Re: Arraywrite can't write word variables?
You may have an older manual. I believe that mine is most recent and on page 37 that is attached here (and not 35) there is correct comment on BYTE and not WORD sized variable. Also nowhere within the manual is any state of WORD use in regard with ARRAYWRITE/ARRAYREAD.
Ioannis
1 Attachment(s)
Re: Arraywrite can't write word variables?
Haha yes, mine is different :)
Attachment 9149