Although thinBasic supports most normal data types, unless you have some very particular requirement we suggest you use only the following three.


STRING

For the storage of normal text data. Strings are dynamically sized, and can contain strings (in theory) up to 2 GB characters long. In practice, string lengths are limited by available memory.


NUMBER

For the storage of numerical data. Number variables are Extended Precision floating point data of 80 bits in the range of 3.4 x 10^-4932 to 1.2 x 10^4932. This format is more than capable of handling any of your numeric variable requirements. And as thinBasic uses this format internally for numeric calculations, it avoids repetitive internal data conversions if numeric variable are stored in this format.


LONG

For simple integer values, LONG is faster than the more generalized NUMBER.



Defining Variables

Every variable used in your macro must be declared before usage.


Variables are declared using the DIM keyword. The DIM keyword works just like standard Basic DIM except that a VALUE clause followed by a numeric or string expression can be entered. If the VALUE clause is used, and multiple variable names are specified, every variable will be initialized to the same value in the VALUE expression.


The VALUE expression can be any Basic expression, including function calls and the constants TRUE and FALSE>


Syntax

DIM VarName [ , Varname [ ,...]] As NUMBER [ VALUE numeric-expression ]

DIM VarName [ , Varname [ ,...]] As STRING [ VALUE string-expression ]

DIM AUTO


Examples


Code

Comment

DIM MyVar AS NUMBER

Define MyVar as a Number


DIM Var1, Var2 AS STRING VALUE "AAA"

Define Var1 and Var2 as STRINGs whose initial value is “AAA”


DIM Var2 AS LONG VALUE 100

This will declare an integer variable (Var2)  whose initial value will be 100.


Created with the Personal Edition of HelpNDoc: Create cross-platform Qt Help files