Available on: all targets ✓ verified

READ

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.

SYNTAX

 READ var


Legend
  • id : identifier
  • type : datatype
  • v : value
  • "..." : string
  • [...] : optional

ABBREVIATION: R#

Join BASIC 10Liner Contest with ugBASIC!

An interesting competition is held at the beginning of each year: the BASIC 10Liner Contest. It is possible to use ugBASIC to participate in the next "BASIC10Liner" competition, in the following categories:

  • PUR-120 - A game in 10 lines of max 120 characters (w/abbrev.)
  • EXTREME-256 - A game in 10 lines of max 256 characters (w/abbrev.)
  • SCHAU - Any program in 10 lines of max 256 characters (w/abbrev.)
In order to reduce space you can use this abbreviation for this instruction:

READ ↔ R#

Any problem?

If you have found a problem with this keyword, if you think there is a bug or, more simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!

open an issue BACK TO KEYWORDS