Article 46401 of comp.sys.cbm:
From: pap@dana.ucc.nau.edu (Paul Allen Panks)
Newsgroups: comp.sys.cbm
Subject: Re: PROGRAMS TO TRY: BASIC 2/7
Date: 13 Dec 1995 06:24:28 GMT
Organization: Northern Arizona University, Flagstaff AZ, USA
Lines: 294
Message-ID: <4alris$uh@ruby.ucc.nau.edu>
NNTP-Posting-Host: dana.ucc.nau.edu
X-Newsreader: TIN [version 1.2 PL2]

NOTE: The following thread deals with disk commands and other common 
commands in the BASIC 2.0 and BASIC 7.0 programming languages. It is 
written with the first time user in mind. However, it may also be a could 
refresher lesson for long-time Commodore users as well.

For a refresher course in BASIC COMMANDS, please read further:

DISK COMMANDS [BASIC 2.0]:

Section 1.0 - LOADing a Program from disk

First off, make sure the disk is properly inserted in the disk drive 
BEFORE you attempt any of the following commands. The disk should be 
placed in the drive LABEL UP. If the disk does not have a label, then it 
should be placed as such:           _
                                   | |
|DISK DRIVE |   = = |   |HATCH: ===| |===   OPEN: Counterclockwise 
|   ========U=====  |   |  |       |_|      CLOSE: Clockwise
 \_________________/    |  U       |O|
     ___ ___ ___         \__________-_________/
    |           |
    |     0     |
    |     _     |      /|\ 
    |    |O|    |       |
    |     -     |       |
     ] |LABEL|  | (Insert this way)
    |___________| 

The "O" in the middle is the ring. The oval-shaped, smaller "0" near the 
top of the disk is the other one. Insert the disk until it cannot be 
inserted any further (WARNING: Do NOT force it in, go gently). 

Also, when you insert it, close the latch on the drive completely (turn 
it clockwise until it stops)

To LOAD a program, [ENTER] the following:

LOAD "<PROGRAM NAME>", 8

Where '8' is the device number and <PROGRAM NAME> is any name up to 16 
characters in length (inluding spaces). Note that an invalid Program Name 
might be: $,*,or @, because these commands are reserved for disk access 
(i.e. '$' lists the directory in Track 18, Sector 1,'*' is a wildcard, 
and '@' is the save-with-replace command)

The device number can be either '8' or '9' depending on if you have a 
second external drive or not. In the case of LOADing a Machine Language 
Program (i.e. most Commercial programs), use the following syntax:

LOAD "<PROGRAM NAME>", 8, 1

Where '8' is the device number and <PROGRAM NAME> is any name up to 16 
characters in length (including spaces), and the '1' is a flag that tells 
the computer to LOAD a Machine Language Program into memory and execute 
it (provided the Program is self-LOADing).

Section 1.1 - SAVEing a Program to Disk

Sometimes, the user may want to SAVE a Program he/she has worked on to 
Disk. In that case, the syntax used is:

SAVE "<PROGRAM NAME>", 8

Again, where '8' is the device number and <PROGRAM NAME> is any name up 
to 16 characters in length (including spaces). An optional '1' flag can 
be appended to the command in order to SAVE a Machine Language Program to 
Disk. In that case, the following syntax can be used:

SAVE "<PROGRAM NAME>", 8, 1

Where '8' is the device number and '1' is the flag that tells the 
computer to SAVE a Machine Language Program to Disk.

Now that the basics of LOADing and SAVEing have been covered, let's move 
on to other, more advanced disk commands.

Section 1.2 - ADVANCED Disk Commands

In a nutshell, the following describes three essential disk commands:

1. Getting the DIRECTORY of a disk
2. VALIDATEing a Disk
3. VERIFYing a Program

1. DIRECTORY of a Disk - The easiest way to get a DIRECTORY of a disk is 
to use the following command in direct mode (non-Program mode):

LOAD "$" ,8

