Previous chapter Index Next chapter

Chapter 3

Disc housekeeping

This chapter looks at the most common tasks you are likely to use CP/M utilities for - keeping your discs organised and up-to-date. These tasks are often described as Disc housekeeping.

Each section covers one aspect of disc housekeeping, describing the commands you will need and how to use them for the job in hand in more detail than was possible in Chapter 1. If you need to know more about a particular command or utility, you can look it up in Chapter 5.

The topics covered are:

Throughout this chapter, we assume that the utility you require for any command is either on the disc in the default drive or that you have set the disc search order (see Section 3.15) so that the utility is automatically found.

If neither is the case, you will have to include the drive the utility is on as part of its name. For example, you may have to type:

    B:PIP NEWFILE=OLDFILE
to copy a file OLDFILE on the default drive, if the copy of PIP you want to use is on the disc in Drive B.

3.1 Assessing the available space

The easiest way of finding out how much free space there is on a particular disc is to use the SHOW utility.

The simplest form of SHOW displays the free space on all the discs in currently logged-in drives, along with what type of access is allowed to that disc. For example, the screen could look like this:

A>SHOW
A: RO, Space:  44k
B: RW, Space: 158k

This tells you that the discs CP/M currently has access to, are the one in Drive A and the one in Drive B and that while you are allowed to read from and write to the disc in drive B, you may only read from the disc in Drive A. (RW stands for Read-Write; RO for Read-Only). It also tells you that you have 44 kilobytes of free data space on the disc in Drive A but 158 kilobytes still free on the disc in Drive B.

You can display just the information about one particular disc by typing, for example, SHOW B: The screen display would then be:

A>SHOW B:
B: RW, Space: 158k

If you want to find out the number of free directory entries on a particular disc, and thus the maximum number of new files you could store on that disc, the command to use is SHOW drive:[DIR]

For example, the screen could look like this:

  A>SHOW A:[DIR]
  A: Number of free directory entries: 12

3.2 Copying discs

Making copies of discs on the Spectrum +3 involves using the DISCKIT utility. If necessary, DISCKIT will also format the disc being written to as part of the copying process.

DISCKIT presents menus to help you select the correct options for the job you want to do and puts up messages to tell you what to do or to advise you of any errors that have occurred.

Before you start copying, always check that the Write Protect Holes on your CP/M Start-up disc and the discs you intend to copy are open so that you cannot spoil them by accidentally writing to the disc. (There is a diagram in Chapter 5 of the Spectrum +3 User Guide showing the position of the Write Protect Holes and how they open and close.)

Start with your CP/M Start-up disc in Drive A (the built-in drive) with Side 1 uppermost. Then type the command DISCKIT [Enter] after a system prompt. This runs the DISCKIT program, which starts by telling you to remove any discs you have in your disc drive(s). (If all you see is DISCKIT?, CP/M hasn't found the DISCKIT program on the disc(s) it searched. Check that you inserted the right disc.)

When you have done this and pressed a key (say, [Enter]), it then displays further messages. The first of these offeres the choice of Copy, Format or Verify (or Exit from DISCKIT), and tells you which function key to press to select the desired action. In this instance, you want Copy ie. the 1 key.

If you have just one disc drive, the next screen merely asks you to type Y to confirm that you want to copy the contents of one disc onto another.

If your system has two disc drives, the next screen will ask which drive you want to read from (press A for Drive A; press Q for Drive B). This is followed by a message asking which drive to write to (press A for Drive A; press Q for Drive B). You will then be asked to type Y to confirm that this is what you want to do.

The process of copying a disc may take place in a number of parts - each part copying a section of the information on the disc to READ onto the disc to WRITE. The messages that follow prompt you to put the right disc in at the right time, and tell you how the copying process is progressing (counting through the tracks, numbered 0...39, as these are copied).

The messages are designed to be self explanatory: for example, if DISCKIT needs a disc to be inserted in a particular drive, you will see a message like:

    Insert disc to READ
    Press any key to continue
or
    Insert disc to WRITE
    Press any key to continue

Put the disc to be copied into the drive with Side 1 uppermost. When the corresponding WRITE message appears, insert the disc you want to copy to, again with Side 1 uppermost. Remember that copying can take place in a number of parts - each copying a section of the information on the disc to READ onto the disc to WRITE.

If, in swopping discs in and out of a single disc system, you mix up the disc you are reading from with the disc you are writing to, DISCKIT will display an appropriate message and allow you to change to the correct disc before continuing. However, DISCKIT can only do this after it has used both discs at least once - in other words, it can't perform this service on Part 1 of the copy. This is why it is so important to write-protect the disc you are copying.

Any error messages that appear should also be self explanatory, but if you feel in need of extra help, refer to Chapter 5 where full details of the DISCKIT messages are given.

Once the process of copying one disc has been completed, DISCKIT tells you to remove all discs from the drives, and then gives you the option of copying another. If this is what you want, type Y and follow all the steps of copying a disc again.

3.3 Copying files

The utility that makes a copy of a file either on the same disc or on a different disc is the Peripheral Interchange Program, PIP.

As you might suppose from its full title, this utility is used for more actions than just copying files from disc to disc. Details of the options are given in Chapter 5.

Copying one file

The fundamental command needed to copy files is:

	PIP destination=source
where source represents the name of the file to be copied and destination the name of the new file which is created to hold the copy.

This command is used whatever the details of the file you want to copy and wherever you want to store the new file. For example:

PIP NAME.TXT=MYNAME.ADR
makes a copy of a file on the default drive called MYNAME.ADR and stores it on the default drive as NAME.TXT.
PIP B:ABC.TXT=A:XYZ.TXT
makes a copy of a file on Drive A called XYZ.TXT and stores it on a different disc as ABC.TXT.

When you want to copy the file to a different disc but retain the original filename and filetype, there is a shorter command you can give:

	PIP destination-drive:=source

For example:

PIP B:=MENU.COM
makes a copy of a file on the default drive called MENU.COM and stores it on another disc also as MENU.COM.
PIP B:=A:USEFUL.SUB
makes a copy of a file on Drive A called USEFUL.SUB and stores it on another disc also as USEFUL.SUB.

This form of the PIP instruction can't be used to make a second copy of a file on the same disc because you can't have two files with identical filename and filetype on the same disc.

As a general rule, if the destination file already exists, the old file contents are erased as part of the copying process.

Copying a group of files

In common with many other CP/M commands, PIP allows you to use Wildcards to reduce the number of instructions needed to copy a number of files from one disc to the other. The characters that can be used as wildcards are * and ?

An asterisk is used to represent any valid group of characters. It can replace a whole filename or filetype or complete a filename or filetype when you quote the character(s) that start it.

A question mark represents a single character or blank in the same position as itself.

For example:

PIP B:=A:*.COM
makes copies on another disc of all the .COM files on Drive A.
PIP B:=A:*.*
makes copies on another disc of all the files on Drive A.
PIP B:=A:PROG??.*
makes copies on another disc of all the files on Drive A whose filenames have no more than six characters and start PROG.
PIP B:=A:PROG*.*
makes copies on another disc of all the files on Drive A with filenames starting PROG.

These versions of the PIP instruction cannot be used to produce copies of a file on the same disc as the original.

Carrying out a series of copy instructions

When you have a number of files to copy, you won't always be able to find a template that picks out just the files you want. So instead of using one PIP command to copy all the files, you will have to use a number of separate PIP commands. To help you do this, PIP has a special Multiple Command Mode in which it prompts you for the next file to copy.

To start using PIP in Multiple Command Mode, you just type:

	PIP

This command loads the PIP utility into memory and starts it running. PIP then prompts you for the details of the copy you want to make by displaying an asterisk. You then type these details in the form:

	destination=source
In other words, what you type is the PIP command for the copy you want to make but without the PIP. For example, you might type:
	NAME.TXT=MYNAME.ADR

PIP makes the copy you have specified and then prompts you for details of the next copy you want to make by displaying another asterisk - and so on until you simply type [Enter] after the asterisk. Typing just [Enter] leaves PIP and returns you to the CP/M prompt. So, from start to finish, the copy operation might go something like this:

	A>PIP [Enter]
	* NAME.TXT = MYNAME.ADR [Enter] 
	* B:=A:USEFUL.SUB [Enter]
	* B:=A:*.COM [Enter]
	* [Enter]
	A>

3.4 Creating files

There is more than one way of creating a new file under CP/M.

For shorter files such as SUBMIT files (see Section 3.15), we recommend using RPED - the text editor supplied on your CP/M Start-up disc. Another option you have is to use CP/M's own Text Editor ED, details of which are given in Chapter 5 of this part of the User Guide.

These each have their own ways of handling the characters you type in, so follow the instructions carefully.

The first thing to do always is to check that there is enough room for the new file on the disc you propose to use. Use the SHOW command to do this (see Section 3.1).

Using RPED to create a file

RPED is a fairly simple Text Editor. Its advantage is that it displays a constantly updated version of the file you are working on and allows you to use the cursor keys etc. to move around the text and edit it.

To use it, insert your CP/M Start-up disc in Drive A and just type A:RPED after a system prompt. (If you don't use the supplied PROFILE.SUB on your Start-up disc, CP/M may simply respond with RPED?. If this happens, try typing SUBMIT A:RPED.)

CP/M then loads RPED. When it has finished loading, you will see a display like this:
This screen editor is for small files (up to 200
lines) and uses normal cursor and delete keys on
both text and filenames.

     EDIT  toggles insert/overstrike mode,
     BREAK ends the edit,
     ^C    aborts the edit.
	 
	 
     5  To edit last screen
	 
     3  To edit new screen
	 
     1  To edit existing file
	 
     0  To quit
	 
	 
	 
	 
	 
[#_]                                 Drive is A:

The top few lines of the screen explain in general terms how RPED works. Read this carefully. Displayed in the centre of the screen are the keys you need to press either to start editing an existing file or to create a new file or to stop using RPED. The other aspect of using RPED to note is that your Spectrum is now working with a 24 x 80 screen - so that the lines of your text file are displayed correctly. (Each line is 80 characters long.)

The key to press to create a new file is 3. Press this now. RPED then asks you to type in the name for your new file.

Type this in as filename.typ. For example, if the file you are preparing is a SUBMIT file (see Section 3.15) you might type MYPROG.SUB. This name is then inserted in the box provided for it.

If you make any mistakes typing this name, use the Cursor keys to move back to the part of the name you want to change and then re-type this part of the name. You should also use this technique to change the drive letter at the start of the file name if you want to store the file on a different drive to Drive A. (Note: Pressing [Delete] to try to delete the old filename does not work: you have to move the cursor to the left of the current drive letter and then type the new drive letter.)

When the name is correct, press [Enter]. RPED then displays a second screen - which is essentially a blank piece of paper on which to type your file. Type the file line by line, pressing [Enter] at the end of each line to move to the start of the next line.

If you make any mistakes in your typing, simply use the Cursor keys to position the Cursor where you want to make the change, use [Delete] and [Graph] to delete characters you no longer want and type in fresh characters. Note: This is the simplest way of editing the file. You can also:

Details of these actions are given in Section 3.6 'Editing text files'. (Creating a file and editing a file are very similar action.))

When you have finished preparing your file, press [Break]. The file is then saved on disc and you are returned to RPED's first screen so that you can, for example, create another file by pressing 3 again.

Press 0 to finish working with RPED.

3.5 Editing the command line

You can always use the [Delete] key to rub out characters when you make a mistake or change your mind about the command you want to execute. However, CP/M Plus provides some short cuts to getting the command line typed in correctly - including using an earlier command as part of the current command. These short cuts are taken by pressing particular keys or combinations of keys on the Spectrum +3 keyboard.

The keys you want are as follows:
[<] to move the cursor back one character
[>] to move the cursor forward one character
[Extend Mode]+B to move the cursor to the beginning of the line
[Extend Mode]+B, twice to move the cursor to the end of the line
[Extend Mode]+E to move the cursor to the beginning of the next line without executing the current command line
[Graph] to delete the character under the cursor
[Delete] to delete the character before the cursor
[Extend Mode]+K to delete from the cursor to the end of the line
[Extend Mode]+X to delete from the start of the line to the cursor
[Edit] to copy the previous command line onto a new line (so that it can be edited before being sent to CP/M again)

Typing a character inserts the character at the cursor. The cursor and any characters to its right are moved one character to the right.

Using the [Edit] key followed by the arrow keys and the [Delete] and [Graph] keys can avoid much re-typing when you want to execute a series of similar commands.

3.6 Editing text files

There are two tools on your Spectrum +3 that you can use to edit text files - RPED and the CP/M Text Editor ED. We suggest you use RPED. This displays a constantly updated version of your file on the screen and allows you to use the Cursor Keys etc. to move around the file and edit it. Details of how to use RPED to edit a file are given below. Alternatively, you might use the CP/M Text Editor ED to edit this file - see the description of ED in Chapter 5.

Using RPED to edit a file

If you have already used RPED to create a file, you will fid the steps involved in editing very similar. The only difference is that you select a different option from RPED's initial 'menu' and you have to specify both the name of file you want to edit and where you want the new version stored. (You don't have to overwrite the 'old' file if you don't want to.)

To use RPED, insert your CP/M Start-up disc in Drive A and just type A:RPED after a system prompt. (If you don't use the supplied PROFILE.SUB on your Start-up disc, CP/M may simply respond with RPED?. If this happens, try typing SUBMIT A:RPED.)

CP/M then loads RPED. When it has finished loading, you will see a display like this:
This screen editor is for small files (up to 200
lines) and uses normal cursor and delete keys on
both text and filenames.

     EDIT  toggles insert/overstrike mode,
     BREAK ends the edit,
     ^C    aborts the edit.
	 
	 
     5  To edit last screen
	 
     3  To edit new screen
	 
     1  To edit existing file
	 
     0  To quit
	 
	 
	 
	 
	 
[#_]                                 Drive is A:

The top few lines of the screen explain in general terms how RPED works. Read this carefully. Displayed in the centre of the screen are the keys you need to press either to start editing an existing file or to create a new file or to stop using RPED. The other aspect of using RPED to note is that your Spectrum is now working with a 24 x 80 screen - so that the lines of your text file are displayed correctly. (Each line is 80 characters long.)

The key to press to edit an existing file is 1. Press this now. RPED then asks you to type in the name of the 'Source' file - that is, the file you want to edit. Type this in as filename.typ. For example, if the file you want to edit is a SUBMIT file (see Section 3.15) you might type MYPROG.SUB. This name is then inserted in the box provided for it.

If you make any mistakes typing this name, use the Cursor keys to move back to the part of the name you want to change and then re-type this part of the name. You should also use this technique to change the drive letter at the start of the file name if you want to store the file on a different drive to Drive A. (Note: Pressing [Delete] to try to delete the old filename does not work: you have to move the cursor to the left of the current drive letter and then type the new drive letter.)

When the name is correct, press [Enter]. RPED then asks you to give it the name of the Destination file - that is, the file you want to save the edited version in. If you want the new version to replace the existing file, just press [Enter]: otherwise edit the name in the box as described above and then press [Enter].

When you press [Enter], RPED displays the current file (or, at least, the first section of this file) on a second screen. You can now move the Cursor to any point in the file by pressing the Cursor keys and you can make changes as follows:

Note: You effectively edit a line at a time and so you must plan your editing in terms of correcting each line separately. You can't, for example, split one line into two by positioning the Cursor where you want to make the break and then pressing [Enter]. Pressing [Enter] merely moves the Cursor to the start of the next line.

When you have finished preparing your file, press [Break]. The file is then saved on disc and you are returned to RPED's first screen so that you can, for example, create another file by pressing 1 again or re-edit this file by pressing 5.

Press 0 to finish working with RPED.

3.7 Erasing files

You delete files you no longer need by using an ERASE command. The space taken up on the disc by the data and the entry in the directory are automatically reclaimed for use by a later file.

The most general form of this command is:

    ERASE file
or
    ERA file
where file represents the name of the file to be erased.

For example:

ERA MYFILE.COM
erases the file on the default drive called MYFILE.COM
ERASE B:TEMP.TXT
erases the file on drive B called TEMP.TXT

If no file is found with exactly the given name, the screen message No File will appear.

The ERASE command also allows you to use Wildcards to reduce the number of instructions needed to erase a number of files.

The characters that can be used as wildcards are * and ?

An asterisk is used to represent any valid group of characters. It can replace a whole filename or filetype or it can complete a filename or filetype when you quote the character(s) that start it.

A question mark can only represent any single character or blank in the same position as itself.

Note: The wildcard version of the ERASE command needs to be used with care. Files erased in error cannot be restored.

A way of guarding against this while still taking advantage of the compact wildcard instruction is to use the Confirm Option of the ERASE command. The usual command is followed by [C] or [CONFIRM]. However, this option can only be used when the associated utility ERASE.COM is available either on the default drive on another drive that you tell CP/M to search (either directly by putting the drive letter followed by : at the start of the command or indirectly by using SETDEF to put the drive on the search path - see Session 3.15).

As CP/M finds entries in the disc's directory that match the given specification, it displays the filename, along with a message asking you to confirm whether this file is to be deleted by typing Y or N as appropriate. It then proceeds to find the next match.

For example:

ERA *.DAT[C]
finds all the files on the default drive that have the filetype DAT and asks you to confirm that you want each one erased (assuming that ERASE.COM is either in the default drive or on the search path). Type Y to erase; N to leave the file on the disc.

3.8 Finding the size of a file

If you want to know the size in kilobytes of one or more files, the command to use is a DIR command with the SIZE option. CP/M recognises that you want this additional information if you add [SIZE] to the end of your DIR command. However, this option can only be used when the associated utility DIR.COM.COM is available either on the default drive or on another drive that you tell CP/M to search (either directly by putting the drive letter followed by : at the start of the command or indirectly by using SETDEF to put the drive on the search path - see Session 3.15).

You get this information only for the files you want, either by going through one by one giving the ful names of each file you want or by making appropriate use of Wildcards. The characters that can be used as wildcards are * and ? An asterisk is used to represent any valid group of characters. It can replace a whole filename or filetype or it can complete a filename or filetype when you quote the character(s) that start it. A question mark can only represent any single character or blank in the same position as itself.

For example:

DIR PR???.*[SIZE]
displays the names and sizes of all those files with at most five letter filenames starting with PR (assuming that DIR.COM is either on the default drive or on a drive on the search path).

3.9 Formatting discs

Formatting is the preparation a blank disc needs before data can be stored on it. Formatting a new disc involves using the DISCKIT utility. You can also format an old disc, but you should remember that this will destroy all the old data.

If you also want to be able to load CP/M from the new disc, you must both format the disc and then put a copy of the file containing the CP/M operating system onto the disc. The operating system is stored in the file called S01CPM3.EMS or a similar name to this. One way of doing this is to copy your CP/M Start-up disc onto your new blank disc, as described in Section 3.2. (Formatting is automatically a part of the copying process.) You can then use the ERASE command to erase all but S01CPM3.EMS from the newly copied disc (see Section 3.7).

Start by checking that the Write Protect Holes of your CP/M Start-up disc are open so that you cannot accidentally format this disc. (There is a diagram showing the position of the Write Protect Holes and how they open and close in Chapter 5 of the Spectrum +3 User Guide.)

Then ensure that the CP/M Start-up disc is in Drive A.

Type DISCKIT [Enter]; then remove any discs from the drive(s) and press a key when prompted. This brings up a set of messages, which offer the choice of Copy, Format or Verify (or Exit from DISCKIT), and tell you which key to press to select the required option. In this instance, the Format option is required, and so press the Q key.

(If all you see is DISCKIT?, CP/M hasn't found the DISCKIT utility. Check that you inserted the right disc.)

Users with just one disc drive will then get a message asking them to insert the disc to be formatted. Those with two drives at their disposal will be asked which drive will be used for formatting, and then asked to type Y to confirm that this information has been entered correctly.

Place the new disc in the specified drive with Side 1 uppermost and press a key (say, [Enter]).

Throughout the formatting process, messages can appear at the top of the screen. Most of these should be self explanatory: for instance, no disc in the drive could lead to the screen message:

    Insert disc to format
	Press any key to continue

Th messages that indicate that some error has occurred should also be self explanatory, but if you need extra help turn to Chapter 5 where the DISCKIT messages are given in full.

3.10 Listing the directory

The command normally used to display information about your files is DIR. This is a built-in command: in some circumstances, it is supported by the DIR utility.

If you simply want a list of the files on a disc, type:

    DIR drive:
where drive is the letter representing the drive holding the disc and is omitted in the case of the default disc. For example:
DIR
lists out all the files on the default disc
DIR B:
lists out all the files on the disc in Drive B

If there are also some special files called System Files on that disc, you will be told this once all the Non-system files have been listed. The command needed to list these files is the DIRSYS command.

A detailed discussion of the DIRSYS command is inappropriate here. All you need to remember about DIRSYS is that is works very much like DIR, but only DIR can be enhanced through the various directory searching options.

You can also use the DIR command if you just want to see if a particular file is on the disc you are working with. The command line to type is:

    DIR file
where file represents the name of the file. For example:
DIR B:MYPROG.COM
tests if there is a copy of the file MYPROG.COM on Drive B

If it isn't, then No File will appear on the screen.

You can use this version of the command, but with Wildcards, to list out details of a group of files. The characters that can be used as wildcards are * and ?. An asterisk is used to represent any valid group of characters. It can replace a whole filename or filetype or it can complete a filename or filetype when you quote the character(s) that start it. A question mark can only represent any single character or blank in the same position as itself. For example:

DIR B:*.COM
lists out just those files on the disc in Drive B that have the filetype COM
DIR PR???.*
lists out only those files on the default disc with filenames that start PR and have no more than five characters

You can obtain more information about the files by using the Options associated with the DIR command. To use these options, you must have the companion DIR.COM utility either on the default drive or on the search path you have set with a SETDEF command (see Section 3.15) - or you should tell CP/M where to find it by putting the drive letter followed by : at the start of your command.

Some of the more useful options are EXCLUDE, FULL and SIZE. EXCLUDE enables you to list all files except those with the given filename; FULL makes the directory listing include size and all the special characteristics along with each file; and SIZE gives the size of each file listed.

The SIZE option is used most often to discover how big a particular file is, typically just before it is copied from one disc to another.

For example:

DIR B:MYPROG.COM[SIZE]
displays the filename, filetype and size in kilobytes of a file on the disc in Drive B called MYPROG.COM (assuming that DIR.COM is either on the default drive or on a drive on the search path).

3.11 Listing a file

If you want to examine the contents of any file on the screen, type:

    TYPE file
where file represents the name of the file to be listed.

The contents of the file are displayed on your monitor, a screenful at a time. Press [Enter] to see more.

If you would like to get a print out of the file at the same time, type 'Control-P' ([Extend Mode]+P) before you type the above command. The Spectrum will bleep when you do this. Now all the text that appears on the screen will be 'echoed' on the printer.

A second 'Control-P' will turn the printer off.

Alternatives to both of these instructions are provided by the PIP utility.

PIP CON:=file
copies the named file to the screen
PIP CON:=file
copies the named file to the printer

3.12 Organising your discs

The way files are organised on CP/M discs allows you to put files on the same disc into separate more manageable groups, each with its own directory. You can then work on just the files listed in one directory at a time.

The files in the separate directories are treated as if they belonged to different people. The 'people' are referred to as Users and so each group is given a User Number. User Numbers run from 0 to 15, giving you up to 16 different groups in which to put your files.

All the time you are running CP/M, you have a User Number. This is referred to as the Current User Number. You can always tell what the Current User Number is from the System Prompt. For example, if the system prompt is 3A>, the Current User Number is 3 but if the prompt just gives the letter of the default drive, then the Current User Number is 0.

In general the files you work with at any time are the ones with the current user number. Files with a different User Number are hidden from you. Any new files you create will also have the current User Number.

For example, suppose you had the files MYFILE.A, MYFILE.B and MYFILE.C with User Number 0 and the files YOURFILE.A and YOURFILE.B with User Number 1. While the Current User Number is 0, the files you can process are the MYFILE files and the YOURFILE files are hidden from you. If the Current User Number is some other number (say, 5) both groups of files will be hidden from you.

Most of the commands only work with files from the Current User Number. However, a few can process files of a different User Number. In particular, you can use the PIP command to create copies of these files either with the Current User Number or with a different User Number. You can therefore 'tidy up' a disc by copying files to a different User Number and then erasing the original copy. However, you may have to change the Current User Number before you erase a file because the only files you can erase are ones with the Current User Number.

To change the Current User Number, type either:

    USER number [Enter]
or
    number: [Enter]

For example, to change to User Number 3, type either:

USER 3 [Enter]
or just
3: [Enter]

If you wish, you can change the Current Drive at the same time as the Current User Number by typing:

    number drive:[Enter]

For example, you can change to User Number 3 on Drive B: by typing:

    3B:[Enter]

CP/M responds by changing the System prompt - in this case to 3B>

In general the only program files that you can run have the Current User Number. The exception to this is program files that have User Number 0 and that have been designated System files (see Section 3.13), which can be run whatever the Current User Number is.

3.13 Protecting your files

As you store programs and data in files, there are a number of questions you should give thought to:

If you regularly make back-up copies of your valuable files - something we advise most strongly - you may not need to take any special steps to protect your files. If this is the case, you don't need to read any further.

Protecting your files is all about giving files the right set of labels. For example, if you don't want the contents of a file to be overwritten, then you give the file a label to say that it can only be read. These labels are often called Attributes, they can be changed at any time during the lifetime of the file and they are copied when the file is copied.

Protecting against accidental deletion

The way to ensure that your important files are not lost through being accidentally overwritten or deleted is to give them a RO (Read-Only) label. The files are then said to be Write-protected, and they stay Write- protected until you replace the RO label with a RW (Read-Write) label.

The utility you use to mark a file Read-Only or Read-Write is the SET utility and you use it as follows.

To mark a file Read-Only, you type the command:

    SET file [RO]

To mark it Read-Write, you type the command:

    SET file [RW]

So, for example, to make MYFILE.A Read-Only, you would type the command:

    SET MYFILE.A [RO]

Note: Marking a file RO protects against an unwise ERASE command (eg. one involving wildcards). It does not stop you losing files when you re-format the disc they are stored on or when you damage the disc, for example by pouring coffee over the disc!

Separating vital programs from files

Programs which are vital to your system are protected by making them System files by giving them the label SYS. All other files have the label DIR.

System files:

Another reason for labelling a program as a System file is to make it available for use when the Current User Number is not the program's User Number. However, this only applies to program files (ie. files with the filetype COM) with User Number 0.

The utility you use to make a file a System file is again the SET utility and you type the command:

    SET file [SYS]

So, for example, to make MYPROG.COM a System file, you would type the command:

    SET MYPROG.COM[SYS]

To make it a 'non-system' file again, you would type the command:

    SET MYPROG.COM[DIR]

Note: Marking some of your files as System files is also a way of making your disc appear tidier when you list its contents, because Directory files and System files are listed separately using different command (see Section 3.10).

Applying passwords to files

If you are worried about a file being read or changed by someone else, you can give the file a password which must be typed in before the file can be used. This stops anyone who doesn't know the password from using the file - but it also means that you have to remember the passwords you set if you are going to be able to use the file yourself! There's nowhere you (or anyone else) can rediscover what password you used.

CP/M gives you a choice of actions to protect through a passowrd, which you select by setting the Protection mode as follows:
Reading, copying, changing, deleting and renaming the READ mode
Changing, deleting and renaming but not reading or copying the WRITE mode
Just deletingthe DELETE mode

You set both the password and the Protection mode with SET commands as follows.

The first step is to ensure that the disc holding the file has password protection 'turned on'. This is done by using the command:

    SET drive:[PROTECT=ON, PASSWORD=password]
(You need the password to stop someone else simply coming along and turning password protection off!)

You can then set the password and the protection mode you want for the individual files on this disc by typing commands of the form:

    SET file [PASSWORD=password, PROTECT=mode]

For example, to protect MYFILE.A against being changed, deleted or renamed, you might type the command:

    SET MYFILE.A[PASSWORD=SECRET, PROTECT=WRITE]

Once a file has been given a password, you have to give this password before any of the protected actions can be carried out. You do this either by following the name of the file in your command line with ;password or by setting the 'Default' password to this password by using the command:

    SET [DEFAULT=password]

To clear the password protection, you have to set the Protection mode to NONE - but before you can do this, you have to show that you have a right to do this by quoting the password immediately after the name of the file as follows:

    SET MYFILE.A;SECRET[PROTECT=NONE]
Note: If you copy a password-protected file, the new file you create will also be password protected if you:

In the first case, the copy is given the same password and the same Protection mode; in the second case, the copy is given the new password and the Protection mode is set to READ.

You can only copy a group of files that includes password-protected files if they all have the same password and you set the Default password to this password first.

3.14 Renaming files

The renaming of files is handled by the built-in RENAME command, in some cases supported by the RENAME utility.

Renaming is just a change of name; the data or program file itself is not altered in any way by RENAME.

The most general form of this command is:

    RENAME new-name=old-name
or
    REN new-name=old-name
where old-name represents the current name of the file and new-name the name you wish to change it to.

For example:

REN DOC.BAK=DOC.TXT
changes the name of the file DOC.TXT on the default disc to DOC.BAK
REN B:RECORDS.Y85=B:RECORDS.LST
changes the name of the file RECORDS.LST on the default disc to RECORDS.Y85

The only restriction on your choice of new-name is that it must not be the name of any existing file on that disc.

RENAME won't accept a different drive for the file under its old name to that you quote with its new name: in other words, it cannot be used to move a file from one disc to another. To do that, you have first to use PIP to copy the file (see Section 3.3) and then use ERASE to delete the original copy of the file (see Section 3.7).

If CP/M fails to find old-name in the directory, the message No File will be displayed on the screen.

You can reduce the number of instructions needed to rename a number of files by appropriate use of Wildcards.

The characters that can be used as wildcards are * and ?

An asterisk is used to represent any valid group of characters. It can replace a whole filename or filetype or it can complete a filename or filetype when you quote the character(s) that start it.

A question mark represents a single character or blank in the same position as itself.

But if you do decide to use the wildcard option, you must remember to make the wildcards in old-name and new-name identical. For example, REN *.TX1=*.TEX and REN A*.T*=S*.T* are valid commands but REN A*.TEX=A*.T* isn't.

3.15 Shortening the command line

You can shorten many of your command lines by extending the way CP/M interprets the commands you give it:

Storing sequences of commands

Suppose, for example, that in order to run a particular program, you usually type the commands:

    PIP B:=*.DAT
    SETKEYS KEYS.APP
    APPLIC B:DATAFILE.DAT

If you were to put these command lines in this order into a file which you called TRANS.SUB, you could then use CP/M SUBMIT utility to get the same effect by just typing:

    SUBMIT TRANS

The TRANS.SUB file is called a SUBMIT file. SUBMIT files are always just simple text files which you can create (and edit) by using the RPED text editor (see Section 3.4). They always have the filetype SUB.

SUBMIT files are typically made up of a sequence of command lines written exactly as you might type them at the keyboard, with each command line on a separate line of the file. Sometimes they will also include lines of data that will be required by the programs being run. Each line of data appears on a new line, at the point in the sequence where the information will be needed, and starts with a <.

A common requirement for data lines is given by any SUBMIT file that uses the PIP utility in its multiple command form (see Section 3.8). The lines giving details of the Source and Destination of each copy, that follow the command line

    PIP
are essentially lines of data required by the PIP program and so appear on separate lines of the SUBMIT file, each starting with a <. This includes the last line on which you just press [Enter] to signal that you have no more files you want to copy.

For example, suppose you would need to type the following to make the copies you require:

    PIP [Enter]
    B:=A*.DAT [Enter]
    B:=B*.DAT [Enter]
    [Enter]
then this should appear in your SUBMIT file as:
    PIP
    < B:=A*.DAT
    < B:=B*.DAT
    < 

If you want CP/M to carry out a specific sequence of actions immediately after it has been loaded, you just put the commands you would type to carry out these actions into a special file in User Number 0 called PROFILE.SUB. Any command in PROFILE.SUB are always executed as part of loading CP/M.

Your Spectrum +3 was supplied with a PROFILE.SUB as follows:

    SETDEF *,C: [ORDER=(SUB,COM)]
    PIP
    < C:=PIP.COM
    < C:=SET24X80.COM
    <

This copies the PIP and SET24X80 utilities into the Memory Disc and sets a program search path such that CP/M will automatically look for programs both on the default drive and on the Memory Disc (see below). If you create your PROFILE.SUB by adding to the supplied file, you will retain these actions as an automatic part of loading CP/M.

Setting up a search path

The utility which sets up the search path is called SETDEF. It has two principal actions: extending the number of drives automatically searched for programs; and instructing CP/M to treat SUBMIT files as additional programs.

Searching additional discs

Normally, if the program you want to run is not on the default drive, you have to specify the drive it is on in your command line. You can make your command lines much simpler by giving CP/M a list of drives to search alongside the default drive. To do this, you use the SETDEF utility with the drives you want searched as its parameters. The order in which you list the drives will be the order in which they are searched for your programs.

For example:

SETDEF B:,A:
instructs CP/M to look for utilities first on Drive B and then on Drive A

If you want to put the default drive on this list, then you use an asterisk to represent the default drive. For example:

SETDEF B:,*
instructs CP/M to look for utilities first on Drive B and then on the default drive.

This use of an asterisk is special to SETDEF. It is not followed by a colon.

Including SUBMIT files in the search

The ORDER option of the SETDEF utility is used to extend the search to cover SUBMIT files that you set up.

You can either specify that CP/M searches .SUB files first and then .COM files or vice versa. It executes the first file it finds with the given name.

The two possible SETDEF commands are:

    SETDEF [ORDER=(SUB,COM)]
and
    SETDEF [ORDER=(COM,SUB)]

Choose the first of these if you have called the SUBMIT file to run a particular program program-name.SUB. Otherwise typing the command program-name will just execute the program itself and not the other commands that you have put into your SUBMIT file.

Suppose you had made this choice. Then, the command line:

    MYCOMM
would make CP/M search first for a file called MYCOMM.SUB and only if it cannot find it, would it carry on and search for a file called MYCOMM.COM.

If it finds MYCOMM.SUB, CP/M will execute the command as if you had typed:

    SUBMIT MYCOMM

Note: You can, if you want, override the rule you've set with SETDEF in order to run individual program or SUBMIT files. If you want to run the program file rather than the SUBMIT file, you type the program name as name.COM. If you want to run the SUBMIT file rather than the program file, you use the SUBMIT utility explicitly and begin your command line SUBMIT name.

3.16 Switching which disc is read or written

You switch discs either by changing which drive is treated as the default drive or by physically changing the disc in a drive.

The default drive is changed by simply typing in new-drive:

For example, suppose you would like Drive B to become your default drive. The command to type in is just:

    B:[Enter]

Most of the time when you want to change which disc is in Drive A or Drive B, all you need to do is release the old disc and put in the new one. But there are some circumstances in which CP/M won't be able to find all the files on the new disc if you don't tell it that you have changed the disc in the drive immediately after putting the new disc in. In particular, DIR may not give you details of all the files on the disc.

Always resetting the drive is therefore a good habit to get into.

The drive is reset by the control code, Control-C, which is generated by holding down [Extend Mode] and pressing C.


Previous chapter Index Next chapter