Constants

[ Back ]

A constant works like a variable, but its value can only be set once. Constants are visible in sub programs, and if constants are declared in a library they're also visible in programs that import the library. An advice is to use constants for naming images, sound effects, array posts etc, as it makes the code much easier to read. To declare one or more constants, use the constant statement:

constant:
  an_integer_constant 5
  pi# 3.14
  program_name$ "My Program"
hidden:
...

You can, but needn't, use the = character when declaring constants. When you're done with your constants, you need to call hidden or visible to make all upcoming variables normal.

[ Back ]