Where '8' is the device number and '$' is a flag that tells the disk 
drive to print out on the screen the contents of a disk. After a short 
pause (if there hasn't been an error), the screen will say:

LOAD "$" ,8   

SEARCHING FOR $
LOADING
READY.

After which the user types:

LIST

Pressing RETURN after LIST will generate the following display (contents 
may vary depending upon the disk):

0 |"MY DISK         " RY 2A |
3   "HOW TO USE"         PRG 
8   "SEQ FILE READ"      PRG
10  "BAM TEST"           PRG
4   "AUTO SALES"         SEQ
21  "2.0 BASIC DEMO"     PRG
7   "I AM THE MAN!"      REL
45  "DATABASE STUFF"     USR
2   "DATABASE.LDR"       PRG
0   "LOOPING MAGIC"      PRG*
554 BLOCKS FREE.   

The following example, of course, may or may not be true of every single 
disk and its contents. However, it was done to show you an example of 
what a disk directory looks like, as well as show you 4 different types 
of files that can appear on a disk:

PRG - BASIC or Program Files (usually BASIC files)
SEQ - Sequential Program Files 
REL - Relative Program Files
USR - User Program Files
DEL - Deleted Program Files (EXTREMELY RARE)

(NOTE: The PRG (Program File) listed in the above example with an 
asterisk '*' by it is called a SPLAT file. These files occur 
when the user has improperly SAVEd a program to disk. This happens when 
an attempt is made to SAVE a program, but the size of the program exceeds 
the number of BLOCKS available of disk (i.e. in our example, this would 
not be the case because 554 BLOCKS are Free, however, if a 45 BLOCK 
program is attempted to be SAVEd onto a disk with LESS than 45 BLOCKS 
free, a SPLAT file will occur. WARNING!!!: _NEVER_ attempt to DELETE a 
SPLAT file, as any attempt to do so will disallocate BLOCKS on the disk 
and thus could scramble important data (i.e. all file types in the 
directory as listed above. If a SPLAT file should occur, IMMEDIATELY use 
the DISK VALIDATE command described in the paragraphs proceeding this one).

Space limitations won't allow me to go into each type of file in great 
detail. However, here is a brief description of each:

PRG (Program Files) - These type of files can be LOADed or SAVEd easily. 
Most of these types of files are BASIC programs or, rarely, Word 
Processor files.

SEQ (Sequential Files) - These types of files cannot be LOADed or SAVEd 
normally. Briefly, a Sequential file stores and retrieves DATA to disk. 
Here is a short program that creates a Sequential file:

10 OPEN 2,8,2,"MY FILE,S,W": REM OPEN CHANNEL TWO AND CREATE A SEQ FILE
15 INPUT"WHAT IS YOUR NAME?";N$: REM ASK FOR DATA USING INPUT STATEMENT
20 PRINT #2,N$: REM WRITE DATA TO DISK USING CHANNEL TWO
25 CLOSE 2: REM TIDY UP AFTERWARDS

In the above example, in line 10, 'S' is the abbreviation for 
'SEQUENTIAL' and 'W' is the abbreviate for 'WRITE'. The 'S' tells the 
computer to OPEN a SEQuential File, and the 'W' tells the computer to 
WRITE that file to disk under the name in the quotation marks.
Line 15 asks the user to enter his/her name using the keyboard. Upon 
pressing RETURN, the program jumps to line 20, which does the actual 
WRITEing of the DATA to disk. 'N$' is the variable that stores the NAME 
of the person. The fina line, 30, CLOSEs the file. IMPORTANT: It is 
always necessary to CLOSE a file before opening any others. If not done 
properly, this may disallocate BLOCKS on the disk and thus the VALIDATE 
command described in a following paragraph must be used.

To READ the file back from the disk, use the following program:

10 OPEN 2,8,2,"MY FILE,S,R": REM OPEN CHANNEL TWO TO READ FROM
15 INPUT #2,N$: REM READ BACK THE DATA FROM STRING 'N$'
20 PRINT N$: REM PRINT NAME TO SCREEN
25 CLOSE 2: REM TIDY UP AFTERWARDS

The only thing different in this example is:

1) The 'R' in Line 10 tells the computer that it will be READing our 
SEQuential file from disk into memory.
2) Line 15 READs the DATA from the string 'N$' (used in the previous 
program) using the INPUT statement, and Line 20 PRINTs the DATA (the 
person's name) to the screen. IMPORTANT: Do not get the INPUT command 
used in the previous program before this one confused with the INPUT 
command used in this exmaple. INPUT has two purposes: 1) To get INPUT 
from the keyboard, and 2) To get INPUT (or READ) information from a 
SEQuential File, as we did above).

