Hi - I have a table of arrays (dunno if that's the correct terminology) and I would like to count/reference specific items in each. I've highlighted the things I'd like to count:
int blNum;
int blMax = 15;
struct Blocks
{
int blNum;
int blStatus;
long blWinds;
int blRPM;
int blAccel;
int blAreaL;
int blAreaR;
int blScatter;
int blWPS;
float ptArea;
float ptInterval;
int ptSpeed;
} const BlockTable[] =
{
{1, **1**, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0},
{2, **1**, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0},
{3, **1**, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0},
{4, **0**, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0},
{5, **0**, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0},
{6, **0**, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0},
{7, **0**, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0},
{8, **0**, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0},
{9, **0**, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0},
{10, **0**, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0},
{11, **0**, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0},
{12, **0**, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0},
{13, **0**, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0},
{14, **0**, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0},
{15, **0**, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0},
};
Blocks x = BlockTable[blNum - 1];
This is the code I have trying to count them - the number should come out to 3 if done correctly:
void blockManager() {
for (int i = 0; i < blMax; i ++) {
if (BlockTable[i][1] != 0) {
blocksTotal = blocksTotal + 1;
};
};
};
Been trying to use this resource as a guide. I get the following compile error:
/Users/jtb/Downloads/AC-2_Current/AC-2_Current.ino: In function 'void blockManager()':
AC-2_Current:1431:22: error: no match for 'operator[]' (operand types are 'const Blocks' and 'int')
if (BlockTable[i][2] != 0) {
^
Multiple libraries were found for "WiFi.h"
Used: /Users/jtb/Library/Arduino15/packages/esp32/hardware/esp32/1.0.6/libraries/WiFi
Not used: /Applications/Arduino.app/Contents/Java/libraries/WiFi
exit status 1
no match for 'operator[]' (operand types are 'const Blocks' and 'int')
I put that little "Blocks x = BlockTable[blNum - 1];" line up there for later use, but maybe that could be useful here? I just don't know how to go about it. Thank you.
//Woops, apparently I can't make text bold in code formatting, sorry about that.