Pages: [1]   Go Down
Author Topic: WString Library  (Read 1637 times)
0 Members and 1 Guest are viewing this topic.
Namibia, Walvis Bay
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Persistance pays off
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: December 09, 2010, 04:09:44 am by edenlgx » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49071
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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().
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9541
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You should be able to substitute like below in 0021:

replace

readString.append(c);

with

readString += c;
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Namibia, Walvis Bay
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Persistance pays off
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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"))" smiley-razz
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?
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9541
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Use indexOf like below:

Code:
if(readString.indexOf("woohoo") >=0) {
      Serial.println("I found woohoo!");
    }
« Last Edit: December 15, 2010, 10:47:42 am by zoomkat » Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Namibia, Walvis Bay
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Persistance pays off
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you zoomkat, that worked perfectly!  ;D
Logged

Norway
Offline Offline
Sr. Member
****
Karma: 0
Posts: 370
R-Doo-Inoo in the making :3
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

so what do u do with an error like:
Code:
'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 smiley
Logged

B-dui in creation.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49071
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Norway
Offline Offline
Sr. Member
****
Karma: 0
Posts: 370
R-Doo-Inoo in the making :3
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

B-dui in creation.

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9541
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can get wstring.h below.

http://arduino.cc/en/uploads/Tutorial/String.zip
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Norway
Offline Offline
Sr. Member
****
Karma: 0
Posts: 370
R-Doo-Inoo in the making :3
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

B-dui in creation.

Pages: [1]   Go Up
Jump to: