Today’s featured TechNet Wiki article comes from LitDev…
Find the latest and complete version of this article here, on TechNet Wiki:
This article covers the basics of text manipulation in Small Basic using the Text object.
Text is a series of characters, often called a string in computing. A string can be a constant (or literal) enclosed within a set of double quotes, or a variable can be assigned to hold a string.
Above, txt is a variable that contains the string literal “Hello World”.
As stated, the string contains a set or characters, in the example above there are 11 characters, ‘H’, ‘e’, ‘l’, ‘l’, ‘o’, ‘ ‘, ‘W’, ‘o’, ‘r’, ‘l’ and ‘d’.
A string can also be a series of numbers such as “3.14159”, or even contain special characters like backspace, newline, ‘♥’ or even a system beep. These are not to be confused with the different representations of the characters that different fonts can provide, including different language fonts like the symbol font.
Each character is identified internally by a ‘character code’ or number, often called ASCII or UNICODE number.
We often want to form one string from others or query a string to see what it contains.
The following is a brief summary of the Small Basic Text object methods with some simple examples.
Returns the number or characters in the input string.
The empty string “” has a special meaning in Small Basic. It represents a variable that has not been set, and in fact an array or one of its elements is deleted by setting it to “”. We cannot therefore have an array element that is the empty string “”.
Joins or concatenates two strings. We can also use + to join two strings in general. However, if the strings are actually numbers, then + would add them numerically rather than join the strings.
This is very straight forward, simply creates a copy of the input string converting the case.
This can be very useful for comparing the equivalence of strings in a case insenstive way. If we convert both to the same case (say lower) and test if they are equal then the case of the original things is effectively ignored.
Create a copy of the input string, with all characters converted to lower case.
Create a copy of the input string, with all characters converted to upper (or capital) case.
You can read the rest of the article on TechNet Wiki:
Thanks to LitDev for this fantastic contribution!
– Ninja Ed