QBasic/Working With Strings

From Wikibooks, open books for an open world
Jump to navigation Jump to search

What are strings and what are they used for?[edit | edit source]

In QBASIC, a string is a contiguous sequence of ASCII encoded characters in memory. The characters are stored in memory as an 8 bit byte. Strings in QBASIC are mutable meaning they can be changed in place without allocating new memory. By now if you have read the prior chapters, you should know that strings are typically used to represent numbers, letters, and other symbols and are used to display information on screen, and getting user input. In the Files chapter you will find that strings can be saved into and read from files as well. If you get creative you can use strings for other purposes. One example is adding large numbers hundreds of digits long. In QBASIC you cannot do that with its built in numeric data types. You could however store the digits in string form and write your own function to add a couple of strings containing digits together thus overcoming some of the initial QBASIC constraints.

Functions[edit | edit source]

Character Functions[edit | edit source]

Asc[edit | edit source]

Chr$[edit | edit source]

String Functions[edit | edit source]

Conversion[edit | edit source]

Lcase$[edit | edit source]
Str$[edit | edit source]
Ucase$[edit | edit source]

Generator[edit | edit source]

Space$[edit | edit source]
String$[edit | edit source]

Search[edit | edit source]

InStr[edit | edit source]

Size Of[edit | edit source]

Len[edit | edit source]

Splice[edit | edit source]

Left$[edit | edit source]
Mid$[edit | edit source]
Right$[edit | edit source]

Truncate[edit | edit source]

Ltrim$[edit | edit source]
Rtrim$[edit | edit source]

Memory Manipulation Functions[edit | edit source]

Peek[edit | edit source]

Poke[edit | edit source]

SADD[edit | edit source]

Examples[edit | edit source]