UserGuide - Variables and Processing of variables

A is an integer - but note that you can't declare variables this way if you use the EnableExplicit directive. Outside of a procedure A will exist at Main scope, within a procedure it will become local.
  A = 0

B is a long integer, C is a floating-point number, they will be initialized to zero.
  Define B.l, C.f

D and E are long integers too. However, they will be initialized to the stated constants. Notice too the alternative syntax of Define used.
  Define.l D = 10, E = 20

F is a string.
  Define.s F

So is G$, however, if you declare strings this way, you must always use the $ notation.
  G$ = "Hello, "
This won't work. (G becomes a new integer variable and a compiler error occurs).
  G = "Goodbye, World!"

H is an array of 20 strings, array indexing begins at zero.
  Dim H.s(19)
Now H is an array of 25 strings. If the array is resized larger, its original contents will be preserved.
  ReDim H.s(24)

J will appear at Global, rather than Main, scope. It will appear in all procedures, but maybe a better way would be to use the Shared keyword inside a procedure on a main scope variable, so that the chances of accidental changes are minimized.
  Global.i J

K will be a new, empty, list of strings at main scope.
  NewList K.s()

M will be a new, empty, map of strings at main scope.
  NewMap M.s()

Note that you can't use the alternative syntax of the Define keyword with NewList or NewMap though. A compiler error will result.

Within a procedure:
  Procedure TestVariables()
    ; N and P will be local.
    Define.l N
    Protected.l P
    ; Q will be a static local.
    Static.l Q
    ; The main scope variable F and the string list K will be available within this procedure.
    Shared F, K()
    ; The global scope variable J will be available here implicitly.

Using operators on variables:
  ; Add two to A.
  A + 2
  ; Bitwise Or with 21 (A will become 23)
  A | 21
  ; Bitwise And with 1 (A will become 1)
  A & 1
  ; Arithmetic shift left (A will become 2, that is 10 in binary).
  A << 1

String concatenation:
  G$ + "World!"

Add an element to the K list:
  K() = "List element one"

Add an element to the M map:
  M("one") = "Map element one"

UserGuide Navigation

< Previous: First steps | Overview | Next: Constants >