Long Variable Declaration (Syntax 1)

In VAR blocks, syntax 1 of LONG is used to declare global, symbolic variables that are either long-sized, or are any array of longs. For example:

VAR
  long Temp                      'Temp is a long (2 words, 4 bytes)
  long List[25]                  'List is a long array

The above example declares two variables (symbols), Temp and List. Temp is simply a single, long-sized variable. The line under the Temp declaration uses the optional Count field to create an array of 25 long-sized variable elements called List. Both Temp and List can be accessed from any PUB or PRI method within the same object that this VAR block was declared; they are global to the object. An example of this is below.

PUB SomeMethod
  Temp := 25_000_000             'Set Temp to 25,000,000
  List[0] := 500_000             'Set first element of List to 500,000
  List[1] := 9_000               'Set second element of List to 9,000
  List[24] := 60                 'Set last element of List to 60

For more information about using LONG in this way, refer to the VAR section's Variable Declarations (Syntax 1) and keep in mind that LONG is used for the Size field in that description.

Unless otherwise noted, content on this site is licensed under the
Creative Commons Attribution-ShareAlike 4.0 International License.