gc9n
March 27, 2013, 3:26pm
1
Is there any way to use the TextFinder with a String variable?
for example, i want for every word of "A" char to get the value of it.......
this code doesnt work as you understand..
String mystringvar = "A1=54$A2=23$A3=32";
TextFinder finder(mystringvar );
while(finder.findUntil("A", "\n\r")){
int val = finder.getValue();
Serial.print(val ); Serial.print(",");
}
i want to get 54,23,32
You can maybe use strtok() to split the string into smaller parts and then use indexOf() to filter out the rest.
Try this, http://arduino.cc/en/Tutorial/StringIndexOf
gc9n
March 27, 2013, 4:02pm
3
so there isn't any function or something to do this for string variables?
system
March 27, 2013, 4:05pm
4
so there isn't any function or something to do this for string variables?
Get your shift key unstuck. Are you talking about Strings or strings? They are NOT interchangeable.
And, you can't use strtok() on a String.
gc9n
March 27, 2013, 4:05pm
5
i am talking about Strings
i think this might work..
char* subStr (char* str, char *delim, int index) {
char *act, *sub, *ptr;
static char copy[MAX_STRING_LEN];
int i;
// Since strtok consumes the first arg, make a copy
strcpy(copy, str);
for (i = 1, act = copy; i <= index; i++, act = NULL) {
//Serial.print(".");
sub = strtok_r(act, delim, &ptr);
if (sub == NULL) break;
}
return sub;
}