{{fbdoc item="title" value="READ"}}---- Reads values stored with the ##[[KeyPgData|Data]]## statement. {{fbdoc item="syntax"}}## **Read** //variable_list// ## {{fbdoc item="desc"}} Reads data stored in the application with the ##[[KeyPgData|Data]]## command. The elements of the ##//variable_list//## must be of basic types, numeric, strings or elements of arrays and user defined types. All the ##[[KeyPgData|Data]]## statements in the program behave as a single list, after the last element of one ##[[KeyPgData|Data]]## statement is read, the first element of the following ##[[KeyPgData|Data]]## statement will be read. The program should not attempt to ##[[KeyPgRead|Read]]## after the last ##**Data**## element. The results are (in all dialects) undefined, and the program may crash (Page Fault). Data constants can only be of simple types (numeric or string). A string read into a numeric variable will be evaluated by the ##[[KeyPgVal|Val]]## function. The "##[[KeyPgRestore|Restore]] //label//##" statement makes the first ##[[KeyPgData|Data]]## item after ##//label//## the next item to be read, allowing the user to choose specific sections of data to be read. {{fbdoc item="ex"}} {{fbdoc item="filename" value="examples/manual/data/read.bas"}}%%(freebasic) ' Create an array of 5 integers and a string to hold the data. DIM AS INTEGER h(4) DIM AS STRING hs DIM AS INTEGER readindex ' Set up to loop 5 times (for 5 numbers... check the data) FOR readindex = 0 TO 4 ' Read in an integer. READ h(readindex) ' Display it. PRINT "Number" ; readindex ; " = " ; h(readindex) NEXT readindex ' Spacer. PRINT ' Read in a string. READ hs ' Print it. PRINT "String = " + hs ' Await a keypress. SLEEP ' Exit program. END ' Block of data. DATA 3, 234, 4354, 23433, 87643, "Bye!" %% {{fbdoc item="lang"}} - None in syntax and usage of ##**Read**## - See the ##[[KeyPgData|Data]]## page for more information on differences in storing the data {{fbdoc item="diff"}} - None in syntax and usage of ##**Read**## - See the ##[[KeyPgData|Data]]## page for more information on differences in storing the data {{fbdoc item="see"}} - ##[[KeyPgData|Data]]## - ##[[KeyPgRestore|Restore]]## {{fbdoc item="back" value="CatPgMisc|Miscellaneous"}}