Skip to reading
BASIC Scripting

Name a value and give it a type

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page

THE BASIC LANGUAGE

A ticket counter needs a starting quantity, a sale, and a number of seats left. DIM gives a changing value a name. CONST holds the capacity steady.

Code example
FUNCTION Run()
    CONST capacity AS Integer = 8
    DIM sold AS Integer = 3
    sold += 2
    DIM spare = capacity - sold
    RETURN spare
END FUNCTION

What you should see The function returns 3. Five tickets were sold, leaving three seats. The += on the fourth line adds two to the existing value.

Source table from Name a value and give it a type, page 7
Integer / NumberUse Integer to count items and Number for fractional values such as seconds. Long is an Integer alias. Single, Double and Decimal map to Number.
String / BooleanString or Text holds words, including an empty string. Boolean holds TRUE or FALSE.
Array / DictionaryAn Array holds entries in order. A Dictionary stores values under keys such as "owner".
Variant / NOTHINGA value can be left untyped. NOTHING represents an absent value. An empty string is a piece of text with zero characters.

The AS annotation is optional. Use it when the expected kind of value helps someone understand the function or gives the validator a useful check.

Page 7 of 86Permalink
Go to page