Variables

You can imagine variables as containener of number or text (strings). You can assig values to variables, that are stored in computer memory, and later recall that values by simply type the variables names.

For example:
' create variables
a = 2
b = 5
' use the previuosly created variables
c = a + b

Variable names can be any sequence of uppercase and lowercase letters and numbers.
There are only a few rules. Variable names must:
Example:
1st_player = 1
is wrong because it starts with a number. Following examples are correct:
player_1st = 1
player1 = 1

Example:
bin =  "some text"
is wrong because bin is a command name. Following examples are correct:
bin2 = "some text"
binary = "some text"

Example:
alien x = 1oo
is wrong because variable name is not continuous and contain a space. Following examples are correct:
alien_x = 100
alienX = 100

There are no types in sdlBasic; all variables and arrays are variants. This means that they
can hold either numeric or string values. In general, sdlBasic will attempt to automatically cast a variable to the correct type.

For example:
' create variables
a = "123"
b = 456
 
' variable a is automatically converted to a number
Print a + b

this means you can compare strings to numbers as the following example:

a = "123"
b = 123
if a=b then : print “they match” : end if

Comparing stings to numbers may be particularly useful when you use dynamic array feature because its indexes are stored as strings.