Tutorial.TextString History

Show minor edits - Show changes to markup

September 22, 2010, at 12:16 AM by Tom Igoe -
Changed lines 1-55 from:

String (formerly TextString) Library

As of version 0.9, this library has been updated using the Wiring String library API. The Wiring library was based on version 0.1 of TextString and extended by Hernando Barragan. The download above contains additional examples and a version compatible with Arduino.

Version 0.9 is a bug fix. There was a memory leak, solved by Mikal Hart, and some length issues addressed by Andre Crone and Coen Blijker. This is an interim release.

A lot of programming work involves sending and receiving strings of ASCII data. Altough Arduino isn't designed as a platform for complex manipulation of text strings, there are often times when you need to read strings, look for substrings, compare strings, and so forth. You might be trying to read a GPS receiver, or sending commands to a Bluetooth or Zigbee radio that uses an AT-style command set. If that's what you're doing, this library is for you.

Download: String.zip

To use, unzip it and copy the resulting folder, called String, into the libraries directory of your arduino sketch folder. If you don't already have a libraries folder, create it now.Then re-start the Arduino application.

When you restart, you'll see a few warning messages in the debugger pane at the bottom of the program. You can ignore them.

There is one significant difference between that version and this one: The Arduino String library contains the function getChars() instead of toCharArray(). The functionality of the two is identical. The name change was made for naming consistency.

This version has been tested with Arduino 0015.

Functions:

char charAt(int position) - Returns the character at position

void append(String thisString) - Appends the String representation of thisString. thisString can be and int, long, char, or char array

int capacity() - Returns the internal capacity of the String. This is different from the length.

boolean contains(String thisString) - Returns true if the string contains thisString

byte[] getBytes() - Returns an array of bytes of the String

char[] getChars() - Returns an array of chars of the String

void setCharAt(int positon, char thisChar) - sets the character specified at position to thisChar

boolean endsWith(String thisString) - Returns true if the current string ends with thisString

boolean equals(String thisString) - returns true if the string equals thisString

int indexOf(char thisChar) - Returns the position of the first occurrence of thisChar

int length() - Returns the number of characters in the string

void replace(char thisChar, char thatChar) - Replaces all the occurrences thsChar with thatChar

boolean startsWith(String thisString) - Returns true if the string starts with thisString

String substring(int beginning, int ending) - Returns a substring that begins at beginning position and ends at ending

void toLowerCase() - Converts all the characters to lower case

void toUpperCase() - Converts all the characters to upper case

If anyone's interested in helping to develop this library further, please contact me at tom.igoe at gmail.com

to:

TextString has been replaced by the core object String, as of version 0019. Feel free to gleefully delete your TextString library and use String instead.

See Also

July 01, 2010, at 05:33 PM by Tom Igoe -
Changed lines 11-12 from:

To use, unzip it and copy the resulting folder, called String, into the lib/targets/libraries directory of your arduino application folder. Then re-start the Arduino application.

to:

To use, unzip it and copy the resulting folder, called String, into the libraries directory of your arduino sketch folder. If you don't already have a libraries folder, create it now.Then re-start the Arduino application.

June 01, 2010, at 08:48 PM by Tom Igoe -
Changed lines 3-6 from:

As of version 0.8, this library has been updated using the Wiring String library API. The Wiring library was based on version 0.1 of TextString and extended by Hernando Barragan. The download above contains additional examples and a version compatible with Arduino.

Version 0.8 is a bug fix. There was a memory leak, solved by Mikal Hart. This is an interim release.

to:

As of version 0.9, this library has been updated using the Wiring String library API. The Wiring library was based on version 0.1 of TextString and extended by Hernando Barragan. The download above contains additional examples and a version compatible with Arduino.

Version 0.9 is a bug fix. There was a memory leak, solved by Mikal Hart, and some length issues addressed by Andre Crone and Coen Blijker. This is an interim release.

March 30, 2010, at 06:37 AM by Tom Igoe -
Changed lines 3-6 from:

As of version 0.7, this library has been updated using the Wiring String library API. The Wiring library was based on version 0.1 of TextString and extended by Hernando Barragan. The download above contains additional examples and a version compatible with Arduino.

Version 0.7 is a bug fix. There was a memory leak, solved by Mikal Hart. This is an interim release.

to:

