Go Down

Topic: WString Library (Read 1 time) previous topic - next topic

edenlgx

Dec 09, 2010, 09:59 am Last Edit: Dec 09, 2010, 10:09 am by edenlgx Reason: 1
Anyone know where to find the WString library? I want to test a sketch that I found at http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1274596787, but the command "readString.append(c);" "has no memeber".

Forgot to mention I use the Arduino 0021 Software, Duemilanove board, I also have an ethernet shield, the Arduino ETHShiled SD.

Any advice?

Thanks in advance.

PaulS

The WString library, containing the String class, was replaced for 0021 by an internal class also called String.

You can replace the append() calls with concat().

zoomkat

You should be able to substitute like below in 0021:

replace

readString.append(c);

with

readString += c;
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

edenlgx

Hey all, thanks for the replies.

The concat() method seems to work, now the next error comes up.
I want to use the sketch here:
http://www.scienceprog.com/getting-hands-on-arduino-ethernet-shield/
But now I'm stuck with an error message telling me "class string has no memeber named "contains". This happens at the line "
if(readString.contains("L=1"))" :P
It looks to me like I require an additional library, like String, but I have Version 0021 that to my knowledge should contain all the string commands.

Any advice on this... can I be more clear in some way?

zoomkat

#4
Dec 15, 2010, 04:47 pm Last Edit: Dec 15, 2010, 04:47 pm by zoomkat Reason: 1
Use indexOf like below:

Code: [Select]

if(readString.indexOf("woohoo") >=0) {
     Serial.println("I found woohoo!");
   }
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

edenlgx

Thank you zoomkat, that worked perfectly!  ;D

The_Bongmaster

so what do u do with an error like:
Code: [Select]
'class String' has no member named 'capacity'

there needs to be a table that shows the alts between wstring and the new core string lib :)
B-dui in creation.

PaulS

Quote
so what do u do with an error like:

Two possibilities. One is to edit the library to add a capacity() member, and continue to use that.

The other is to look at how Strings are now implemented, to see that the _capacity (private) field is simply used to determine if a given String object has room to add the new characters. If it doesn't, another (larger) memory allocation is performed, and the existing data copied to the new location, and the old location is freed. Effectively, String objects are now unlimited in size (constrained only by the actual memory available at any given point in time), so the capacity of a string is irrelevant. So, quit asking. There WILL be enough room.

The_Bongmaster

ok that sounds a little copmlicated for a novice like myself.
any chance for an idiots guide? x3 im trying to get a gps sketch to work that i found here but it uses wstring.h and that capacity bit is preventing compile since i have no wstring.h or the rest of that particular lib.
im not really a coder so i cant work out the complex things.
B-dui in creation.

zoomkat

You can get wstring.h below.

http://arduino.cc/en/uploads/Tutorial/String.zip
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

The_Bongmaster

thanks for that zoom, i added that to arduino 17 ide and the sketch compiled fine, the new ide doesnt like it tho, but thats not a problem
B-dui in creation.

Go Up