SECTION 1212. Files, Disks, and Drives in CP/M 3.012.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 FILEThere 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 FILE12.3.1 File SpecificationCP/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 SpecifierThe 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 FilenameA 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: CUSTOMERso that the name gives you some idea of what is in the file. 12.3.1.3 FiletypeTo 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 PasswordIn 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 SpecificationA 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 NumberCP/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 FileCertain 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 CharactersThe 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.
12.3.5 Reserved FiletypesCP/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
|
page URL: www.bigfoot.com/~c128page/c128sg/sect-12.htm
contact: c128page@bigfoot.com