|
C++ AnsiString Methods
Look in "Help"
for "AnsiString" methods.
|
| |
Declares
myString
as an AnsiString. |
AnsiString myString; |
| |
Returns
the character in position "i", starting at 1. |
myString[i]; |
| |
Returns
the position of a target string. |
myString.Pos("target"); |
| |
Returns
the length of the target string. |
myString.Length(); |
| |
Extracts
a substring. |
myString.SubString(position, length); |
| |
Deletes
a substring. |
myString.Delete(position, length); |
| |
Inserts
a substring. |
myString.Insert("target", position); |
| |
Trims
preceeding blanks from myString.
Trims trailing blanks from myString.
Trims preceeding & trailing blanks from myString. |
myString.TrimLeft();
myString.TrimRight();
myString.Trim();
|
| |
Converts
all characters to either upper or lower case. |
myString.UpperCase();
myString.LowerCase();
|
| |
Creates
a string of repeated characters. |
myString.StringOfChar('character', repeats); |
| |
Converts
string to an integer or floating point number. |
myString.ToInt();
myString.ToIntDef(value);
myString.ToDouble();
|
| |
Converts
currency or floating point numbers to a string. |
myString.CurrToStrF();
myString.FloatToStrF();
|
| |
Controls
how myString
is formatted. |
myString.Format(format, arguments, size);
myString.FormatFloat(format, value);
|
|
C++ char Character
Array
You must:
#include <SysUtils.hpp>
|
| |
Declares
myString as a char.
The array will be terminated by a "NUL" and will thus be
one character longer than the string.
|
char[] myString = "Able was I ere I saw Elba";
|
| |
Declares
an integer x. |
int x; |
| |
Returns
the character at index "i".
Remember, arrays begin at 0. |
myString[i]; |
| |
Returns
the ASCII value of the character in position "i", starting
at 0. |
x = myString[i]; |
| |
Inserts
the character "O" at index "i".
(Note the single quotes!) |
myString[i] = 'O'; |
| |
Inserts
the character whose ASCII value is 85 at index "i". |
myString[i] = 85; |
|
C++ basic_string
routines
Look in "Help"
for "basic_string" routines.
These do not appear to be compatible with Edit or Memo Boxes.
You must:
#include <string>
using namespace std;
|
| |
Declares
myString as a basic_string.
|
string myString = "There are no elephants here!";
|
| |
Returns
the length of myString. |
myString.length(); |
| |
Replaces
the third character with an "X".
Note the single quotes!
Remember, arrays begin at 0. |
myString[2] = 'X'; |
| |
Inserts
the character whose ASCII value is 85 at position 3. |
myString[2] = 85; |
| |
|
|
| |
Finds
the first occurrance of the string "here" beginning at position
0. |
myString.find("here", 0); |
| |
Replace
the 4 characters beginning at position 24 with "there." |
myString.replace(24, 4, "there"); |
| |
Replace
"here" with "there". |
myString.replace(myString.find("here",0), 4, "there");
|