As of version 0.8, this library has been updated using the Wiring String library API. The Wiring library was based on version 0.1 of TextString and extended by Hernando Barragan. The download above contains additional examples and a version compatible with Arduino.

Version 0.8 is a bug fix. There was a memory leak, solved by Mikal Hart. This is an interim release.

March 29, 2010, at 09:04 PM by Tom Igoe -
Changed lines 3-4 from:

As of version 0.4, this library has been updated using the Wiring String library API. The Wiring library was based on version 0.1 of TextString and extended by Hernando Barragan. The download above contains additional examples and a version compatible with Arduino.

to:

As of version 0.7, this library has been updated using the Wiring String library API. The Wiring library was based on version 0.1 of TextString and extended by Hernando Barragan. The download above contains additional examples and a version compatible with Arduino.

Version 0.7 is a bug fix. There was a memory leak, solved by Mikal Hart. This is an interim release.

April 17, 2009, at 09:42 PM by Tom Igoe -
Changed lines 1-2 from:

TextString Library

to:

String (formerly TextString) Library

April 10, 2009, at 09:15 PM by Tom Igoe -
Added lines 3-4:

As of version 0.4, this library has been updated using the Wiring String library API. The Wiring library was based on version 0.1 of TextString and extended by Hernando Barragan. The download above contains additional examples and a version compatible with Arduino.

Deleted lines 12-13:

As of version 0.4, this library has been updated using the Wiring String library API. The Wiring library was based on version 0.1 of TextString and extended by Hernando Barragan. The download above contains additional examples and a version compatible with Arduino.

Changed lines 15-16 from:

This version has been tested with Arduino 0013.

to:

This version has been tested with Arduino 0015.

April 10, 2009, at 06:33 PM by Tom Igoe -
Changed lines 7-8 from:

To use, unzip it and copy the resulting folder, called TextString, into the lib/targets/libraries directory of your arduino application folder. Then re-start the Arduino application.

to:

To use, unzip it and copy the resulting folder, called String, into the lib/targets/libraries directory of your arduino application folder. Then re-start the Arduino application.

February 09, 2009, at 12:41 AM by Tom Igoe -
Added lines 17-52:

Functions:

char charAt(int position) - Returns the character at position

void append(String thisString) - Appends the String representation of thisString. thisString can be and int, long, char, or char array

int capacity() - Returns the internal capacity of the String. This is different from the length.

boolean contains(String thisString) - Returns true if the string contains thisString

byte[] getBytes() - Returns an array of bytes of the String

char[] getChars() - Returns an array of chars of the String

void setCharAt(int positon, char thisChar) - sets the character specified at position to thisChar

boolean endsWith(String thisString) - Returns true if the current string ends with thisString

boolean equals(String thisString) - returns true if the string equals thisString

int indexOf(char thisChar) - Returns the position of the first occurrence of thisChar

int length() - Returns the number of characters in the string

void replace(char thisChar, char thatChar) - Replaces all the occurrences thsChar with thatChar

boolean startsWith(String thisString) - Returns true if the string starts with thisString

String substring(int beginning, int ending) - Returns a substring that begins at beginning position and ends at ending

void toLowerCase() - Converts all the characters to lower case

void toUpperCase() - Converts all the characters to upper case

February 09, 2009, at 12:39 AM by Tom Igoe -
Added lines 15-16:

This version has been tested with Arduino 0013.

February 09, 2009, at 12:27 AM by Tom Igoe -
Changed lines 5-8 from:

Download: TextString.zip

To use, unzip it and copy the resulting folder, called TextString, into the lib/targets/libraries directory of your arduino application folder. Then copy the examples folder from the TextString folder to your Arduino code folder (the devault location is Documents/Arduino/). Then re-start the Arduino application.

to:

Download: String.zip

To use, unzip it and copy the resulting folder, called TextString, into the lib/targets/libraries directory of your arduino application folder. Then re-start the Arduino application.

Changed lines 11-96 from:

As of version 0.1, this library has very limited functionality. Here's what you can do:

TextString(int strLength) - initialize a TextString of a given length e.g.

TextString myString = TextString(50); // makes a 50-byte long TextString

clear(void) - fill the TextString with zeroes, e.g.

myString.clear();     // clears the string

length(void) - get the length up to the first zero byte e.g.

int stringLength = myString.length(); // gives the string length

