User Tools

Site Tools


ugbasic:user:kw:read
Translations of this page:


ugBASIC User Manual

READ ✓

SYNTAX

   READ var

PURPOSE

The READ is used for reading constant values from DATA lines into the given variables. This command is able to read more constants at once with a variable list separated by commas.

If using the wrong type of variable (for example read a character string into a numerical variable like float or integer), the variable will be untouched. Such behavior can be prevented by generally using a variable of the same type like the DATA AS used.

With a value that falls outside the expected range of a READ variable, e.g. the value is outside the range of an integer, ugBASIC will implicitly convert it, with a precision lost, but only if SAFE keyword is used. If more constants are read than values exist in DATA lines, garbare will be read. It can be avoided by using SAFE keyword or using READ END function. Using SAFE the variable will not be touched if last value is already read.

A succeeding READ searches for the first DATA statement where the DATA read pointer is adjusted to.

EXAMPLE

  READ nextStep

See also the following example files:

ABBREVIATION

 R#

AVAILABLE ON

  • Atari (400/800)
  • Atari XL/XE
  • Commodore 128 (MOS 8502)
  • Commodore 128 (Zilog Z80)
  • Commodore 64
  • Commodore 64+REU
  • TRS-80 Color Computer
  • TRS-80 Color Computer 3
  • ColecoVision
  • Amstrad CPC 664
  • Dragon 32
  • Dragon 64
  • Thomson MO5
  • Thomson MO5
  • Olivetti Prodest PC128
  • Commodore PLUS/4
  • SEGA SC-3000
  • SEGA SG-1000
  • VG-5000
  • Commodore VIC-20
  • ZX Spectrum 48

ANY PROBLEM?

If you have encountered a problem using this command, if you think there is a bug or the explanation is unclear, please open an issue for this keyword on GitHub. Thank you!

POWERED BY