Hello, I am attempting to make a for loop that will run 199 times so that I do not have to type out 1000 lines that will be printed to a web server. Here is the code I am currently working with.
for (int x = 1; x <= 199; x++){
String nameFP = 'nameFP' + String(x);
String fingerFP = 'fingerFP' + String(x);
String fpxA = 'fp' + String(x) + 'A';
client.print("<tr><td>1</td><td>" + [b]nameFP [/b]+ "</td><td>" + [b]fingerFP [/b]+ "</td><td>");
if ([b]fpxA [/b]== 1) {
client.print("<input type='checkbox' checked onclick=\"window.location.assign('[b]/fp" + x + "/0[/b]')\"/></td></tr>");
} else {
client.print("<input type='checkbox' onclick=\"window.location.assign('[b]/fp" + x + "/1[/b]')\"/></td></tr>");
}
}
I am having trouble with the "if" statement because I am trying to have fpxA equal the name of a variable depending on the value of x. For example: if x = 1, I want:
client.print("<tr><td>1</td><td>" + nameFP1 + "</td><td>" + fingerFP1 + "</td><td>");
if (fp1A == 1) {
client.print("<input type='checkbox' checked onclick=\"window.location.assign('/fp1/0')\"/></td></tr>");
} else {
client.print("<input type='checkbox' onclick=\"window.location.assign('/fp1/1')\"/></td></tr>");
to be returned from the for loop. All of the elements involving x are working as far as I am aware except for the condition within the 'if'. The error message I am receiving is "invalid conversion from 'int' to 'const char*' [-fpermissive]"
Does anyone know how to have the value of the variable fpxA be treated as the name of a variable?
Please let me know if I was unclear about anything or if further explanation / code is required.
Thank you,
James