I have been haggling with this now for two days. Looking online and trying various ideas I just can't seem to get this to work or find comparable code to what I'm trying to accomplish. I think I have been pretty clear about what I am wanting to do.
I know the variable or array has to be predefined as dynamic variables are not possible.
I am trying to have the code formulate the array name from text "Remote_Device" and joining it with the Device_ID in order to populate the correct array item with incoming serial data.
I am currently getting the Error:
exit status 1
invalid operands of types 'const char*' and 'const char [4]' to binary 'operator+'
See code for further explanation of goal.
int Remote_Device1[30];
int Remote_Device2[30];
int Remote_Device3[30];
int Remote_Device4[30];
int Remote_Device5[30];
int Remote_Device6[30];
int Remote_Device7[30];
int Remote_Device8[30];
int Remote_Device9[30];
int Remote_Device10[30];
int Remote_Device11[30];
int Remote_Device12[30];
int Remote_Device13[30];
int Remote_Device14[30];
int Remote_Device15[30];
int Remote_Device16[30];
int Remote_Device17[30];
int Remote_Device18[30];
int Remote_Device19[30];
int Remote_Device20[30];
int Remote_Device21[30];
int Remote_Device22[30];
int Remote_Device23[30];
int Remote_Device24[30];
int Remote_Device25[30];
int Remote_Device26[30];
int Remote_Device27[30];
int Remote_Device28[30];
int Remote_Device29[30];
int Remote_Device30[30];
int Remote_Device31[30];
int Remote_Device32[30];
String Device = getStringPartByNr(INData, ' ', 1); //OUTSOURCED FUNCTION
int Device_ID = Device.toInt();
int Dev;
for (Dev = 0; Dev < 32; Dev = Dev + 1) {
if (Device_ID == Dev)
{
"Remote_Device" + Device_ID + "[0]" = Device_ID;
/* Explanation of Goal:
*
* For: Restrict to numbers less than 32 and process if this is so.
*
* if (the Device ID received from the Serial Packet is = to the Dev value from the for loop
*
* Locate the appropriate predefined array that matches the Device_ID and populate [0] with the device
* ID
*
* in shorter terms,
* Device_ID = Dev_Value, if true, find predefined array Remote_DeviceDevice_ID[0] and populate it with
* Device_ID
*
*
*--
*Credit where credit is due:
*
*//OUTSOURCED FUNCTION
*https://github.com/BenTommyE/Arduino_getStringPartByNr
*
*/
}
Thank You Ladies and Gents, in advance..
Hoffy