String
Declared as:
Dim <Name> As String
This allocates a RAM for a string (plus one extra byte internally). Fixed strings are not null-terminated and do not resize automatically.
Fixed-length string
Declared as:
Dim <Name> As String [* <Length>]
Dim <Name> * <Length>This allocates a 16-byte string (plus one extra byte internally). Fixed strings are not null-terminated and do not resize automatically.
String Escape Sequences
String literals in GCBASIC source support escape sequences, allowing arbitrary byte values to be embedded directly in strings without workarounds. This capability removes the need to use CHR() which is expensive in terms of RAM. From build 1603.
Supported Sequences
| Sequence | Value | Example |
|---|---|---|
|
|
Hex byte, exactly 2 digits (0-9, A-F) |
|
|
|
Hex byte, exactly 2 digits (0-9, A-F) |
|
|
|
Decimal byte, exactly 3 digits (0-9) |
|
|
|
Carriage return |
Chr(13) |
|
|
Newline |
Chr(10) |
|
|
Tab |
Chr(9) |
|
|
Literal backslash |
Chr(92) |
|
|
Literal double-quote |
Chr(34) |
Rules
- Hex digits must be uppercase or lowercase A-F; exactly 2 are required.
- Decimal values must be exactly 3 digits and in the range 000-255.
- An unrecognised escape sequence produces a compile-time error with file and line number.
Example
tmpstring = "\223C\\"
Produces a 3-byte string: Chr(223), C, \ — stored in the string table as:
StringTable2:
.DB 3, 223, 67, 92

