Strings

When handling strings, nuBASIC uses the set of ASCII characters.

The Asc and Chr functions allow the ASCII value belonging to a character to be established and/or the corresponding character to be found for a ASCII value.

Example:

Print Asc("A") 
65 


Print Chr(65) 
A


The Chr function is often used in Basic languages to insert control characters in a string.

The following assignment
MyString$ = Chr(9) + "Hello World" + Chr(13)

ensures that the text is preceded by a tab character (ASCII-value 9) and that a hard line break (ASCII-value 13) is added after the text.
 
nuBASIC provides the InStr function for searching for a partial string within another string.

Example:
ResultString% = InStr(MyString$, SearchString$)

The SearchString$ parameter specifies the string to be searched for within MyString$. 

The function returns a number that contains the position at which the SearchString$ first appears within MyString$ or -1 otherwise. 

InStr ignores uppercase and lowercase characters. 
InStrCs is the case sensitive version of InStr.

nuBASIC provides several functions that return partial strings, plus a length function: