assign values to an array of structs

General discussion on mikroBasic PRO for PIC32.
Post Reply
Author
Message
tnot
Posts: 5
Joined: 27 Dec 2019 00:11

assign values to an array of structs

#1 Post by tnot » 27 Dec 2019 00:27

I am working with an array of structs. here is the definition of the struct:
typedef struct fanStruct{
int brightness;
int speed;
int bladeCount;
int fanDiameter;
int modbusAddress;
unsigned char fanState;
unsigned char lightState;
unsigned char isLightKit;
char fanName[20];
}FanArray;

I can read from the array just fine with something like this: fans_progBar_1_7.position = fanArray[0].speed;
However nothing ive tried seems to work for reassigning the values inside the array.
for example fanArray[1][1] = 1; fanArray[1].speed = 1; both return invalid declarator errors.

Any help is appreciated.

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: assign values to an array of structs

#2 Post by jovana.medakovic » 27 Dec 2019 10:32

Hello,

The name of struct, FanArray, is the same like the name of the array, fanArray. The difference is only in the first letter.
So, try to change one of the names or go to Tools -> Options -> Output Settings and turn on Case Sensitive.

Kind regards,
Jovana

tnot
Posts: 5
Joined: 27 Dec 2019 00:11

Re: assign values to an array of structs

#3 Post by tnot » 27 Dec 2019 14:14

I tried selecting case sensitivity as well as renaming the array and im still not able to assign values to variables inside each individual struct within the array.

is this the correct syntax?
arrayOfFans[1].speed = 1;

the compiler says its expecting a semicolon but finding a period.

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: assign values to an array of structs

#4 Post by jovana.medakovic » 27 Dec 2019 15:33

Hi,

Yes, this is correct syntax, I tested it and I can build without any errors.
Can you tell me which version of the compiler you are using?
Can you zip and send me your project for review?
Also, send me a screenshot of the errors which you got?

Kind regards,
Jovana

tnot
Posts: 5
Joined: 27 Dec 2019 00:11

Re: assign values to an array of structs

#5 Post by tnot » 27 Dec 2019 15:52

oh my goodness, i'm in the wrong compiler forum. I should be in microC Pro for pic32.
my apologies, ill move my thread over there.

Post Reply

Return to “mikroBasic PRO for PIC32 General”