Ok I've narrowed down my problem.
From my experiments I can gladly say that theres no problem getting characters from long string.
You can either use brackets like String[](will return as a char), the String.substring() function or use String(String[]).
Any of them work fine.
And for the problem that I'm having I suggest you to visit the dedicated blog for my library so you can fully understand its string handling functions, visit xelfa.blogspot.com.
Ok, so XELFA have 2 functions that are used by the problem.
One function, the CountStr(), works fine by entering any size String.
However the CountListItems, which basically calls CountStr and results the same value as CountStr plus 1 (CountStr+1)
does not seem to receive the first parameter, unless the string is short.
Try this:
Take the following super long string:
String MyValues = "00,0,0|100,26,0|200,28,0|300,29,0|400,30,0|500,32,0|600,31,0|700,32,0|800,34,0|900,37,0|1000,39,0|1100,41,0|1200,43,0|1300,46,0|1400,49,0|1500,52,0|1600,56,0|1700,60,0|1800,65,0|1900,71,0|2000,80,0|2100,88,0|2200,101,0|2300,114,0|2400,141,0|2500,180,0|2600,180,8|2700,180,18|2800,180,27|2900,180,36|3000,180,46|3100,180,57|3200,180,68|3300,180,77|3400,180,87|3500,180,97|3600,179,109|3700,155,109|3800,134,109|3900,117,109|4000,102,109|4100,88,109|4200,76,109|4300,66,109|4400,57,109|4500,50,109|4600,41,109|4700,35,109|4800,27,109|4900,21,109|5000,17,109|5100,10,109|5200,4,109|5300,0,115|5400,0,136|5500,0,170|5600,0,240|5700,-12,240|5800,-24,240|5900,-37,240|6000,-50,240|6100,-63,240|6200,-76,240|6300,-90,240|6400,-105,240|6500,-118,240|6600,-134,240|6700,-148,240|6800,-164,240|6900,-181,240|7000,-199,240|7100,-212,240|7200,-236,240|7300,-255,230|7400,-255,201|7500,-255,179|7600,-255,163|7700,-255,140|7800,-255,119|7900,-255,99|8000,-255,82|8100,-255,71|8200,-255,61|8300,-255,49"
And run this code:
Serial.println(String(XELFA.CountStr(MyValues,"|")));
Works like a charm, no matter how long the string is.
Now try to use the same string but with the following code:
Serial.println(String(XELFA.CountListItems(MyValues,"|")));
It wont work, unless the string is short.
The two functions look like this:
int XELFA::CountStr(String Str, String SubStr){
//WORKING. DO NOT TOUCH!
return FindStrPass(Str, SubStr, -1);
}
int XELFA::CountListItems(String List, String Spacer){
int Count = CountStr(List, Spacer)+1;
if (List=="") return 0;
return Count;
}
Maybe I should use pointers instead of creating a bunch of new strings all the time?!
Btw I have an Arduino Mega.