A variable is a storage location paired with an associated symbolic name called identifier. Variables allow you to store and change information. Below is an example how to use variables. AString$ = "Hello World" Anumber% = 10 Print AString$ Print Anumber%
In case where type declaration character is not specified, floating point type will be assumed. nuBASIC enables both the creation of a variable through simple assignment without an explicit declaration statement and the declaration of a variable specifying its name and characteristics using Dim Statement A variable exists from the moment that you assign it a value in your code or declare it by using Dim. Example: A = -123.5 : Rem Floating-point A! = 1E50 : Rem Double floating-point A% = &HFF0000 : Rem Integer 32 bit A$ = ”This is a string” : Rem String A# = false : Rem Boolean
Dim i as Integer : Rem i is just an integer Dim s(2) as String : Rem s is an array of two strings Explicit type declaration syntax:
Type deductionType deduction is possible by using the keyword Any. For example: Dim x as Any ' x can become any type at run-time x = "string" ' x becomes a string (it cannot change anymore)
Const keyword allows to assigns the value of an expression to a constant variable. Constant variables are non‐modifiable. Example: Const square2 = 1.41 |