9.6 String object
Description
You can manipulate (cut, search, compare, ...) strings with the String object.
Liste of methods/properties
Name | Type | Short description |
Length | Method | Returns the length of a string |
LTrim | Method | Truncates spaces from the left side of a string |
RTrim | Method | Truncates spaces from the right side of a string |
Trim | Method | Truncates spaces from both sides (left and right) of a string |
Chr | Method | Translates an ASCII code to a char |
Ord | Method | Returns the ASCII code of a char |
Pos | Method | Returns the position of a search string |
SubStr | Method | Returns a specified part of a string |
Compare | Method | Compares two strings |
Replace | Method | Replaces all occurences of a string in an other string |
ToUpper | Method | Translates each letter into upper case letters |
ToLower | Method | Translates each letter into lower case letters |
Reverse | Method | Reverses each char of a string |
Fill | Method | Concatenates a string multiple times |
Format | Method | Formats numbers |
WeekdayName | Method | Returns the name of a weekday |
MonthName | Method | Returns the name of a month |
Description
Returns the number of chars in a string.
Syntax
Return value
Dword
Type
Method
Parameter: String
Description
The string whose length shall be determined.
Data type
String
Example
1
2
$
d[1] = String.Length("7 Chars")
d[1] whould be at end: 7
Description
Truncates spaces (this means chars with the ASCII code 32) from the left side of a string.
Syntax
Return value
String
Type
Method
Parameter: String
Description
The string whose spaces shall be removed from the left side.
Data type
String
Example
1
2
$
a[1] = String.Trim(" Text with spaces left and right ")
a[1] whould be at end: "Text with spaces left and right "
Description
Truncates spaces (this means chars with the ASCII code 32) from the right side of a string.
Syntax
Return value
String
Type
Method
Parameter: String
Description
The string whose spaces shall be removed from the right side.
Data type
String
Example
1
2
$
a[1] = String.Trim(" Text with spaces left and right ")
a[1] whould be at end: " Text with spaces left and right"
Description
Truncates spaces (this means chars with the ASCII code 32) from both sides (left and right) of a string.
Syntax
Return value
String
Type
Method
Parameter: String
Description
The string whose spaces shall be removed from the left and right side.
Data type
String
Example
1
2
$
a[1] = String.Trim(" Text with spaces left and right ")
a[1] whould be at end: "Text with spaces left and right"
Description
Syntax
Return value
String
Type
Method
Parameter: Char
Description
The ASCII code of the char. The ASCII code 0 isn't valid.
Data type
Byte
Example
1
2
$
a[1] = String.Chr(65)
a[1] whould be at end: "A"
Description
Returns the ASCII code of a char at a specified position in a string.
Syntax
1
String.Ord(String, Position)
Return value
Byte
Type
Method
Parameter: String
Description
The string which contains the char.
Data type
String
Parameter: Position
Description
The position of the char in the string. This is the offset from the start of the string (this means 0 whould be the first char, 1 whould be the second char, ...).
Data type
Dword
Example
1
2
$
d[1] = String.Ord("Text", 2)
d[1] whould be at end: 120 (this is the ASCII code of the char "x")
Description
Returns the position of a partial string in an other string. The return value is the offset from the start of the string (this means 0 whould be the first char, 1 whould be the second char, ...). This method returns -1 if the string couldn't be found.
Syntax
1
String.Pos(String, SearchString, StartPosition)
Return value
Dword
Type
Method
Parameter: String
Description
The string which contains SearchString (haystack).
Data type
String
Parameter: SearchString
Description
The string which shall be searched (needle).
Data type
String
Parameter: StartPosition
Description
The position where the search shall start. This value is the offset from the start of the string (this means 0 whould start at the first char, 1 whould start at the second char, ...).
Data type
Dword
Example
1
2
$
d[1] = String.Pos("Search me!", "e", 2)
d[1] whould be at end: 7 (the first "e" has been skipped because the search started at char no. 3)
Description
Returns a partial string with specified length at a specified position.
Syntax
1
String.SubStr(String, Position, Length)
Return value
String
Type
Method
Parameter: String
Description
The string which contains the partial string.
Data type
String
Parameter: Position
Description
The start position where of the partial string. This value is the offset from the start of the string (this means 0 whould start at the first char, 1 whould start at the second char, ...).
Data type
Dword
Parameter: Length
Description
The length of the partial string. If this value is greater than the remainder of the string (or if it is a negative value) then the entire remainder will be copied.
Data type
Dword
Example
1
2
$
a[1] = String.SubStr("Text with parts", 5, 4)
a[1] whould be at end: "with"
Description
Compares two strings and returns true if they are equal (otherwise false).
Syntax
1
String.Compare(String1, String2)
Return value
Switch
Type
Method
Parameter: String1
Description
The first string which shall be compared.
Data type
String
Parameter: String2
Description
The second string which shall be compared.
Data type
String
Example
1
2
$
s[1] = String.Compare("Text", "Text")
s[1] whould be at end: 1 (= True)
Description
Replaces all occurences of a partial string in an other string.
Syntax
1
String.Compare(Expression, Search, Replacement)
Return value
String
Type
Method
Parameter: Expression
Description
The string which contains Search (Haystack).
Data type
String
Parameter: Search
Description
The string which shall be replaced (Needle).
Data type
String
Parameter: Replacement
Description
The string which shall be used as replacement for Search.
Data type
String
Example
1
2
3
$
a[1] = String.Replace("Milk products are from cows",
"Milk", "Meat")
a[1] whould be at end: "Meat products are from cows"
Description
Translates each letter (a to z) of a String into upper case letters.
Syntax
Return value
String
Type
Method
Parameter: String
Description
The string whose lower case letters shall be translated into upper case letters.
Data type
String
Example
1
2
$
a[1] = String.ToUpper("UPPER and lower case LETTERS")
a[1] whould be at end: "UPPER AND LOWER CASE LETTERS"
Description
Translates each letter (a to z) of a string into lower case letters.
Syntax
Return value
String
Type
Method
Parameter: String
Description
The string whose upper case letters shall be translated into lower case letters.
Data type
String
Example
1
2
$
a[1] = String.ToLower("UPPER and lower case LETTERS")
a[1] whould be at end: "upper and lower case letters"
Description
Reverses the content of a string.
Syntax
Return value
String
Type
Method
Parameter: String
Description
The string whose content shall be reversed.
Data type
String
Example
1
2
$
a[1] = String.Reverse("Reversed")
a[1] whould be at end: "desreveR"
Description
Concatenates a string multiple times.
Syntax
1
String.Fill(String, Count)
Return value
String
Type
Method
Parameter: String
Description
The string which shall be repeated.
Data type
String
Parameter: Count
Description
The number of repeats.
Data type
Dword
Range
0 to 10000
Example
1
2
$
a[1] = "We are" + String.Fill(" hungry", 3)
a[1] whould be at end: "We are hungry hungry hungry"
Description
Formats a number similar to the MessageLink. The first char must be a F (for double) or a D (for dword). Accordingly the second parameter will be formatted either as dword or double. If it is formatted as dword then the minimum length of digits can follow the D (e. g. D4 whould be a dword with at least 4 digits). If the number is formatted as double then you can specify the minimum integer length and/or the exact decimal length (e. g. F2.3 for at least 2 integer digits an exact 3 decimal digits).
Syntax
1
String.Format(Format, Number)
Return value
String
Type
Method
Parameter: Format
Description
The format string for the number.
Data type
String
Parameter: Number
Description
The number which shall be formatted.
Data type
Dword or double
Example
1
2
$
a[1] = String.Format("f0.4", 123.7)
a[1] whould be at end: "123.7000" (if Convert.DecimalComma whould be 1 then a comma whould have been used instead of a point as decimal separator)
Description
Returns the name of a weekday. This method depends on the chosen language of Destiny.dll.
Syntax
1
String.WeekdayName(Number, Short)
Return value
String
Type
Method, depends on language
Parameter: Number
Description
The number of the weekday. (0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday)
Data type
Byte
Range
0 to 6
Parameter: Short
Description
Specifies either the weekday shall return in short format (e. g. Sat) or long format (e. g. Saturday). True means short format.
Data type
Switch
Example
1
2
$
a[1] = String.WeekdayName(3, True)
a[1] whould be at end: "Wed" (if Destiny.Language whould be 0 then the return value whould be "Mi")
Description
Returns the name of a month. This method depends on the chosen language of Destiny.dll.
Syntax
1
String.MonthName(Number, Short)
Return value
String
Type
Method, depends on language
Parameter: Number
Description
The number of the month. (1 = January, 2 = February, 3 = March, 4 = April, 5 = May, 6 = June, 7 = July, 8 = August, 9 = September, 10 = October, 11 = November, 12 = December)
Data type
Byte
Range
1 to 12
Parameter: Short
Description
Specifies either the month shall return in short format (e. g. Jan) or long format (e. g. January). True means short format.
Data type
Switch
Example
1
2
$
a[1] = String.MonthName(12, False)
a[1] whould be at end: "December" (if Destiny.Language whould be 1 then the return value whould be "Dezember")