PDA

View Full Version : Arraywrite can't write word variables?



CuriousOne
- 13th January 2022, 19:20
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.



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?

Ioannis
- 13th January 2022, 20:06
You are using con or byte variable to read from the array.

Ioannis

CuriousOne
- 13th January 2022, 21:15
I'm not reading anything :)
the above quoted 2 line code from manual gives that error.
There is no more code in the program.

HenrikOlsson
- 14th January 2022, 05:50
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:


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.

Ioannis
- 14th January 2022, 06:27
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

CuriousOne
- 14th January 2022, 06:39
Haha yes, mine is different :)

9149