I'm having serious problems with arrays.
I'm using PIC18F47k42
N.1
I know that only arrays of bytes are allowed.
However when writing: "Dim array(50) as Word" or "Dim array(50) as Long" does not generate a compiler error.
Accordingly, the first question: May I have arrays of Word or Long elements?
Actually, according to a GCB manual, I'm using only arrays of bytes.
N.2
I'm expected that all variables and arrays of a code should be blank before starting any computation. Is this correct?
In my code I have arrays of bytes. If I print the content of the array just before any computation is made, the elements of the array are not blank.
Is it possible thet there are allocation problems due to the compiler operations ? I mean that some array elements can be writen by the allocation of "variables" with an assigned value at the compilation time (as an example, names of colors, needed constants, etc)
I do not know how to efford this difficulty.
I hope somebody will have some suggestion to analyze the problem
Giuseppe
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Arrays can be byte, word, long or integer. Can you share where in the Help does it state byte only?
Arrays and all variables are NOT initialised to 0 for PIC and AVR. For LGT the RAM is initialised as 0 ( as I wrote the initialisation routine for these chips.). If you need an empty array, you should always set all elements to 0.
Hope this helps.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for your answer.
My conviction stems from the use of an old version of GCB where the IDE help reported that only byte arrays were allowed.
Now I have downloaded version 99. 01 which reports exactly what you wrote.
I apologize for the question, I'm sorry.
Maybe I should just consider using long variable arrays to solve my problem.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm having serious problems with arrays.
I'm using PIC18F47k42
N.1
I know that only arrays of bytes are allowed.
However when writing: "Dim array(50) as Word" or "Dim array(50) as Long" does not generate a compiler error.
Accordingly, the first question: May I have arrays of Word or Long elements?
Actually, according to a GCB manual, I'm using only arrays of bytes.
N.2
I'm expected that all variables and arrays of a code should be blank before starting any computation. Is this correct?
In my code I have arrays of bytes. If I print the content of the array just before any computation is made, the elements of the array are not blank.
Is it possible thet there are allocation problems due to the compiler operations ? I mean that some array elements can be writen by the allocation of "variables" with an assigned value at the compilation time (as an example, names of colors, needed constants, etc)
I do not know how to efford this difficulty.
I hope somebody will have some suggestion to analyze the problem
Giuseppe
Hi Giuseppe
Arrays can be byte, word, long or integer. Can you share where in the Help does it state byte only?
Arrays and all variables are NOT initialised to 0 for PIC and AVR. For LGT the RAM is initialised as 0 ( as I wrote the initialisation routine for these chips.). If you need an empty array, you should always set all elements to 0.
Hope this helps.
Hi Anobium
Thanks for your answer.
My conviction stems from the use of an old version of GCB where the IDE help reported that only byte arrays were allowed.
Now I have downloaded version 99. 01 which reports exactly what you wrote.
I apologize for the question, I'm sorry.
Maybe I should just consider using long variable arrays to solve my problem.
0.99.01 is a very old version. Can you check what version the compiler is?