The DATA command supplies data to be used by an associated verb or QMBasic program which would normally take input from the keyboard. It may only be used in paragraphs.
The DATA command must immediately follow the verb to which it is to apply. Multiple DATA commands may be used to supply data to be processed consecutively by the associated verb or program. Any intervening blank lines or comments in a sequence of DATA commands will be ignored except for processing of inline prompts.
When the verb or program executes an INPUT statement, the data from the DATA command(s) will be used. If all stored data has been used, keyboard input proceeds as normal.
Data stored by the DATA command or the QMBasic DATA statement is cleared on return to the command prompt. Thus unused data where, for example, a program terminates at an error, will not be carried forward to a later command. The CLEAR.DATA command can be used to clear the data queue within a paragraph.
The DATA command cannot be used to provide text for inline prompts.
IF <<A,Record name>> = "" THEN GO DONE
ED BP <<Record name>>
DATA I * <<History>>
This paragraph inserts a history comment at the top of QMBasic programs. The editor commands to insert the text are provided using DATA commands. Note how the history text, which is only required once as it is common to all files edited, is obtained first using an inline prompt in a comment. The names of the records to be edited are then obtained in a loop which is terminated when a null name is entered.
QMBasic DATA statement