Download 1746-RM001A-US-P, BASIC Language Reference Manual
Transcript
Input Functions READ 13-45 Purpose Use the READ statement to retrieve the expressions that are specified in the DATA statement and assign the value of the expression to the variable in the READ statement. The READ statement is always followed by one or more variables. If more than one variable follows a READ statement, they are separated by a comma. Syntax READ Example >1 >10 >20 >30 >40 >50 >60 >70 >80 REM EXAMPLE PROGRAM FOR I = 1 TO 3 READ A,C PRINT A,C NEXT I RESTORE READ A,C PRINT A,C DATA 10,20,10/2,20/2,SIN(PI),COS(PI) READY >RUN 10 20 5 10 0 -1 10 20 READY > Every time a READ statement is encountered the next consecutive expression in the DATA statement is evaluated and assigned to the variable in the READ statement. You can place DATA statements anywhere within a program. They are not executed and do not cause an error. DATA statements are considered chained together and appear as one large DATA statement. If at anytime all the data is read and another READ statement is executed, the program terminates and the message ERROR: NO DATA - IN LINE XX prints to the console device. Publication 1746-RM001A-US-P