4. Input/Output Processing
A key reason for the existence of programs is to change data from one form to another. This implies that there must be a source of data in some form and resultant data when the program is done. In earlier versions of Thoroughbred Basic there was a DATA statement, which contained the source data for the program. Later, additional commands were added which allowed the program to take in (input) or send out (output) data from the keyboard and monitor. Today, almost every storage device and communication path is available to the program for input and output.
Data, both input and output (I/O), can be grouped or classified in several ways. It can be raw, as opposed to edited; random versus sequential; fixed-length or variable-length; structured or unstructured. Data can be a simple stream of characters or could be carefully broken up into files, records, fields, and/or bytes. The programmer’s principal concerns are aimed at understanding how to get data into the program, what to expect when the program gets that data, how to get data ready for output and send it out, and how does the program start and end these exchanges of data.
Thoroughbred Basic recognizes the concepts of:
Tasks, which are other programs that may want to input data from this program, or output data to this program.
Devices, such as tape drives and printers, which accept or send data on commands from the program.
Logical Disk Directories, which represent a collection of files of data on physical disks and provide a level of organization of files into logical groups.
Files, in a variety of structures that contain related data in the form of records.
Records within files that contain related pieces of data as one or more fields.
Fields within records, containing related strings of bytes that may be defined only by their position within the total record or may be separated by a field separator character.
Bytes within fields that represent characters of data.
Tasks, devices, and logical disk directories normally have 2-character names. Files have names up to 8 characters long in Thoroughbred Basic, even though the actual file as stored on disk may contain many more characters preceding the Thoroughbred Basic filename. Records, fields, and bytes do not have names, but are accessed by the position of the record in the file, the field in the record, or the byte in the field.
In this chapter
Section titled “In this chapter”- How programs input or output data
- Data organization
- Other directives used for input/output processing
- Input/output options for directives
- Mnemonics
- How Thoroughbred Basic locates a file
- Transaction processing
From the Thoroughbred Basic Developer Guide, version 8.9.1. Open this page in the PDF