String variables

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Core Language > Data types and variables >

String variables

 

String variables

 

String variables are stored internally as Dynamic Strings. Dynamic strings contain a variable-length string that can be up to approximately 2 billion characters in length.

There are also fixed-len strings or fixed-len ASCIIZ strings. In this case the size of the allocated buffer is fixed when variable is declared and not dynamic based on variable content.

 

The following string data types are supported:

Data type

Bytes

More ....

STRING

4

Plus the size of the string (up to 2Gb).

No need to worry about size: thinBasic will automatically allocate/de-allocate data when needed

 

Dim MyVar As String

 

ASCIIZ

4

Plus the size of the string (up to 2Gb) plus 1, the $NUL char

 

Dim MyVar As Asciiz

 

Fixed-len STRING


The fixed size is declared in DIM statement using:

 

Dim MyVar As STRING * SIZE

 

where size is the size in bytes of the fixed string.

Fixed-len ASCIIZ


The fixed size is declared in DIM statement using:

 

Dim MyVar As ASCIIZ * SIZE

 

where SIZE is the size in bytes of the fixed string.

WString


Used in DECLARE ... statement to define unicode dynamic string

WStringZ


Used in DECLARE ... statement to define unicode fixed string