This article is about literal in Microsoft Small Basic programming language.


What is a Literal?

A literal is a data written directly in a program code.

Literal Number

Literal numbers are treated as positive numbers.  The format is one of following sequences.

  • digits [, decimal point] [, digits]
  • decimal point, digits

ex. 1.41421356

Literal Text

A literal text contains a sequence of Unicode characters without double quotation marks (") between double quotation marks.  Double quotation mark itself can be written as Text.GetCharacter(34).  Literal texts can be concatenated with plus operators (+).

ex. "Hello World!"

But numbers enclosed in double quotation marks are treated as numbers.  Especially, scientific notation (E notation) can be used in double quotations.  In a double quoted number, following symbols are allowed: (1) leading space characters, (2) previous single plus or minus sign of the number and (3) trailing space characters.

ex. "79228162514264337593543950335"
ex. "7.9228162514264337593543950335E28"
ex. " +123 "

Literal Boolean

As conditions in control statements, literal Boolean "True" or "False" can be used.  These values are also be substituted into variables.

Literal Array

An array is initialized such like point["x"] = 100.  But with literal array, some array indices can be initialized in one line.  Note that characters "=", ";" and "\" need an escape character "\" before them in a literal array.
  
ex. "x=100;y=200;"
ex. "EQ=\=;"

Literal Color

In Small Basic, colors can be described as the color names or hexadecimal numbers.  The details are here.

ex. "#00FFFF"


See Also

Other Resources