199 DATA Purpose DATA is used in conjunction with the keyword READ , and sometimes with RESTORE , to enable you to make available automatically any data (numbers and words) that will be needed by a program. For example, if you were writing a geography quiz, you might want to use the names of five countries and their five capital cities each time you used the program. The names of the cities and countries can be entered as DATA in the program and will always be there when the program is run. Computers using the language BASIC are really clumsy at handling information like this, as the demonstration program on the next page shows. In the example program the DATA consists of many words.
DATA statements can just as well contain numbers – or a mixture of words and numbers. In our example the words were all read into a string array. It is essential that the DATA contains numbers where numeric variables are to be filled. Text information, eg hello , will just give 0. There is no need to put each word in quotes unless leading spaces are important in the DATA words, for example " four spaces" . If you wish to have leading spaces then these words should be enclosed in quotes. Since a comma is used to separate items of DATA , if you want a comma in your DATA , you must enclose the DATA in quotes.
Examples 100 DATA "Allen, Stephen", Stamp dealer, 01-246 8007, 24 130 DATA "TOP OF ROOF", 450, January Description A program object which must precede all lists of data intended for use by the READ statement. Syntax DATA | {, str-const> | }