{{htmlmetatags>metatag-robots=() metatag-title=(DATA | ugBASIC User Manual) metatag-keywords=(ugBASIC,Commodore 64,Commodore PLUS/4,ZX Spectrum) metatag-description=(Manual page for DATA) metatag-media-og:image=(:ugbasic:logo-ugbasic-fb.png) metatag-og:title=(DATA | ugBASIC User Manual) metatag-og:description=(Manual page for DATA) }} ====== ugBASIC User Manual ====== ===== DATA ✓ ===== ===== SYNTAX ===== DATA c1[, c2[, c3[, ...]]] DATA AS type c1[, c2[, c3[, ...]]] ==== PURPOSE ==== The ''DATA'' command is used to store constant information in the program code, and is used with the BASIC-command ''READ''. Each ''DATA''-line can contain one or more constants separated by commas. Expressions containing variables will not be evaluated here. The instruction stores numeric data in an optimized way: so, if you enter a numeric constant that can be represented by a single byte, it will be stored in the program as a single byte. Floating point numbers are stored with default precision. Finally, strings are stored "as is". As a result, when you use the ''READ'' command, ugBASIC will implicitly perform the conversion if the same data type is not used, and it is posssible. It is possible to avoid optimization by using the ''AS'' keyword with the data type. The ''DATA'' values will be read from left to right, beginning with the first line containing a ''DATA'' statement. Each time a ''READ'' instruction is executed the saved ''DATA'' position of the last ''READ'' is advanced to the next value. Strings must be written in quotes, so characters like comma, space, colon, graphical ones or control characters has to be written inside double quotes like string constants. The ''RESTORE'' resets the pointer of the current ''DATA'' position the program start so that next ''READ'' will read from the first ''DATA'' found from the beginning of the program. In case ''READ'' uses the wrong variable type, variable will be untouched and pointer will be left to the current position. There is no easy way to get the position of the ''READ'' statement which is the real origin of the mismatch. ''DATA'' lines may scattered over the whole program code. ==== EXAMPLE ==== DATA 10, 20, "test" DATA AS INTEGER 10, 20, 30 See also the following example files: * ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/data_example_01.bas|data_example_01.bas]]'' * ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/data_example_02.bas|data_example_02.bas]]'' * ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/data_example_03.bas|data_example_03.bas]]'' * ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/data_example_05.bas|data_example_05.bas]]'' ==== ABBREVIATION ==== Da ==== 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 [[https://github.com/spotlessmind1975/ugbasic/issues/new?title=ISSUE ON DATA|open an issue]] for this keyword on GitHub. Thank you!===== POWERED BY ===== [[:ugbasic:user:index|{{ :ugbasic:user:logo-ugbasic.png?nolink&600 |}}]]