Hi Guys,
I couldn't find the answer how to initialize the array in FC7 ( so the simulation not complines as an Error) and not sure if this error would have any influence on the compiler?
The only way which I figure it out so far is by assigning the value it in the calculation block, but this is really painfull exercise as I cannot figure out working syntax apart individual variable (test_array[5][5][2]):
test_array[0][0][0] = 0
test_array[0][0][1] = 0
test_array[0][0][2] = 0
.........
test_array[4][4][1] = 0
So this declaration would have 50 lines
I would expect that something like this is possible in case all variables are 0:
test_array = {0} or test_array[]={0}
Making the loop is another option which I will do in the desperation, but only if there is no other (proper) way.
I would expect that it should be 'automatically' initialized as '0' if the variable is global and if is not declared differently.
Could you please provide some more details how to do it in FC7 and how this is passed to the c code and to the PIC18 compiler?
Regards,
Igor
How to initialise the array?
Moderator: Benj
-
- Posts: 78
- Joined: Mon Jul 31, 2017 11:14 am
- Has thanked: 7 times
- Been thanked: 13 times
- Contact:
-
- Posts: 188
- Joined: Thu Jun 28, 2012 7:29 pm
- Location: Durham
- Has thanked: 86 times
- Been thanked: 186 times
- Contact:
Re: How to initialise the array?
Hi Igor
The way I understand the way to set up an array is as follows:
When the variable is declared, I place the size of the array using [ ] as you have within the set up box shown above.
Each value can then be defined using the calculation icon.
Hope this helps.
Regards
Dave
The way I understand the way to set up an array is as follows:
When the variable is declared, I place the size of the array using [ ] as you have within the set up box shown above.
Each value can then be defined using the calculation icon.
Hope this helps.
Regards
Dave
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: How to initialise the array?
I think the easiest way for a large array is to have a loop or nested loop for multi dimensional arrays.
For example TestArray[10]
For example TestArray[10][10]
For example TestArray[10]
Code: Select all
index = 0
while (index < 10)
{
TestArray[index] = 0
index = index + 1
}
Code: Select all
index = 0
while (index < 10)
{
index2 = 0
while (index2 < 10)
{
TestArray[index][index2] = 0
index2 = index2 + 1
}
index = index + 1
}
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel