System variable

From C64-Wiki
Jump to navigationJump to search

A system variable is a variable, which is not freely usable, but provides some specific information of the system. The name of such a variable can be of any length, but only the first two characters are significant.

BASIC V2[edit | edit source]

BASIC V2 on a C64 or VIC 20 knows 3 system variables:

  • ST or STATUS: Input-/output status; read-only
  • TI or TIME: Counter of the internal clock in 1/60 seconds steps since system startup (as long it is not set back by modifying TIME$); read-only
  • TI$ or TIME$: The time in format HHMMSS since system start (except no changed before); read and write

BASIC 3.5 and higher[edit | edit source]

With BASIC 3.5 found in the Commodore-264 series following system variables have been added:

  • EL (ErrorLine): Number of the BASIC line where the last error has occurred; read-only
  • ER (ERror): Number of the last error which has occurred; read-only
  • ERR$ (ERRor): Returns message for a given error number; read-only
    To be technically correct its internally more a string function than an array variable (it has a function token, but nevertheless it could be accessed like an array with some negligible exceptions).
  • DS (DiskStatus): Disk drive error code of the latest drive in use; read-only
  • DS$ (DiskStatus): Disk drive error message text of the latest drive in use; read-only

All these additional system variables introduced with BASIC 3.5 could lead to problems if BASIC V2 are ported to the C264 series or to the C128. Variables with the same name break the program in case of write access with raising the error message ?SYNTAX ERROR.

Simons' Basic[edit | edit source]

Even Simons' Basic knows fixed variables:

  • GRAPHICS: returns the base address to the register of the C64's VIC chip.
  • ERRLN: line number of the latest occurred error.
  • ERRN: error number of the latest occurred error.
  • JOY: Value from Controlport 2
  • PENX: Lightpen X position
  • PENY: Lightpen Y position
  • SOUND: returns the base address to the register of the C64's SID chip.