I've tried various types for 'h' and other ways to get what I need such as String h[1] and String h
What I need:
User inputs some characters but is not allowed to repeat any.
This becomes test_str. This is probably an awkward way to input data but it's the only way I have found. It would be easier to check the string as it is being made, I suspect.
error is reported on this line "if (h == test_str.substring(t+1))"
error: no match for 'operator==' (operand types are 'char' and 'String')
What I need:
User inputs some characters but is not allowed to repeat any.
This becomes test_str. This is probably an awkward way to input data but it's the only way I have found. It would be easier to check the string as it is being made, I suspect.
error is reported on this line "if (h == test_str.substring(t+1))"
error: no match for 'operator==' (operand types are 'char' and 'String')
Code:
String answers; unsigned int randNumber; String send_char; String test_str;
Serial.flush();
Serial.println("Enter the characters you want sent. Then press Esc to continue");
Serial.setTimeout(10000);
test_str.concat(Serial.readStringUntil(27)); // 10 seconds or Esc
while (test_str.length() > 43)
{
Serial.println("Too many characters. Try again. Max:44");
test_str = "";
test_str.concat(Serial.readStringUntil(27));
}
Serial.setTimeout(1000); // reset key timeout to a more reasonable length
test_str.toLowerCase();
for (unsigned int t = 0; t < test_str.length(); t++)
{
char h;
h = test_str[t];
if (h == test_str.substring(t+1)) // <----------------problem
{
Serial.println("Do not include the same character more than once.");
}
}
Last edited: