File Types

A file a sequence of elements of the same type. Standard I/O routines use the predefined TextFile or Text type, which represents a file containing characters organized into lines. For more information about file input and output, see Standard routines and I/O.

To declare a file type, use the syntax type fileTypeName = fileoftype where fileTypeName is any valid identifier and type is a fixed-size type. Pointer types - whether implicit or explicit - are not allowed, so a file cannot contain dynamic arrays, long strings, classes, objects, pointers, variants, other files, or structured types that contain any of these.

For example, type

PhoneEntry = record

FirstName, LastName: string[20]; PhoneNumber: string[l5]; Listed: Boolean;

end;

PhoneList = file of PhoneEntry;

declares a file type for recording names and telephone numbers.

You can also use the file of ... construction directly in a variable declaration. For example, var Listl: file of PhoneEntry;

The word file by itself indicates an untyped file:

var DataFile: file;

For more information, see Untyped files. Files are not allowed in arrays or records.

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Post a comment