The DATA statements can also supply more that one variable with each READ. To do this, separate each piece of data by a comma. The READ must then use more than one variable name. Try this program:10 FOR X% = 1 TO 3 20 READ FIRST$,SECOND$,THIRD% 30 PRINT FIRST$ SECOND$ THIRD% 40 NEXT X% 50 END 60 DATA Call,me,1 70 DATA Call,me,2 80 DATA Call,me,3Each piece of data in a DATA statement is called a FIELD. The fields are separated by commas. When they are read, the first field is placed in the first variable name of the READ statement. The second field is placed in the second variable, and so on. The variable type must match the type of data. For example, the integer variable THIRD% in the READ on line 20 can only be used to hold whole numbers. An error message is issued if you try to place letters into an integer variable. This works just like INPUT.If a field in a DATA statement contains commas, semicolons (;), or many blank spaces, that field must be enclosed in quotation marks.Each time a READ statement is executed it gathers the input from the next DATA statement. Therefore, one DATA statement must exist for each time READ executes. If a READ is executed after all DATA statements have been processed, BASIC issues the error message Out of Data and the program ends.
This blog is been created for students of GW-basic facing problems in their academics year(matric). We are trying our atmost to create a teach your self blog
Wednesday, 10 December 2014
USING MULTIPLE DATA FOR SINGLE READ STATEMENT
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment