====== DATA ====== /* Remove the comments after creating content for each section.*/ Declares lists of literal values within the program /* For the lines below, just create links, separated by commas, to other pages of the BASICs section, like [[:basics:basicTagName]]. "Implemented by" should mention BASICs which implement the keyword like described, in a more usual and standard way. "With variations" should point to BASICs where this keyword is used a bit differently. "Also written as" should list alternative spellings and abbreviations this keyword has. No need to refer to a BASIC, there is a section for that later. */ **Implemented by:** [[:basics:Dartmouth:dartmouth1]], [[:basics:Dartmouth:dartmouth4]], [[:basics:ANSI:ansimin]], [[:basics:ANSI:ansifull]], [[:basics:hptsb:]], [[:basics:decbasic:]], [[:basics:Altair:]], [[:basics:Applesoft:]], [[:basics:TI994:]], [[:basics:CBM:]], [[:basics:Atari:]], [[:basics:Atari:atxl]], [[:basics:msatari:]], [[:basics:trs80:]], [[:basics:trs80:level2]], [[:basics:trscolor:]], [[:basics:trscolor:colormc]], [[:basics:Sinclair:spectrum]], [[:basics:BBC:]], [[:basics:GWBASIC:]], [[:basics:MSX:]], [[:basics:bwbasic:]], [[:basics:bwbasic:bw32]], [[:basics:ABasiC:]], [[:basics:msqb:QBasic]], [[:basics:VBDOS:]], [[:basics:FreeBASIC:]], [[:basics:minibasicjs:]] **With variations:** [[:basics:Applesoft:tasc]] (numeric strings can be [[READ]] into a numeric variable), [[:basics:EndBASIC:]] (strings must be quoted) **Also written as: ** * D. in some [[:basics:tiny:|Tiny BASIC]] implementations, as [[:basics:trs80:level1|TRS-80 Level I BASIC]] * DAT. in PDP-8E BASIC ===== Usage ===== /* For inline examples of syntax, write the keyword between '' and '' (two single quotes) */ DATA is the place to put numbers and sometimes strings which do not //change each time the program is run, but you would like it to be easy to change them if necessary//, as put by [[:basics:Altair:|Altair BASIC]]'s manual. Some examples of usage might be: * Default configuration values of an application * Sprites, icons and characters bitmap definitions * Notes of a song for [[SOUND]] or [[PLAY]] DATA lines are usually grouped at the bottom end of a program or routine. Each line contain a number of individual values separated by commas. Such values are retrieved and written into one or more variables sequentially by a [[READ]] statement usually placed within a loop somewhere else in the program. 5 EXAMPLE FROM ALTAIR BASIC MANUAL 10 PRINT "GUESS A NUMBER"; 20 INPUT G 30 READ D 40 IF D=-999999 THEN 90 50 IF D<>G THEN 30 60 PRINT "YOU ARE CORRECT!" 70 END 90 PRINT "BAD GUESS. TRY AGAIN." 95 RESTORE 100 GOTO 10 110 DATA 1,393,-39,28,391,-8,0,3.14,90 120 DATA 89,5,10,15,-34,-999999 The [[RESTORE]] keyword is used to make the next [[READ]] start from the first value or from a given DATA line, instead of the value(s) after the last retrieved one(s). DATA must be the first statement of a program line in order to be found in most if not all BASICs. And the PC-BASIC (a modern implementation of [[:basics:GWBASIC:]]) manual [[https://robhagemans.github.io/pcbasic/doc/2.0/#DATA|puts it clearly]] that a properly written DATA statement //will be// found and read no matter where it is within a conditional section of a program — in other words, do **not** expect the DATA not to be read according to the result of an [[IF]] statement. ==== Variations ==== Most BASICs also allow strings to be used as constant values in DATA statements, but following rules apply: * If a comma is part of a string, the string must be double-quoted ("like this") in [[:basics:MSX:|MSX BASIC]]. * If a string contains a comma, a colon, leading or trailing spaces, it must be double-quoted in [[:basics:GWBASIC:]]. * Any string value must be double-quoted in [[:basics:EndBASIC]] . ===== Comments ===== /* Origin of the keyword, opinions, history... */ DATA was the primary (well, //only//) method of getting values into a program for processing in the initial Dartmouth implementations of BASIC, before the [[INPUT]] keyword was implemented. It certainly looked more natural back then, when batch processing of data in punched cards were common. DATA and READ are notoriously missing in the Apple II "Mini-Manual" which refers to Apples's INTEGER BASIC. There is an evident and intriguing similarity between the DATA statement and the CSV (Comma-Separated Values) tabular data format, which, according to some sources((https://manifold.net/doc/mfd9/csv,_asc,_psv,_tab.htm))((https://en.wikipedia.org/wiki/Comma-separated_values)), would be roughly described for the first time in a 1972 IBM FORTRAN manual ((http://bitsavers.trailing-edge.com/pdf/ibm/370/fortran/GC28-6884-0_IBM_FORTRAN_Program_Products_for_OS_and_CMS_General_Information_Jul72.pdf)). ===== Related keywords ===== * [[READ]], [[RESTORE]] ===== Similar keywords ===== /* Keywords with the same or similar functionality found in other versions of BASIC */ ===== In other languages... ===== /* For parallels and comparisons with other modern-day languages */ ===== References ===== /* If you used the ((citation)) syntax elsewhere in the text, they will appear under this section. But you can write some recommendations of books, magazines, etc */ /* ===== TAGS ===== Please use the syntax below for adding tags to this page, separated by spaces (use quotes for tags with spaces). The most important tags to be used are, separated by groups: - Statements | Commands | SpecialVariables | Operators */ {{tag>Statements}}