Data Types

Data types are types of variables that contain specific types of information. There are 7 data types supported in SecondBASIC Studio:


Byte:

A Byte can hold a value ranging from 0 to 255 and is the smallest numerical data type.
 
    Dim a As Byte
    a = 127
    a = a + 128
    Print a
    a = a + 128
    Print a

If you run the code above, you'll notice that the variable a goes back to the value of 127 in the 2nd example. Instead of overflowing when reaching their upperbound, numerical values will roll over instead, starting back at 0.

 

Char:

The Char data type holds a single character. If you try to assign more than a single character in a literal expression, the compiler will throw an overflow error. If you assign a regular String, it will contain the first character only. Char and String variables are identified with a $ symbol. If a variable isn't defined as a Char, the compiler will default the data type to a String.
 
    Dim a$ As Char
    a$ = "A"
    b$ = "Hello World"
    Print a$
    a$ = b$
    Print a$

 

Signed Integer

A 16 bit numerical variable with a range of -32,767 to 32,767.
 
    Dim a As Signed Integer
    a = 1000
    Print a
    a = a - 2500
    Print a

 

Unsigned Integer

A 16 bit numerical variable with a range of 0 to 65,535.
 
    Dim a As Integer
    a = 1000
    Print a
    a = a - 2500
    Print a

As you'll notice in the second output, the number isn't negative. If you try to go below 0 in an unsigned Integer, then it will roll the value over, just like if you were trying to overflow the variable.

 

Unsigned Long Integer:

A 32 bit numerical variable with a range of 0 to 4,294,967,295. Long variables are identified with an & symbol.
 
    Dim a& As Long
    a& = 867530
    Print a&

 

String:

A String is a variable that can hold text. By default, the length of a String is 128 bytes / characters. Like the Char data type, a String is identified by a $ symbol.
 
    Dim a$ As String
    a$ = "Hello World"
    Print a$

 

Constant:

A Constant is a variable that never changes value. These variables are replaced by their numerical assignment during compilation and are treated as if they were numbers rather than an Integer. A Constant is prefixed by a # symbol.
 
    Const #a = 6
    b = #a + 1000
    Print b