Wave's~ BlitzMax Tutorial for NG~ November, 2015 ~ Version 11
Beginners guide to BlitzMax 

Strings
I assume you know the basics of strings. BlitzMax has a quite easy way to deal with strings. It's very similar to arrays. Remember that a string is an object.

Strings use slices just as arrays. To get the first three letters of a string:
Test$ = "TestString"
Print Test[..3]
Print Test.length 'Like arrays

If you compare two strings you compare the characters of the string. For example "Car" and "car" is not the same because C and c is not equal. Sometimes you want to ignore case-sesitivity.
 
One way to do that is to use ToUpper or ToLower.
Car$ = "Ferrari"
If Car.ToLower() = "FerRaRi".ToLower() Then
  DebugLog
("Got match!")
End If

How Strings actually work
A string is a piece of text. A string is built up of characters. A character is a letter, number or a symbol and is represented with a character code. The most common standard to use to encode text to numbers is called ASCII. For example in ASCII "a" has the value 97 while "A" has the value 65, "B" has the value 66. Each symbol on your keyboard has a code which is used by the computer. There are more letters and signs than those 127 covered in the ASCII standard. These 127 codes are not enough to cover all possible symbols and letters from different languages. BlitzMax uses 2 bytes for each character and can therefore contain almost all common key-symbols in the world ; ) These 2byte numbers is called shorts and range from 0-65535.
 
A string is an array with characters. In other words a string is an array of shorts. Remember that to get an element of an array you would do: MyArray[ ElementNrToGet ] the same goes for a string. To get a character-code of a character in a string you go MyString[ CharacterToGet ].
Example:
Test$ = "TestString"
Print Test[ 0 ] 'Print the code of the first letter in the String
Print "T"[0] 'Print the code of the Letter T

It could also be good to note that the size and length of a string in BlitzMax isn't the same.
Test$ = "ASCII"
Print Test.length+" chars" ' The number of characters - 5
Print SizeOf( Test )+" bytes"'The number of bytes - 10
 
To Index | Next Page page 17