equals( char *thatString) - compare your TextString to a given string, e.g.

if (myString.equals("Hello")) {
   // compares myString to "Hello"
}

contains(char *subString) - whether the TextString contains a given substring e.g.

if (myString.contains("Hello")) {
   // checks if myString contains the subString "Hello"
}

trim(void) - trim whitespace from both ends of the TextString. Removes any space characters, carriage returns, newlines, tabs, or vertical tabs. e.g.

Serial.print(myString.trim());   // prints the trimmed version of myString 

trimRight(void) - trim whitespace from the end of the TextString e.g.

Serial.print(myString.trimRight());   // prints the version of myString trimmed on the end


trimLeft(void) - trim whitespace from the beginning of the TextString e.g.

Serial.print(myString.trimLeft());   // prints the version of myString trimmed from the beginning


setArray(char* thatString) - set the whole character array e.g.

myString.setArray("What's up Doc?");   // puts a string in the array


getArray(void) - get the whole character array e.g.

Serial.println(myString.getArray());   // prints the string

getCharAt(int charNum) - get a given character from the TextString e.g.

char thisChar = myString.getCharAt(5);   // gets the sixth character in the array

setCharAt(int charNum, char thisChar) - set a given charracter in the TextString e.g.

myString.setCharAt(5, 'A');   // sets the sixth character in the array to "A"

version(void) - get the library version. Since there will be more functions added, printing the version is a useful debugging tool when you get an error from a given function. Perhaps you're using an earlier version that doesn't feature the version you need! e.g.

Serial.println(myString.version());   // prints the version of the library 


to:

As of version 0.4, this library has been updated using the Wiring String library API. The Wiring library was based on version 0.1 of TextString and extended by Hernando Barragan. The download above contains additional examples and a version compatible with Arduino.

There is one significant difference between that version and this one: The Arduino String library contains the function getChars() instead of toCharArray(). The functionality of the two is identical. The name change was made for naming consistency.

October 21, 2006, at 09:30 PM by David A. Mellis - adding more missing parentheses
Changed line 48 from:

Serial.print(myString.trim); // prints the trimmed version of myString

to:

Serial.print(myString.trim()); // prints the trimmed version of myString

Changed lines 54-55 from:

Serial.print(myString.trimRight); // prints the version of myString trimmed on the end

to:

Serial.print(myString.trimRight()); // prints the version of myString trimmed on the end

Changed lines 61-62 from:

Serial.print(myString.trimLeft); // prints the version of myString trimmed from the beginning

to:

Serial.print(myString.trimLeft()); // prints the version of myString trimmed from the beginning

October 21, 2006, at 06:13 PM by David A. Mellis - made download more prominent, added missing parens in sample code
Changed lines 5-8 from:

To use it download TextString.zip. Unzip it, and copy the resulting folder, called TextString, into the lib/targets/libraries directory of your arduino application folder. Then copy the examples folder from the TextString folder to your Arduino code folder (the devault location is Documents/Arduino/). Then re-start the Arduino application.

to:

Download: TextString.zip

To use, unzip it and copy the resulting folder, called TextString, into the lib/targets/libraries directory of your arduino application folder. Then copy the examples folder from the TextString folder to your Arduino code folder (the devault location is Documents/Arduino/). Then re-start the Arduino application.

Changed line 32 from:

