Commodore 2031 User Manual

Table of Contents
Chapter1
General Description 1 Introduction 1 The Manual - A Learning Tool 2 General Hardware Information 3 Front Panel 3 Back Panel 4 Interior Configuration 4 The Diskette 4 Specifications 5 Care of the 2031 5 Care of the Diskettes 7 Unpacking the Disk Drive 7
Chapter 2
Preparing Your Disk Drive 9 Connecting the Disk Drive To The Computer 9 Performing the Power-On Test 10 Inserting The Diskette Into The 2031 12 The 2031 Performance Test 12
Chapter 3
Learning How To Use Your Floppy Disk Drive 15 The Block Availability Map (BAM) 16 The Disk Operating System (DOS) 17 Disk Maintenance Commands 18 NEW 18 HEADER (BASIC 4.0 Direct Command) 20 Initializing The 2031 20 The Directory 20 LOAD$ 21 DIRECTORY (BASIC 4.0 Direct Command) 21 Printing The Directory 21 VALIDATE 22 COLLECT (BASIC 4.0 Direct Command) 22 COPY 23 COPY (BASIC 4.0 Direct Command) 24 CONCAT (BASIC 4.0 Direct Command) 24 RENAME 24 RENAME (BASIC 4.0 Direct Command) 25 SCRATCH 26 SCRATCH (BASIC 4.0 Direct Command) 26
iii
Chapter 4
BASIC Commands For Data Handling 27 BASIC Commands Associated With Floppy Disk Drives 27 SAVE and DSAVE (Writing a Program to a Diskette) 28 LOAD and DLOAD (Reading a Program from a Diskette 29 VERIFY 30 OPEN 31 DOPEN 32 CLOSE 32 DCLOSE 33 Closing the Command Channel 33 Closing the Data Channel 34 PRINT# 34 INPUT # 36 GET# 37 RECORD# 37 Quickload Feature (BASIC 4.0) 38 Moving A Tape Program to Disk 39
Chapter 5
Advanced Disk Programming 41 Commodore Disk Operating System (DOS) 41 Disk Utility Command Set 42 BLOCK-READ 44 BLOCK-WRITE 44 BLOCK-EXECUTE 45 BUFFER POINTER 45 BLOCK-ALLOCATE 45 MEMORY 46 MEMORY-WRITE 46 MEMORY-READ 47 MEMORY-EXECUTE 47 USER 47 File Types 49 File Formats 49
Chapter 6
Advanced File Handling 55 Special Open and Close Statements for Direct Access 55 Random Access Example 56 To create A File 57 To Add A Record 58 To See A Record 59 To Change A Record 60
iv
Getting The Directory of Listings 60 Ending the Program 60 Relative Files 60 Relative File Components 61 Side Sectors 61 Relative File Expansion 61 I O Channels 62 Spanning 63 Print Termination 63 Creating A Relative File 65 Expanding A Relative File 65 Accessing A Relative File 66
Chapter 7
Simplifying The Use Of Commodore Disk Related Commands 71 Loading The DOS Support Program 71 Using The DOS Support Symbols: > and @ 71 Loading the Program With The / 73 Loading And Running A Program With Up Arrow 73 Special DOS Support Information 73 Changing Device Number 74
Chapter 8
Chapter 9
Random Example Program Listing 85
Chapter 10
Index 91
List of Illustrations
Figure Title Page
1 Model 2031 Rear View 8 2 Floppy Disk Hookup 10 3 Position for Diskette Insertion 11 4 Expanded View of a Single Sector 53
v
List of Tables
Table Title Page
1 Suggested Reading List 4 2 Specifications: Model 2031 Single Drive Floppy Disk 6 3 Standard Jump Table 48 4 Block Distribution By Track 50 5 2031 BAM Format 50 6 2031 Directory Header 51 7 Directory Format 51 8 Directory Entry Format 52 9 Sequential Format 52 10 Program File Format 52 11 Relative File Format 62
vi
Chapter
1
GENERAL
DESCRIPTION
INTRODUCTION
With the purchase of your Commodore 2031 Floppy Disk Drive, you have greatly enhanced the computing power of your disk-oriented Commodore Computer system. The system has been designed around the central concept of providing you, the user, with large file-handling capabilities supported by BASIC programming commands and further simplified by Disk Operating Sys­tem (DOS) Support command abbreviations.
Because the disk drive is an "intelligent" peripheral device, its operation requires no additional space in the computer's memory. This means you have just as much computer memory available to you as when the disk drive is not attached.
When the disk drive is properly interface to a Commodore Computer, YOU become an important element of the system. Your importance, however, is measured directly with how well you understand how to effectively utilize the hardware and software. That's why it is best to think of your computer and disk drive as only part of a system. Grasping and understanding the concept that each individual component acts and reacts to signals and commands from other devices in the system will accelerate your fundamental grasp of how to operate, control, and master the system. This concept forms the basis of this manual: teaching you how to gain mastery of the system so that it will perform as desired. That is the reason this manual is organized in a building block fashion; it permits you to advance as fast as you desire.
1
To get the most out of your system you should study your Computer User's Guide and, if necessary, obtain selected manuals listed in Table 1. You will benefit most if you first read through this entire manual before attempting to operate the Disk Drive.
THE MANUAL - A LEARNING TOOL
This manual is designed to encourage the concept of learning by doing. Difficult concepts and procedures have been broken down into simpler steps that lead the user through examples which provide ample opportunity to experiment later by returning to each command description. When possible, the command format has been included with the command description and, as an additional aid, a User's Quick Reference has been placed in Chapter 8 for easy access if problems persist.
The first chapters discuss basic hardware features and permit you, right from the start, to become familiar with the disk drive by doing the performance tests which comprise the first essential "hands on" experience. Then, by actually using your particular disk drive and learning to carefully follow instructions, you can gain the necessary confidence to proceed to more comprehensive subjects.
By the time you begin Chapter 3, Learning How To Use Your Floppy Disk Drive, you will have already used some portions of the DOS Support system which is fully described in Chapter 7. It is actually easier to instruct a new user by using the simplified command structure of DOS Support than attempting to explain the entire command hierarchy at an early stage. This concept of provid­ing you with enough essential information to complete a task, a step-by-step description of the task, and meaningful examples is a feature of this manual which will provide you with sufficient incentive to actually complete the task.
Problems are often accompanied with error messages. These error messages are contained in Chapter 8 where they can be quickly referenced, if needed. The Error Message discussions have been expanded to include:
* How to request error messages.
* Error message summary.
* Detailed error message descriptions.
For those users who have been reluctant to attempt disk programming because of the presumed degree of difficulty, note that the entire disk command hie­rarchy is structured in this manual from the least difficult to the more complex:
2
* Commands for file manipulation and maintenance * Commands for data handling * Advanced programming * Advanced file handling * Simplified commands
Users who have attained some degree of programming skills may desire to begin with the advanced subjects such as random access or relative files while others may be content with just following the manual's format. In either case, this manual has been structured to provide the user with essential information in a logical sequence. Follow the examples, attempt the step-by-step procedures, and learn by doing.
GENERAL HARDWARE INFORMATION
The CBM model 2031 Floppy Disk Drive, described in this manual, is a 170 K-byte capacity storage device. Its primary components consist of read/write controls, drive motor electronics, one drive mechanism, one read/write head, and a track positioning mechanism. Also, the disk drive conforms to IEEE-488 interface requirements.
For ease of reference, the Model 2031 Single Floppy Disk Drive will be referred to in this manual as "the 2031".
The 2031 is operationally compatible with the following Commodore Computers:
1. Series 2001 -- 16K and 32K -- Operating With BASIC Version 3.0
2. Series 2001 -- PET 8K -- Upgraded to BASIC Version 3.0
3. Series 3000 -- 16K and 32K -- Operating With BASIC Version 3.0
4. Series 4000 -- PET 8K, 16K, and 32K -- Operating With BASIC Version
4.0
5. Series 8000 -- 32K -- Operating With BASIC Version 4.0
FRONT PANEL
The disk drive's front panel consists of an identification panel across the top, a slot in which to insert a diskette, and a door to close after inserting the diskette.
When the door is closed, the diskette is clamped onto the diskette spindle hub. Also, there is a LED indicator light on the front panel. This light is called the Drive Active Indicator; it lights when the drive is active. This LED flashes continuously if an error has occurred; it will extinguish after the error channel has been read.
3
Back Panel
The back of the disk drive contains an IEEE-488 interface connector. Near the panel's lower edge is the power ON/OFF switch. There is also a "slow blow" fuse, and the AC power cord.
Interior Configuration
The interior of your 2031 contains a disk drive and all the necessary logic for disk operation. The mechanical device is, for the most part, located beneath the disk spindle.
The Diskette
The diskette (also known as a minifloppy, floppy diskette, minidiskette, etc.) is
similar to the standard flexible disk. You should ensure that you buy diskettes for
SOFT SECTORED FORMAT. Your Commodore dealer can supply your needs.
Table I. SUGGESTED READING LIST
Pet/CBM Personal Computer Guide. C.S. Donahue and J.K. Enger,
Osborne/McGraw-Hill. 630 Bancroft Way, Berkeley, CA 94710
Hands-On Basic With A Pet. H.D. Peckman, McGraw-Hill, 1979
Entering BASIC. J. Sack and J. Meadows, Science Research Associates,
1973
BASIC: A Computer Programming Language. C. Pegels, Holden-Day,
Inc., 1973
BASIC Programming. J. Kemeny and T. Kurtz, Peoples Computer Co.,
1010 Doyle (PO Box 3100), Menlo Park, CA 94025, 1967
A Guided Tour of Computer Programming In BASIC. T. Dwyer,
Houghton Miflin Co., 1973
Programming Time Shared Computer In BASIC. Eugene H. Barnett,
Wiley-Interscience, L C 72-175789
4
Table 1. Suggested Reading List (Continued)
Programming Language #2. Digital Equipment Corp., Maynard MA
01754
101 BASIC Computer Games. Software Distribution Center, Digital
Equipment Corp., Maynard, MA 01754
What To Do After You Hit Return. Peoples Computer Co., 1010 Doyle
(PO Box 3100), Menlo Park, CA 94025
Basic BASIC. James S. Coan. Hayden Book Co., Rochelle, Park NJ Workbooks 1-5 T.I.S., PO Box 921, Los Alamos, NM 87544
Programming The 6502. R. Zaks, Sybex, 1978
24 Tested, Ready-To-Run Game Programs In BASIC. K. Tracton, Tab
Books, 1978
Some Basic Programs. M. Borchers and R. Poole. Osborne & Assoc.
Inc., 1978
The Channel Data Book. B. Lewis, 5950 Mandarin Ave., Goleta, CA
93017, 1978
PET And The IEEE 488 Bus(GPIP). Osborne/McGraw-Hill, 630 Ban-
croft Way, Berkeley CA 94710
Specifications
Table 2 contains the specifications for the 2031.
CARE OF THE 2031
The disk drive should be placed on a flat surface free of vibration. It is important that dust particles be kept at a minimum since a particle buildup will interfere with optimum operation. If you should experience a hardware failure, contact your Commodore dealer. Any attempt to correct the problem yourself could result in voiding the warranty.
5
Table 2. SPECIFICATIONS: MODEL 2031 SINGLE DRIVE FLOPPY DISK
STORAGE
Total capacity 174848 bytes Sequential 168656 bytes Relative 167132 bytes; 65536 records per file Directory entries 144 Sectors per track 17 to 21 Bytes per sector 254 Tracks 35 Blocks 683
IC's:
Controller and Interface 6502 microprocessor 6522 I/O, interval timers 6522 I/O, interval timers 2114 (4) 4x1K RAM
PHYSICAL
Material 18 ga. steel Dimensions Height 6.5" Width 15.0" Depth 14.35"
ELECTRICAL
Power requirements USA (domestic) Voltage 120 VAC Frequency 60 Hertz Power 50 Watts Power requirements (international) Voltage 100, 220, or 240 VAC Frequency 50 Hertz Power 50 Watts
MEDIA:
Diskettes Standard mini 5 1/4", single sided,
single density
6
CARE OF THE DISKETTES
Handle diskettes with care. Follow these instructions to maintain the quality of the diskette and to protect the integrity of the data:
1. Return the diskette to its storage envelope whenever it is removed from the drive.
2. Keep the diskettes away from magnetic fields. Exposure to a magnetic field can distort the data.
3. Never leave a diskette on top of your computer or disk drive.
4. Do not write on the plastic jacket with a lead pencil or ball-point pen. Use a felt tip pen or fill out the label before attaching it to the jacket.
5. Do not expose diskettes to heat or sunlight.
6. Do not touch or attempt to clean the diskette surface. Abrasions will cause loss of stored data.
7. Before applying power to the 2031, insure that there is no diskette in the drive.
UNPACKING THE DISK DRIVE
Before unpacking the disk drive, inspect the shipping carton for signs of external damage. If the carton is damaged, be especially careful when inspecting its contents. Carefully remove all packing material and the contents of the carton. DO NOT discard any packing material until you have made sure you have located all the contents of the carton! The carton should contain:
1. Commodore Single Floppy Disk Drive
2. User Manual, Number 2031036
3. A 2031 TEST/DEMO diskette
If any items are missing, please contact your Commodore dealer immediately.
7
Figure 1. Model 2031 Rear View
8
CHAPTER
PREPARING TO
USE YOUR
DISK DRIVE
Before starting to use your disk drive, make sure it is in good working condition. This includes properly connecting it to your computer, giving it a power-on and initial checkout test, and finally the performance test using the appropriate TEST/DEMO diskette.
2
CONNECTING THE DISK DRIVE TO THE COMPUTER
One of two connector cables are required to interface the floppy to the compu­ter. These cables can be supplied by your Commodore dealer.
1. PET-to-IEEE cable P.N 320101 Use this cable if the disk drive is to be the only (or first) IEEE device connected to your computer.
2. IEEE-to-IEEE cable, P/N 905080 Use this cable if your disk drive is to be connected ("daisy chained") to another peripheral device such as the Commodore Model 2022, or any other suitable interfaced printer.
9
Follow these steps to connect the disk drive to you computer:
STEP 1. Turn power OFF to the computer.
STEP 2. Place the disk in a convenient location as close as possible to
the computer. DO NOT connect the disk drive to a power outlet at this time (see Figure 2).
STEP 3. Connect the PET-to-IEEE cable between the IEEE-488 interface
connector on the computer and the connector on the disk drive. If additional IEEE devices are to be connected, the IEEE-to-IEEE cable(s) must be used.
STEP 4. Connect the disk drive power cable to an AC outlet. DO NOT turn
on power at this time.
Figure 2. Floppy Disk Hookup
PERFORMING THE POWER-ON TEST
You are now ready to proceed with the power-on part of the checkout:
STEP 1. Open the disk drive door. Ensure that there is no diskette in the
drive.
STEP 2. Turn power ON to the COMPUTER and verify that it is working
properly.
10
STEP 3. Apply power to the disk drive. The LED flashes to indicate a faulty
condition. The number of flashes determine which component is faulty. The following lists the components and their respective number of flashes.
Flash Code Component
1 zero page, U3B, U3D 2 ROM U5F 3 ROM U5H 4 RAM U3B, U3C, U3D, U3E
NOTE
If the problem persists, try disconnecting the other devices attached to the IEEE bus. This should assure that a problem related to another device does not affect the disk drive.
Figure 3. Position for Diskette Insertion
11
INSERTING THE DISKETTE INTO THE 2031
Caution
NEVER APPLY POWER TO THE DISK DRIVE IF A DISKETTE IS PRESENT (LOCKED AND SEATED).
STEP 1. Ensure that the power to the disk drive is OFF and DO NOT apply
power until you complete this step. Open the disk drive door and ensure that no diskette is present in the drive.
STEP 2. If the preceding conditions have been met, you may apply power to
the disk drive.
STEP 3. Insert the diskette into the slot with the write protect tab oriented
to the left (see Figure 3) and push it completely in.
STEP 4. Once the diskette is in the slot, GENTLY close the door partially to
center the diskette. Repeat this centering action several times and then close the door firmly. The diskette is now seated and locked in the drive, ready for processing by the computer.
STEP 5. To remove the diskette, insert your index finger under the lip of the
door and gently PULL. This will release the door and permit access to the diskette. The diskette is now free to be removed from the drive.
THE 2031 PERFORMANCE TEST
When you have successfully completed the Power-On test, proceed with the Performance Test. Don't worry if you don't fully understand exactly what is happening in this test. At this point, enter the commands just to get a feel for what you can do with your disk. If UNEXPECTED result are obtained during any step of the test, stop and start over again. The most likely cause of a problem is an improperly entered command. This is to be expected until you become familiar with your disk nit.
All commands are entered via t5he keyboard and must be followed by a carriage return: press the RETURN key on your keyboard.
NOTE
Commands must be entered exactly as shown. DO NOT insert any spaces unless shown in the example. If the error indicator lights, you may be able to continue the example anyway. Re-enter your last command. If the light goes out, your correction was successful and you may continue.
12
NOTE FOR BUSINESS KEYBOARD USERS ONLY: You can set your com­puter for upper case character entry. Do this by typing:
POKE 59468,12 and pressing the RETURN key.
Although it is not absolutely necessary to give this command, it does permit easy entry. In addition, the examples in this manual can be duplicated exactly when you sue only upper case. If this step is omitted the display will be in lower case letters. DO NOT use the shift key when entering commands.
STEP 1. Insert the DEMO diskette into the drive as previously instructed.
STEP 2. Type: LOAD"*",8 and press RETURN. The computer will load the
first file from the diskette in drive 0 and display the following:
READY. LOAD"*",8 SEARCHING FOR * LOADING
READY.
STEP 3. Type: RUN and press RETURN. This will cause the DOS Support
Program to be executed. (This program is not necessary for the disk unit to operate; it just simplifies the direct mode commands.) A brief introductory description of DOS Support is presented in Chapter 3 as it applies to Chapter 3 operations. A detailed description of DOS Support is presented in Chapter 7.
STEP 4. Type: /PERFORMANCE TEST
The screen will display:
SEARCHING FOR PERFORMANCE TEST LOADING READY.
STEP 5: Type: RUN and press RETURN.
The program instructs you to place a blank diskette into the drive. The Performance Test Program executes a shortened version of the test used by Commodore in final inspection of the 2031. The purpose of this test is to ensure that the unit is functioning correctly and will take approximately seven minutes to complete.
NOTE
Do not use diskettes containing any valuable infor­mation since the Performance Test Program will re-format them and any data will be lost. The test program will label this diskette "Test Disk." This diskette is ready for further use when the test pro­gram is completed and the performance test has been satisfied.
13
The computer will first format the diskette. This procedure takes up to three minutes. At the end of the operation the screen displays:
NEW-0 COMMAND OK 0 00.0
THE DRIVE PASSES THE MECHANICAL TEST
The computer conducts the remainder of the Performance Test and displays:
OPEN WRITE FILE ON 0 OK 0 00.00 WRITING DATA TO 0 OK 0 00.00 CLOSE WRITE DATA TO 0 OK 0 00.00 OPEN READ FILE ON 0 OK 0 00.00 READING DATA FROM 0 OK 0 00.00 SCRATCH FILE ON 0 FILES SCRATCHED 1 01.00 WRITE TRACK XX ON 0 OK 0 00.00 WRITE TRACK 1 ON 0 OK 0 00.00 READ TRACK XX ON 0 OK 0 00.00 READ TRACK 1 ON 0 OK 0 00.00
UNIT HAS PASSED PERFORMANCE TEST!
REMOVE DISKETTE FROM THE DRIVE BEFORE TURNING POWER OFF.
READY.
STEP 6. Remove the diskettes and return them to their protective jackets. The
floppy has passed the Performance Test.
STEP 7. If any problems have been encountered during this phase of the test,
return to step 1 and repeat the entire procedure. If problems persist and you do not reach a satisfactory conclusion to the Performance Test, contact your Commodore dealer.
14
Chapter
3
LEARNING HOW
TO USE YOUR FLOPPY DISK
DRIVE
Your CBM Floppy Disk Drive, which enhances your computing power with added storage and file handling capability, is controlled directly with:
* BASIC commands entered via the keyboard * BASIC statements within programs * Special disk commands
In this chapter you will learn how to apply those commands and statements. This chapter is organized in such a way that the functions and format of disk commands are described in a manner which permits the user to perform disk­related tasks. For BASIC 4.0 users, those BASIC commands which correspond to each disk maintenance command are also discussed.
Before using your floppy disk make sure you know how to:
15
As changes occur to the BAM in DOS memory, the BAM on disk will be updated to reflect these changes. Updates to the BAM occur when a program is SAVEd or a CLOSE or DCLOSE is performed on a new RELative or SEQuen­tial data file.
1. Operate you Commodore Computer
2. Do elementary programming in BASIC
3. Open and close files.
NOTE
The BASIC statements described in this chapter apply specifically to the 2031. Certain commands and statements may follow a slightly different for­mat or produce different results from those des­cribed herein when they are used with the computer or with other peripherals. Consult the appropriate manual for the exact use of these commands and statements in other applications.
This chapter will first acquaint the user with those fundamental disk commands that perform disk maintenance and file manipulation and will then progressively advance toward an understanding of those BASIC commands used for data handling. Approached in this manner, the user will then have developed the necessary confidence and programming skills to proceed to advanced disk pro­gramming techniques. Practice the disk commands, read the examples, and follow the step-by-step illustrations of their usage. The understanding of the more advanced disk programming techniques will depend to a large degree upon how well the fundamentals have been mastered.
To facilitate your understanding and mastery of Commodore BASIC, two com­puter terms are stressed in this Chapter: Block Availability Map (BAM) and Disk Operating System (DOS). Although these are conventional terms, they will be briefly discussed as they relate to the Commodore Floppy Disk Drive.
THE BLOCK AVAILABILITY MAP (BAM)
The BAM is a disk memory representation of available and allocated space on a disk. When the system stores information on a disk, the BAM will be automati­cally referenced by the DOS to determine what space is available and how many blocks can be allocated. If sufficient space is available to store a given file, it will be stored on the disk and the BAM updated to account for the space allocated. However, if the DOS detects that a file will occupy more space than available, an error message will be generated.
Formatting a disk creates the BAM which is then loaded into DOS memory upon initialization. The BAM which is then loaded into DOS memory upon initialization. The BAM is stored on diskette on track 18, sector 0, and 128 bytes in length.
16
As changes occur to the BAM in DOS memory, the BAM on disk will be updated to reflect these changes. Updated to the BAM occur when a program is SAVEd or a CLOSE or DCLOSE is performed on a new RELative or SEQuen­tial data file.
THE DISK OPERATING SYSTEM (DOS)
The DOS is responsible for managing information exchange between disk con­troller and the computer.
The DOS performs many functions which are transparent to the user but which are vital to the operation of the system. For example, the DOS monitors the input/output (I/O) of the disk so that channels are properly assigned and that no lengthy waits for an open channel occur. In addition to monitoring of disk I/O, the DOS also uses the channel structure to search the directory and to delete and copy files.
There is another function of DOS called DOS Support which was used during hardware checkout in Chapter 2. Review the Performance Test procedure and observe the special symbols of DOS Support which were used to duplicate and initialize the disks before these procedures were fully explained to the user. Because of its ease of use, DOS Support symbols were easier to implement at that point than attempting to explain the programming procedures they replace. It is now appropriate to briefly discuss how DOS Support can enhance and simplify you knowledge of operating your Commodore computer.
The first file on the TEST DEMO diskette that comes with your disk drive is the DOS SUPPORT PROGRAM. This program, when loaded into computer memory, permits the user to enter abbreviations from many disk commands.
For example, disk commands which would normally be transmitted to the disk using the PRINT#1fn,”commandstring” format may be transmitted via DOS SUPPORT by preceding the command with > or @. Typing slash (/) followed by a program name and RETURN will cause DOS SUPPORT to load that program into memory. Replacing certain disk commands with DOS Support special symbols can simplify learning about your Commodore computer by providing a faster method to communicate with the disk.
Chapter 7 contains detailed instructions concerning the use of these special symbols and their limitations.
17
DISK MAINTENANCE COMMANDS
The following disk commands permit the user to perform file manipulation and disk maintenance.
BASIC 4.0 DIRECT
COMMAND FUNCTION COMMAND
NEW Formats a disk HEADER
INITIALIZE Prepare diskette for use ----
Diskette Level LOAD"$0" Read disk directory DIRECTORY
VALIDATE Reconstruct Block Avail- COLLECT
ability Map (BAM)
COPY Copies files (optional COPY
concatenation) CONCAT File Level RENAME Renames a file RENAME
SCRATCH Erases a file SCRATCH
NOTE
Diskette commands can be transmitted to the disk by PRINT# commands or through the abbreviated commands of DOS support. The examples in this chapter assume that a file has been opened with the OPEN 15,8,15 command. If the error message ?FILE OPEN ERROR appears upon typing the OPEN command, it means that the logical file was opened but had not been properly closed. This error condition will automatically close the file; to re­cover, retype the OPEN command.
NEW
Each time a diskette is placed in the drive, both the diskette and the drive must be prepared for use. A previously unused diskette must first be formatted in the soft-sector format recognized by your particular disk drive. This may be accomplished by use of the NEW disk command.
18
Before using the NEW command to format the diskette and initialize the disk drive, enter the command:
PRINT#15,"commandstring"
where 15 is the logical file number of a file which has been opened to the disk command channel (primary address 8, secondary address 15).
The format for NEW is:
"NEWdr:fn,xx"
or
"Ndr:fn,xx"
Where: dr = the drive number, 0
fn = the file name you wish to assign to the disk. It may be up to 16 characters long.
xx = a unique two-character, alphanumeric identifier supplied by the user.
The NEW command (with ID specified) is used on an unformatted diskette or one which the user wishes to reformat. NEW creates the block headers, writing the sync characters, disk ID, and track and sector numbers at the beginning of each block. The directory header and the BAM are created and the diskette is made ready to accept data. The command may be used on an already formatted diskette (with no ID specified) to clear the disk directory and reinitialize the BAM, deallocating all blocks on the diskette. The time involved in reformatting without an ID is much less than formatting with an ID.
Example 1: OPEN15,8,15
PRINT#15;"N0:TEST DISK,88"
These commands will open the command and error channel to the disk drive and format a disk, giving it a disk identifier of 88.
Here's an example of reformatting a diskette using the NEW command and no disk ID.
Example 2: OPEN1,8,15
PRINT#1,"N0:NEWNAME"
The diskette will be assigned the name "NEWNAME" and the directory and BAM will be cleared. This procedure will work only if the diskette has been formatted.
The NEW disk command SHOULD NOT be confused with the NEW command in BASIC. The latter will delete the program currently in memory and clear all variables before entering a new program.
19
HEADER (BASIC 4.0 DIRECT COMMAND)
The HEADER command has the same effect as NEW command but is reserved for those computers using BASIC 4.0. Since formatting destroys all data pre­viously stored, the HEADER commands has a built-in safety feature that que­ries the user: ARE YOU SURE? A positive response to this question permits formating to take place while a negative response aborts the operation.
The format for the HEADER COMMAND IS:
HEADER"fn",Ddr,Ixx,Udn
Where: fn = file name supplied by user but limited to 16 characters.
dr = drive number, 0
xx = a unique two character alphanumeric identifier (ID) supplied by user.
(same parameters as used by NEW command)
dn = device number (Defaults to 8)
Initializing the 2031
The 2031 uses a hardware feature to detect the removal or insertion of a diskette, so it is not necessary to initialize since this is an automatic function.
THE DIRECTORY
Confirm that the newly formatted disk has the correct ID and disk name by using one of the following methods to list the directory. The directory display includes the following information:
* Disk Name * Disk ID * DOS version number * File Name * File type * Number of blocks used * Number of available (free) blocks
There are two methods available to all users for listing the directory. The first method illustrates the listing procedure using LOAD and the second, the listing procedure in BASIC 4.0 using the DIRECTORY command.
20
LOAD$
This procedure will destroy any program currently in computer memory when the directory is LOADed. (Refer to the description of the >$ DOS Support command in Chapter 7 which is a non-destructive directory display procedure.)
STEP 1: Place a formatted disk in the drive. STEP 2: Type: LOAD"$0",8 (or LOAD"$",8) then press RETURN.
The screen displays: LOAD"$0",8 SEARCHING FOR $0 LOADING READY
STEP 3: Type: LIST
The drive directory will be displayed.
DIRECTORY (BASIC 4.0 DIRECT COMMAND)
This command will display the directory without disturbing the content of the memory. You may type: DIRECTORY D0 using the full word spelling but the preferred short format is illustrated which uses the first two unshifted characters followed by a shifted R.
To display the directory, type: diRd0 ON Udn and press RETURN.
If using upper case display, type: DI-D0 ON Udn and press RETURN.
The - in this example represents the upper case display for a shifted R. See your BASIC 4.0 reference manual for a complete description of this BASIC command.
Printing The Directory
Quite often, it becomes convenient to affix a diskette directory listing directly on the protective jacket. This permits the user to scan the printed directory listing without having to insert the diskette into the drive to obtain this information. Should you desire to print the directory, place the diskette in the drive and enter the following commands:
LOAD"$0",8 Loads the directory OPEN 4,4:CMD4 Opens device 4 (printer) and changes the primary
output device to 4. LIST Prints the directory. PRINT#4:CLOSE4 Returns output to the screen and closes the file.
21
VALIDATE
The VALIDATE command traces through each block of data contained in all files on the diskette. If this trace is successful, a new BAM is generated in the disk memory and written to the diskette. Any blocks which have been allocated but are not associated with a file name, as in the case of direct access files will be freed for use. This will not affect relative files created using the BASIC 4.0 DOPEN command.
In addition to reconstructing the BAM, VALIDATE deletes files from the direc­tory that were never properly closed. If a READ error is encountered during a VALIDATE, the operation aborts and leaves the diskette in its previous state. If a VALIDATE error does occur, you must re-initialize before proceeding.
The format for VALIDATE is:
PRINT#15,"VALIDATEdr"
Where: dr = drive number 0
NOTE
You may abbreviate VALIDATE to V.
Example: OPEN1,8,15
PRINT#1,"V0" or PRINT#1,"VALIDATE 0"
COLLECT - (BASIC 4.0 Direct Command)
The COLLECT command in BASIC 4.0 performs the same function as VALI­DATE. Either command will accomplish the following:
* Recreate a Block Availability Map according to valid data on disk * Delete files from the directory which were never properly closed OPENed but never CLOSEd)
The format for COLLECT is:
COLLECT Dx ON Udn
Where: x = drive number 0
Example: COLLECT D0 ON Udn
Verifies the drive (drive defaults to 0)
22
COPY
The COPY command allows you to reproduce files on the diskette or to create multiple copies (under different names). This command can also be used to concatenate data files. Up to four files can be concatenated into the destination file. The COPY command may be abbreviated with a C.
COPY disk command can be formatted three ways depending upon application.
To copy a single file: PRINT#1fn,"COPYddr:dfn=sdr:sfn"
or
PRINT#1fn,"Cddr:dfn=sdr:sfn"
NOTE
The source (sdr) and the destination (ddr) drives are the same.
To concatenate and copy PRINT#1fn,"Cddr:dfn=sdr:sfn,sdr:sfn...
Where: ddr = is the destination drive (0).
dfn = is the destination file name. This name must be different than the old file name since both files will reside on the same diskette.
In example 1, a file is reproduced on the diskette. In example 2, two files are concatenated into one file. An error message (FILE EXISTS) will be generated in the disk unit if a file to be copied already exists on the diskette.
Example 1: PRINT#1,"C0:ACCT1=0:ACCT"
A file is reproduced on the diskette.
Example 2: PRINT#1,"C0:JDATA=0:ADATA,0:BDATA"
Two files are concatenated into one file. Note that file names should be short since the maximum length of a disk command string is 58 characters.
23
COPY - (BASIC 4.0 Direct Command)
The COPY direct command in BASIC 4.0 performs the same function as COPY disk command and its format is also dependent upon application.
Use this format to copy a single file:
COPY Dsdr,"sfn" to Dddr,"dfn" ON Udn
Where sdr = the source diskette (0)
ddr = destination diskette (0)
fn = file name
Again, notice that the source (sdr) and the destination (ddr) are the same.
CONCAT (BASIC 4.0 Direct Command)
The CONCAT direct command is BASIC 4.0 permits the user to concatenate files.
The format for CONCAT is:
CONCAT Dsdr,"sfn" TO Dddr,"dfn" ON Udn
The file named dfn on drive ddr will contain the contents of both dfn and sfn after the concatenation. For example:
CONCAT D0,"YOURFILE" TO D0,"MYFILE"
This will result in MYFILE, containing the data from the old MYFILE, and YOURFILE being concatenated. YOURFILE will remain unchanged.
NOTE
The concatenation feature of COPY disk command and CONCAT direct command are valid only for DOS 2.
For further information regarding use of BASIC COPY and CONCAT com­mands, refer to the Commodore BASIC 4.0 Reference Manual.
RENAME
The RENAME command renames an existing file. A file can not already exist with the file name specified in the command or the FILE EXISTS error message will be generated.
24
The format for RENAME is:
PRINT#1fn,"RENAMEdr:nfn=ofn"
Where: dr = the disk drive on which the diskette is located (0).
nfn = the new name of the file.
ofn = the old name of the file.
1fn = a logical file number. You assign this number arbitrarily and it may be any whole number between 1 and 255.
NOTE
The letter R is a legal abbreviation for RENAME.
RENAME - (BASIC 4.0 Direct Command)
The RENAME direct command in BASIC 4.0 performs the same function as RENAME disk command.
The format is:
RENAME Ddr,"ofn" TO "nfn" (Ddr=0) ON Udn
NOTE
Close any open files before using the RENAME command since the disk will not execute this com­mand on any active files.
For further information on the RENAME command, please refer to the Com­modore BASIC 4.0 Reference Manual.
SCRATCH
The SCRATCH command erases unwanted files from the specified diskette and its directory. You can erase one file, several files, or all the files on a diskette.
The format for SCRATCH is:
PRINT#1fn,"Sdr:fn,dr:fn...dr:fn"
Where: dr = is the disk drive to be searched (0).
fn = is the name of the file to be erased.
25
To erase one file, enter the entire name of the file:
Example: PRINT#1,"S0:ACCT"
To erase several files with unrelated names, enter the entire name of each file to be deleted:
Example: PRINT#1,"S0:ACCT,0:CUSTOMER,0:INV"
To erase several files at one time where names have something in common, refer to the rules in APPENDIX B concerning pattern matching.
You may erase all files on a diskette using pattern matching as in the following example:
Example: PRINT#1,"S0:*"
SCRATCH - (BASIC 4.0 Direct Command)
SCRATCH direct command in BASIC 4.0 performs the same function as SCRATCH disk command.
The format is: SCRATCH Ddr,"jn" ON Udn
Where: dr = drive number (0)
fn = filename of file to be scratched dn = device number (Defaults to 8)
Pattern matching rules may be used with this command. As with the HEADER command, there is a built-in safety feature that queries the user: ARE YOU SURE? A positive response permits the file to be SCRATCHed while a negative response aborts the operation.
For a complete description of the SCRATCH direct command, please refer to your BASIC 4.0 reference manual.
26
Loading...
+ 68 hidden pages