The above programs can be used in more advanced ways, but because of 
space limitations we cannot get into the matter further.

USR (User Files) - Essentially, these files can store any kind of DATA, 
and are quite advanced for the beginning user. Therefore, we will not 
attempt to explain this command at this time.

REL (Relative Files) - These types of files are more flexible and thusly 
more advanced than the SEQuential file types. Essentially, these files 
can store information in any order the user chooses. These are much 
faster than SEQuential files in that they don't have to be read 
sequentially. That is, from the beginning to the end all the way through. 
SEQuential files are handy for storing information, but lack the speed of 
RELative files. We cannot get into this topic further because these 
commands are difficult to explain as well as implement in a Program.

DEL (Deleted Files) - These file types are extremely rare and will 
rarely, if ever, show up on a directory. If they do, it may be because 
the user failed to close a file properly upon deleting it (this can be 
caused by a disk error).

VALIDATEing a disk

If an error should occur, especially with a SAVE command or a SEQuential 
file (the disk drive will usually blink constantly to tell the user an 
error has occured), the DISK VALIDATE command should be used. This is 
usually the case as described in previous paragraphs about a SPLAT file. 
To review, a SPLAT file is any file that has tried to be SAVEd to disk, 
but the size (i.e. BLOCKS) of the program exceed the number of available 
BLOCKS, or BLOCKS FREE. The following command performs a DISK VALIDATE 
command:

OPEN 15,8,15, "V0":CLOSE 15

Where 'V0' is the flag which tells the computer to perform a DISK 
VALIDATE command. CLOSE 15 tells the computer to CLOSE channel 15 (the 
one used in this example).

This can be ENTERed in either DIRECT MODE or within a BASIC PROGRAM. 
However, DIRECT MODE is more convienent. What this command does is 
re-allocate any and all available BLOCKS so that any BAD BLOCKS (or 
disallocated BLOCKS) are wiped out, thus space is made for the GOOD 
BLOCKS not damaged by the disk error (or SPLAT file).

PROGRAM VERIFY COMMAND

Sometimes a user may want to check and see if a program is either 
existent on disk, or has been SAVEd properly (without error). In that 
case, the following PROGRAM VERIFY command can be used:

VERIFY "<PROGRAM NAME>", 8

Where '8' is the device number and <PROGRAM NAME> is the name of the file 
up to 16 characters in length (including spaces).

Upon pressing RETURN, hopefully the user will see:

VERIFY "<PROGRAM NAME>" ,8

VERIFYING <PROGRAM NAME>
OK
READY.

This means that the program was SAVEd properly to disk. However, if the 
disk drive light starts blinking, the screen probably says:

VERIFY "<PROGRAM NAME>", 8

VERIFYING <PROGRAM NAME>
?VERIFY ERROR
READY.

This means that an error has occured with the SAVEd program. In other 
words, the program would have a LOAD error and would not LOAD properly. 
This, again, is due to an error in the attempt to SAVE the program. In 
this case, the file should be deleted and the disk VALIDATEd.

There are other disk commands, such as RENAMEing a file,SCRATCHing a 
file,etc., but we will not get into them for now. The examples described 
above are the first commands you should know and the most important ones.

In the meantime, have fun with your new disk drive! (or computer, as may 
be the case). Happy Computing! ;)

Regards,

Paul Allen Panks
E-mail: pap@dana.ucc.nau.edu

 --
------------------------------------------------------------------------------
This signature file was brought to you by Paul Panks, not Micro$oft, IBM, 
or any of those other money-sapping, machine-wasting companies bent on world 
domination. Did you here that Micro$oft wants to purchase the Catholic 
Church? I don't think Bill Gates would make a very good choir boy. I think 
its time to put our foots down and stop this maniac before he declares his 
campaign for the Presidency!
*** Check out Jim Brain's WWW Page at: Http://www.msen.com/~brain/ ***
(You'll be glad you did!)
E-mail: pap@dana.ucc.nau.edu

"If you quote me on this, I'll have to deny it. Besides, my memory is 
*terrible*. I forget things often. Also, my memory is *horrible*."
------------------------------------------------------------------------------



