SECTION 12

[continue/next section] [MAIN/Introduction] [table of contents]

12. Files, Disks, and Drives in CP/M 3.0


TABLE OF CONTENTS

12.1 WHAT IS A FILE?

12.2 CREATING A FILE

12.3 NAMING A FILE

12.3.1 File Specification
12.3.1.1 Drive Specifier
12.3.1.2 Filename
12.3.1.3 Filetype
12.3.1.4 Password
12.3.1.5 Sample File Specification
12.3.2 User Number
12.3.3 Using Wildcard Characters to Access More Than One File
12.3.4 Reserved Characters
Table 12-1. CP/M Reserved Characters.
12.3.5 Reserved Filetypes
Table 12-2. CP/M 3.0 Reserved Filetypes.

12.1 WHAT IS A FILE?

One of CP/M's most important tasks is to access and maintain files on your disks. Files in CP/M are fundamentally the same as in C128 or C64 modes - that is, they are collections of information. However, CP/M handles files somewhat differently than do C128 and C64 modes. This section defines the two types of files used in CP/M, tells how to create, name, and access a file, and describes how files are stored on your CP/M disks.

As noted above, a CP/M 3.0 file is a collection of information. Every file must have a unique name by which CP/M identifies the file. A directory is also stored on each disk. The directory contains a list of the filenames stored on that disk and the locations of each file on the disk.

There are two kinds of CP/M files: program (command) files, and data files. A program file contains a series of instructions that the computer follows step-by-step to achieve some desired result. A data file is usually a collection of related information (e.g. a list of names and addresses, the inventory of a store, the accounting records of a business, the the text of a document).

12.2 CREATING A FILE

There are several ways to create a CP/M file. One way is to use a text editor. The CP/M text editor ED is used to create and name a file. You can also create a file by copying an existing file to a new location; you can rename the file in the process. Under CP/M you can use the PIP command to copy and rename files. Finally, some programs (such as MAC, a CP/M machine language program) create output files as they process input files.

The ED and PIP commands are summarized in Section 14, together with other commonly used CP/M commands. Details on these and all other CP/M 3.0 commands may be found in the CP/M Plus User's Guide, which you can obtain by following the instructions on the coupon enclosed in the box in which the C128 computer is supplied.

12.3 NAMING A FILE

12.3.1 File Specification

CP/M identifies every file by a unique file specification. A file specification can have four parts: a drive specifier, a filename, a filetype, and a password. The only mandatory part is the filename.

12.3.1.1 Drive Specifier

The drive specifier is a single letter (A-P) followed by a colon. Each disk drive in your system is assigned a letter. When you include a drive specifier as part of the file specification, you are telling CP/M to look for the file on the disk currently in the specified drive. For example, if you enter:

B:MYFILE {return}
CP/M looks in drive B for the file MYFILE. If you omit the drive specifier, CP/M 3.0 looks for the file in the default drive (usually A).
12.3.1.2 Filename

A filename can be from one to eight characters long, such as:

MYFILE

A file specification can consist simply of a filename. When you make up a filename, try to let the name tell you something about what the file contains. For example, if you have a list of customer names for your business, you could name the file:

CUSTOMER
so that the name gives you some idea of what is in the file.
12.3.1.3 Filetype

To help you identify files belonging to the same category, CP/M allows you to add an optional one- to three-character extension, called filetype, to the filename. When you add a filetype to the filename, separate the filetype from the filename with a period.

Try to use letters that tell something about the file's category. For example, you could add the following filetype to the file that contains a list of customer names:

CUSTOMER.NAM

When CP/M displays file specifications, it adds blanks to short filenames so that you can compare filetypes quickly. The program files that CP/M loads into memory from a disk have the filetype COM. DO NOT use this filetype in your own file specifications.

12.3.1.4 Password

In the Commodore 128's CP/M 3.0 you can include a password as part of the file specification. The password can be from one to eight characters. If you include a password, separate if from the filetype (or filename, if no filetype is included) with a semicolon, as follows:

CUSTOMER.NAM;ACCOUNT

A password is optional. However, if a file has been protected with a password, you MUST enter the password as part of the file specification to access the file.

12.3.1.5 Sample File Specification

A file specification containing all four possible elements consists of a drive specification, a primary filename, a filetype, and a password, all separated by the appropriate characters or symbols as in the following example:

A:DOCUMENT.LAW;SUSAN {return}

12.3.2 User Number

CP/M 3.0 further identifies all files by assigning each one a user number which ranges from 0 to 15. CP/M 3.0 assigns the user number to a file when the file is created. User numbers allow you to separate your files into 16 file groups.

The user number always precedes the drive identifier except for user 0, which is the default user number and is not displayed in the prompt. Here are some examples of user numbers and their meanings.

4A>
User number 4, drive A

A>
User number 0, drive A

2B>
User number 2, drive B

You can use the built-in command USER to change the current user number like this:

A>USER 3 {return}
3A>

You can change both the user number and the drive by entering the new user number and drive specifier together at the system prompt:

A>3B: {return}
3B>

Most commands can access only those files that have the current user number. However, if a file resides in user 0 and is marked with a special file attribute, the file can be accessed from any user number.

12.3.3 Using Wildcard Characters to Access More Than One File

Certain CP/M 3.0 built-in and transient commands can select and process several files when special wildcard characters are included in the filename or filetype. A wildcard is a character that can be used in place of some other characters. CP/M 3.0 uses the asterisk (*) and the question mark (?) as wildcards. For instance, if you use a {?} as the third character in a filename, your are telling CP/M to let the {?} stand for any character that may be encountered in that position. Similarly, an {*} tells CP/M to fill the filename with {?} question marks as indenticated.

A file specification containing wildcards is called an ambiguous filespec and can refer to more than one file, because it gives CP/M 3.0 a pattern to match. CP/M 3.0 searches the disk directory and selects any file whose filename or filetype matches the pattern. For example, if you type:

?????TAX.LIB {return}
then CP/M 3.0 selects all files whose filename ended in TAX and whose filetype is LIB.

12.3.4 Reserved Characters

The characters in Table 12-1 have special meaning in CP/M 3.0, so do not use these characters in file specifications except as indicated.

Table 12-1. CP/M Reserved Characters.

Character

< $ , ! | > [ ] {tab} {space} {carriage return}

file specification delimiters

:

drive delimiter in file specification

.

filetype delimiter in file specification

;

password delimiter in file specification

* ?

wildcard characters in an ambiguous file specification

< > & ! | \ + -

option list delimiters

[ ]

option list delimiters for global and local options

( )

delimiters for multiple modifiers inside square brackets for options that have modifiers

/ $

option delimiters in a command line

;

comment delimiter at the beginning of a command line

12.3.5 Reserved Filetypes

CP/M 3.0 has already established several file groups. Table 12-2 lists some of their filetypes with a short description of each.

Table 12-2. CP/M 3.0 Reserved Filetypes

Filetype

Meaning

ASM

Assembler source file

BAS

BASIC source program

COM

8080, 8085, Z80 or equivalent machine language program

HEX

Output file from MAC (used by HEXCOM)

HLP

HELP message file

$$$

Temporary file

PRN

Print file from MAC or RMAC

REL

Output file from RMAC (used by LINK)

SUB

List of commands to be executed by SUBMIT

SYM

Symbol file from MAC, RMAC or LINK

SYS

System file

[top of document]

page URL: www.bigfoot.com/~c128page/c128sg/sect-12.htm
contact: c128page@bigfoot.com