Abdellazizhammami / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

String.replace compile error Arduino 1.0 #764

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. goto http://arduino.cc/en/Tutorial/StringReplace and copy string replace 
example
2. save and attempt to compile/upload onto arduino ethernet

What is the expected output? What do you see instead?
expected output is to replace all "<" with "</" in the var stringOne. Instead 
you get the compile error: "conversion from 'void' to non-scalar type 'String' 
requested"

What version of the Arduino software are you using? On what operating
system?  Which Arduino board are you using?
Arduino 1.0
Windows 7 x86
Arduino Ethernet (not the poe version)

Please provide any additional information below.
I've attempted to try this without the example code however I cannot seem to 
find a different way to use the 'replace' function. Its also worth noting that 
the '.replace' in the IDE doesn't turn orange, neither does other String 
functions (length, indexof). I've looked into importing the string library but 
the site says its included since version 00022 or something, thus I didn't need 
to include it. Also, other string examples seem to compile (string.length(), 
string.startswith/endswith, string.indexof) even though the IDE doesn't 
highlight them as keywords (the highlighting dosen't matter to me, just thought 
I would point it out)

Original issue reported on code.google.com by my49plym...@gmail.com on 29 Dec 2011 at 7:05

GoogleCodeExporter commented 8 years ago
Ok figured out what was going wrong. the code example (as i've found with many 
others) is severely out of date and should read as this:

stringOne.replace("<", "</");
stringTwo = stringOne;

that worked just fine. apparently the assignment was causing issues.

I hope this helps someone in the future, please mark as solved.

Original comment by my49plym...@gmail.com on 29 Dec 2011 at 4:10

GoogleCodeExporter commented 8 years ago
Sounds like we need to update the example, so I'm handing this over to Tom.

Original comment by dmel...@gmail.com on 29 Dec 2011 at 8:34

GoogleCodeExporter commented 8 years ago
Seems to work fine in Arduino IDE 1.5.4.

Original comment by c.mag...@arduino.cc on 22 Sep 2013 at 1:23