Closed C-In-OFF closed 11 years ago
How can you add an integer or unspecified 123
to a string stringOne
?
The example may come from the Arduino IDE and MSP430 tool-chain may be more strict than AVR one.
For topics like it, the forum might be a better place. See http://forum.43oh.com/forum/28-energia/
No No No!
This is real problem. Look at this:
String stringOne; String stringTwo; String stringTree;
void setup() { Serial.begin(9600); stringOne = String("0123456789ABCD"); //stringOne = String("0123456789ABCDE"); // <--- Point "A" stringTwo = String("XYZ"); stringTree = String("ZYX"); Serial.println("\n\n***Test******"); }
void loop() { stringOne += stringTwo; stringTwo = stringOne + stringTree; Serial.println(stringOne); Serial.println(stringTwo); // <--- Point "B" Serial.println(stringTwo.length()); // <--- Point "C" Serial.println("End"); while(true); }
If [stringOne] add 1 symbol (look Point "A"), than script do not work. (look Point "B" & "C") [stringTwo] will be = NULL !!! Why?
Please read the specification sheet of the MSP430G2452 available at http://www.ti.com/lit/ds/symlink/msp430g2112.pdf
The MSP430G2452 features 256 bytes only of RAM.
The String
object you're using wastes a lot of memory so you're running out of memory.
Use instead the char array
as described at http://arduino.cc/en/Reference/String or use a MCU with more RAM as the MSP430G2553.
@C-In-OFF
Have you posted your question there? I haven't seen any post about that topic.
So I close this issue just like #220 and I ask you not to open another one. Thank you.
// IDE ENERGIA 0101E0009 + MSP430G4252
String stringOne; String stringTwo;
void setup() { Serial.begin(9600); stringOne = String("0123456789ABCD"); //stringOne = String("0123456789ABCDE"); // <--- Point "A" stringTwo = String("XYZ"); Serial.println("\n\n***Test******"); }
void loop() { stringOne += 123; stringTwo = stringOne + 123; Serial.println(stringOne); Serial.println(stringTwo); // <--- Point "B" Serial.println(stringTwo.length()); // <--- Point "C" Serial.println("End"); while(true); }
If [stringOne] add 1 symbol (look Point "A"), than script do not work. (look Point "B" & "C") [stringTwo] will be = NULL !!! Why?
P.S. this is part of Base Energia Example "StringAdditionOperator"