if (myString.equals("Hello") {

to:

if (myString.equals("Hello")) {

Changed line 40 from:

if (myString.contains("Hello") {

to:

if (myString.contains("Hello")) {

October 20, 2006, at 07:53 PM by Tom Igoe -
Changed lines 5-8 from:

Attach:TextString2.zip Δ

To use it download . Unzip it, and copy the resulting folder, called TextString, into the lib/targets/libraries directory of your arduino application folder. Then copy the examples folder from the TextString folder to your Arduino code folder (the devault location is Documents/Arduino/). Then re-start the Arduino application.

to:

To use it download TextString.zip. Unzip it, and copy the resulting folder, called TextString, into the lib/targets/libraries directory of your arduino application folder. Then copy the examples folder from the TextString folder to your Arduino code folder (the devault location is Documents/Arduino/). Then re-start the Arduino application.

October 20, 2006, at 07:50 PM by Tom Igoe -
Changed lines 5-8 from:

To use it download TextString.zip. Unzip it, and copy the resulting folder, called TextString, into the lib/targets/libraries directory of your arduino application folder. Then copy the examples folder from the TextString folder to your Arduino code folder (the devault location is Documents/Arduino/). Then re-start the Arduino application.

to:

Attach:TextString2.zip Δ

To use it download . Unzip it, and copy the resulting folder, called TextString, into the lib/targets/libraries directory of your arduino application folder. Then copy the examples folder from the TextString folder to your Arduino code folder (the devault location is Documents/Arduino/). Then re-start the Arduino application.

October 20, 2006, at 07:49 PM by Tom Igoe -
Changed lines 65-66 from:

getArray(char* thatString) - set the whole character array e.g.

to:

setArray(char* thatString) - set the whole character array e.g.

Added lines 95-97:

If anyone's interested in helping to develop this library further, please contact me at tom.igoe at gmail.com

October 20, 2006, at 07:48 PM by Tom Igoe -
Changed lines 23-24 from:

length(void) - get the length up to the first zero e.g.

to:

length(void) - get the length up to the first zero byte e.g.

Deleted lines 30-31:
Changed lines 65-66 from:

getArray(void) - get the whole character array e.g.

to:

getArray(char* thatString) - set the whole character array e.g.

Changed lines 68-69 from:

Serial.println(myString.getArray()); // prints the string

to:

myString.setArray("What's up Doc?"); // puts a string in the array

Changed lines 71-73 from:

getCharAt(int charNum) - get a given character from the TextString e.g.

to:

getArray(void) - get the whole character array e.g.

Changed line 74 from:

char thisChar = myString.getCharAt(5); // gets the sixth character in the array

to:

Serial.println(myString.getArray()); // prints the string

Changed lines 77-78 from:

setCharAt(int charNum, char thisChar) - set a given charracter in the TextString e.g.

to:

getCharAt(int charNum) - get a given character from the TextString e.g.

Changed line 80 from:

myString.setCharAt(5, 'A'); // sets the sixth character in the array to "A"

to:

char thisChar = myString.getCharAt(5); // gets the sixth character in the array

Changed lines 83-84 from:

version(void) - get the library version. Since there will be more functions added, printing the version is a useful debugging tool when you get an error from a given function. Perhaps you're using an earlier version that doesn't feature the version you need! e.g.

to:

setCharAt(int charNum, char thisChar) - set a given charracter in the TextString e.g.

Changed line 86 from:

Serial.println(myString.version()); // prints the version of the library

to:

myString.setCharAt(5, 'A'); // sets the sixth character in the array to "A"

Added lines 89-94:

version(void) - get the library version. Since there will be more functions added, printing the version is a useful debugging tool when you get an error from a given function. Perhaps you're using an earlier version that doesn't feature the version you need! e.g.

Serial.println(myString.version());   // prints the version of the library 

October 20, 2006, at 07:32 PM by Tom Igoe -
Changed lines 23-25 from:

length(void) - get the length up to the first zero

e.g.

to:

length(void) - get the length up to the first zero e.g.

Changed lines 39-42 from:

contains(char *subString) - whether the TextString contains a given substring

e.g.

to:

contains(char *subString) - whether the TextString contains a given substring e.g.

Changed lines 47-50 from:

trim(void) - trim whitespace from both ends of the TextString. Removes any space characters, carriage returns, newlines, tabs, or vertical tabs.

e.g.

to:

trim(void) - trim whitespace from both ends of the TextString. Removes any space characters, carriage returns, newlines, tabs, or vertical tabs. e.g.

Changed lines 53-56 from:

trimRight(void) - trim whitespace from the end of the TextString

e.g.

to:

trimRight(void) - trim whitespace from the end of the TextString e.g.

Changed lines 60-63 from:

trimLeft(void) - trim whitespace from the beginning of the TextString

e.g.

to:

trimLeft(void) - trim whitespace from the beginning of the TextString e.g.

Changed lines 67-70 from:

getArray(void) - get the whole character array

e.g.

to:

getArray(void) - get the whole character array e.g.

Changed lines 73-76 from:

getCharAt(int charNum) - get a given character from the TextString

e.g.

to:

getCharAt(int charNum) - get a given character from the TextString e.g.

Changed lines 79-82 from:

setCharAt(int charNum, char thisChar) - set a given charracter in the TextString

e.g.

to:

setCharAt(int charNum, char thisChar) - set a given charracter in the TextString e.g.

Changed lines 85-88 from:

version(void) - get the library version. Since there will be more functions added, printing the version is a useful debugging tool when you get an error from a given function. Perhaps you're using an earlier version that doesn't feature the version you need!

e.g.

to:

version(void) - get the library version. Since there will be more functions added, printing the version is a useful debugging tool when you get an error from a given function. Perhaps you're using an earlier version that doesn't feature the version you need! e.g.

October 20, 2006, at 07:31 PM by Tom Igoe -
Changed lines 50-51 from:

trim(void) - trim whitespace from both ends of the TextString

to:

trim(void) - trim whitespace from both ends of the TextString. Removes any space characters, carriage returns, newlines, tabs, or vertical tabs.

Changed line 55 from:

Serial.print(myString.trim); // prints the version of myString with no spaces, returns, or newlines on either end

to:

Serial.print(myString.trim); // prints the trimmed version of myString

Changed lines 63-64 from:

Serial.print(myString.trimRight); // prints the version of myString with no spaces, returns, or newlines on the end

to:

Serial.print(myString.trimRight); // prints the version of myString trimmed on the end

Changed lines 72-73 from:

Serial.print(myString.trimLEft); // prints the version of myString with no spaces, returns, or newlines at the beginning

to:

Serial.print(myString.trimLeft); // prints the version of myString trimmed from the beginning

October 20, 2006, at 07:29 PM by Tom Igoe -
Deleted lines 22-23:

equals( char *thatString) - compare your TextString to a given string, e.g.

Deleted line 25:
Changed lines 27-29 from:

if (myString.equals("Hello") {

   // compares myString to "Hello"

}

to:

int stringLength = myString.length(); // gives the string length

Changed lines 30-33 from:

contains(char *subString) - whether the TextString contains a given substring

e.g.

to:

equals( char *thatString) - compare your TextString to a given string, e.g.

Changed lines 35-36 from:

if (myString.contains("Hello") {

   // checks if myString contains the subString "Hello"
to:

if (myString.equals("Hello") {

   // compares myString to "Hello"
Changed lines 40-41 from:

trim(void) - trim whitespace from both ends of the TextString

to:

contains(char *subString) - whether the TextString contains a given substring

Changed lines 45-47 from:

Serial.print(myString.trim); // prints the version of myString with no spaces, returns, or newlines on either end

to:

if (myString.contains("Hello") {

   // checks if myString contains the subString "Hello"

}

Changed lines 50-51 from:

trimRight(void) - trim whitespace from the end of the TextString

to:

trim(void) - trim whitespace from both ends of the TextString

Changed lines 55-56 from:

Serial.print(myString.trimRight); // prints the version of myString with no spaces, returns, or newlines on the end

to:

Serial.print(myString.trim); // prints the version of myString with no spaces, returns, or newlines on either end

Changed lines 58-59 from:

trimLeft(void) - trim whitespace from the beginning of the TextString

to:

trimRight(void) - trim whitespace from the end of the TextString

Changed lines 63-64 from:

Serial.print(myString.trimLEft); // prints the version of myString with no spaces, returns, or newlines at the beginning

to:

Serial.print(myString.trimRight); // prints the version of myString with no spaces, returns, or newlines on the end

Changed lines 67-68 from:

getArray(void) - get the whole character array

to:

trimLeft(void) - trim whitespace from the beginning of the TextString

Changed lines 72-73 from:

Serial.println(myString.getArray()); // prints the string

to:

Serial.print(myString.trimLEft); // prints the version of myString with no spaces, returns, or newlines at the beginning

Changed lines 76-77 from:

getCharAt(int charNum) - get a given character from the TextString

to:

getArray(void) - get the whole character array

Changed line 81 from:

char thisChar = myString.getCharAt(5); // gets the sixth character in the array

to:

Serial.println(myString.getArray()); // prints the string

Changed lines 84-85 from:

setCharAt(int charNum, char thisChar) - set a given charracter in the TextString

to:

getCharAt(int charNum) - get a given character from the TextString

Changed line 89 from:

myString.setCharAt(5, 'A'); // sets the sixth character in the array to "A"

to:

char thisChar = myString.getCharAt(5); // gets the sixth character in the array

Changed lines 92-93 from:

version(void) - get the library version. Since there will be more functions added, printing the version is a useful debugging tool when you get an error from a given function. Perhaps you're using an earlier version that doesn't feature the version you need!

to:

setCharAt(int charNum, char thisChar) - set a given charracter in the TextString

Changed line 97 from:

Serial.println(myString.version()); // prints the version of the library

to:

myString.setCharAt(5, 'A'); // sets the sixth character in the array to "A"

Added lines 100-107:

version(void) - get the library version. Since there will be more functions added, printing the version is a useful debugging tool when you get an error from a given function. Perhaps you're using an earlier version that doesn't feature the version you need!

e.g.

Serial.println(myString.version());   // prints the version of the library 

October 20, 2006, at 07:27 PM by Tom Igoe -
Added line 14:
Changed lines 17-18 from:

clear(void) - fill the TextString with zeroes

to:

clear(void) - fill the TextString with zeroes, e.g.

myString.clear();     // clears the string

Added lines 29-34:
if (myString.equals("Hello") {
   // compares myString to "Hello"
}
Added lines 39-44:
if (myString.contains("Hello") {
   // checks if myString contains the subString "Hello"
}
Added lines 49-52:
Serial.print(myString.trim);   // prints the version of myString with no spaces, returns, or newlines on either end
Added lines 57-61:
Serial.print(myString.trimRight);   // prints the version of myString with no spaces, returns, or newlines on the end

Added lines 66-70:
Serial.print(myString.trimLEft);   // prints the version of myString with no spaces, returns, or newlines at the beginning

Added lines 75-78:
Serial.println(myString.getArray());   // prints the string
Added lines 83-86:
char thisChar = myString.getCharAt(5);   // gets the sixth character in the array
Changed lines 91-92 from:

version(void) - get the library version

to:
myString.setCharAt(5, 'A');   // sets the sixth character in the array to "A"

version(void) - get the library version. Since there will be more functions added, printing the version is a useful debugging tool when you get an error from a given function. Perhaps you're using an earlier version that doesn't feature the version you need!

Added lines 99-102:
Serial.println(myString.version());   // prints the version of the library 
October 20, 2006, at 07:18 PM by Tom Igoe -
Changed lines 13-14 from:

TextString(int strLength)!!! - initialize a TextString of a given length

e.g.

to:

TextString(int strLength) - initialize a TextString of a given length e.g.

Changed lines 16-20 from:

clear(void)!!! - fill the TextString with zeroes

equals( char *thatString)!!! - compare your TextString to a given string

length(void)!!! - get the length up to the first zero

to:

clear(void) - fill the TextString with zeroes

equals( char *thatString) - compare your TextString to a given string, e.g. length(void) - get the length up to the first zero

Changed lines 23-24 from:

contains(char *subString)!!! - whether the TextString contains a given substring

to:

contains(char *subString) - whether the TextString contains a given substring

Changed lines 27-28 from:

trim(void)!!! - trim whitespace from both ends of the TextString

to:

trim(void) - trim whitespace from both ends of the TextString

Changed lines 31-32 from:

trimRight(void)!!! - trim whitespace from the end of the TextString

to:

trimRight(void) - trim whitespace from the end of the TextString

Changed lines 35-36 from:

trimLeft(void)!!! - trim whitespace from the beginning of the TextString

to:

trimLeft(void) - trim whitespace from the beginning of the TextString

Changed lines 39-40 from:

getArray(void)!!! - get the whole character array

to:

getArray(void) - get the whole character array

Changed lines 43-44 from:

getCharAt(int charNum)!!! - get a given character from the TextString

to:

getCharAt(int charNum) - get a given character from the TextString

Changed lines 47-48 from:

setCharAt(int charNum, char thisChar)!!! - set a given charracter in the TextString

to:

setCharAt(int charNum, char thisChar) - set a given charracter in the TextString

Changed lines 51-52 from:

version(void)!!! - get the library version

to:

version(void) - get the library version

October 20, 2006, at 07:17 PM by Tom Igoe -
Changed lines 15-30 from:

TextString myString = TextString(50); // makes a 50-byte long TextString clear(void); // fill the TextString with zeroes

 	int equals( char *thatString);	// compare to a given string
    int length(void);				// get the length up to the first zero
    int contains(char *subString);	// whether the string contains the substring
    char* trim(void);				// trim whitespace
    char* trimRight(void);			// trim whitespace from the end
    char* trimLeft(void);			// trim whitespace from the beginning

    char* getArray(void);			// get the whole char array
    char getCharAt(int charNum);	// get a given char
    void setCharAt(int charNum, char thisChar);		// set a given char

    char* version(void);			// get the library version

to:

TextString myString = TextString(50); // makes a 50-byte long TextString

clear(void)!!! - fill the TextString with zeroes

equals( char *thatString)!!! - compare your TextString to a given string

length(void)!!! - get the length up to the first zero

e.g.

contains(char *subString)!!! - whether the TextString contains a given substring

e.g.

trim(void)!!! - trim whitespace from both ends of the TextString

e.g.

trimRight(void)!!! - trim whitespace from the end of the TextString

e.g.

trimLeft(void)!!! - trim whitespace from the beginning of the TextString

e.g.

getArray(void)!!! - get the whole character array

e.g.

getCharAt(int charNum)!!! - get a given character from the TextString

e.g.

setCharAt(int charNum, char thisChar)!!! - set a given charracter in the TextString

e.g.

version(void)!!! - get the library version

e.g.

October 20, 2006, at 07:12 PM by Tom Igoe -
Changed lines 1-2 from:

TextString Library

to:

TextString Library

Added lines 13-30:

TextString(int strLength)!!! - initialize a TextString of a given length

e.g. TextString myString = TextString(50); // makes a 50-byte long TextString clear(void); // fill the TextString with zeroes

 	int equals( char *thatString);	// compare to a given string
    int length(void);				// get the length up to the first zero
    int contains(char *subString);	// whether the string contains the substring
    char* trim(void);				// trim whitespace
    char* trimRight(void);			// trim whitespace from the end
    char* trimLeft(void);			// trim whitespace from the beginning

    char* getArray(void);			// get the whole char array
    char getCharAt(int charNum);	// get a given char
    void setCharAt(int charNum, char thisChar);		// set a given char

    char* version(void);			// get the library version

October 20, 2006, at 07:10 PM by Tom Igoe -
Changed lines 5-8 from:

Attach:TextString.zip

To use it download TextString.zip. Unzip it, and copy the resulting folder, called TextString, into the lib/targets/libraries directory of your arduino application folder. Then copy the examples folder from the TextString folder to your Arduino code folder (the devault location is Documents/Arduino/). Then re-start the Arduino application.

to:

To use it download TextString.zip. Unzip it, and copy the resulting folder, called TextString, into the lib/targets/libraries directory of your arduino application folder. Then copy the examples folder from the TextString folder to your Arduino code folder (the devault location is Documents/Arduino/). Then re-start the Arduino application.

October 20, 2006, at 07:09 PM by Tom Igoe -
Added lines 5-6:
October 20, 2006, at 07:08 PM by Tom Igoe -
October 20, 2006, at 07:08 PM by Tom Igoe -
Changed lines 3-5 from:

A lot of programming work involves sending and receiving strings of ASCII data. For example, the exchange between a web browser and a web server involves escanges like this:

Altough Arduino isn't designed as a platform for complex manipulation of text strings, there are often times

to:

A lot of programming work involves sending and receiving strings of ASCII data. Altough Arduino isn't designed as a platform for complex manipulation of text strings, there are often times when you need to read strings, look for substrings, compare strings, and so forth. You might be trying to read a GPS receiver, or sending commands to a Bluetooth or Zigbee radio that uses an AT-style command set. If that's what you're doing, this library is for you.

To use it download TextString.zip. Unzip it, and copy the resulting folder, called TextString, into the lib/targets/libraries directory of your arduino application folder. Then copy the examples folder from the TextString folder to your Arduino code folder (the devault location is Documents/Arduino/). Then re-start the Arduino application.

When you restart, you'll see a few warning messages in the debugger pane at the bottom of the program. You can ignore them.

As of version 0.1, this library has very limited functionality. Here's what you can do:

October 20, 2006, at 06:59 PM by Tom Igoe -
Added lines 1-5:

TextString Library

A lot of programming work involves sending and receiving strings of ASCII data. For example, the exchange between a web browser and a web server involves escanges like this:

Altough Arduino isn't designed as a platform for complex manipulation of text strings, there are often times

Share