Helpful program

Basic and Machine Language

Moderator: Moderators

Post Reply
JoshuaHorn
Vic 20 Drifter
Posts: 37
Joined: Fri Feb 06, 2009 11:03 am

Helpful program

Post by JoshuaHorn »

I wrote this simple program to simplify the formmating of floppy disks.

1 INPUT "INIT/REINIT DISK";I$
2 IF I$ = "I" THEN OPEN 1,8,15,"I":CLOSE 1
3 IF I$ = "R" THEN OPEN 1,8,15,"N:NEWDISK,ID": CLOSE 1
4 IF I$ = "ABORT" THEN END
GOTO 1
Joshua Horn
--
"Just because YOU think it's old, does not me it's useless to ME!" -- Joshua Horn
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

How about adding a second INPUT statement that lets the user select the name and ID of the disk to be formatted? While you're onto it, it is a simple matter to add an option to validate a disk too. I think it is more often required than just initializing it.
Anders Carlsson

Image Image Image Image Image
rhurst
Omega Star Commander
Posts: 1371
Joined: Thu Jan 31, 2008 2:12 pm
Website: https://robert.hurst-ri.us
Location: Providence, RI
Occupation: Tech & Innovation

Post by rhurst »

Those are good suggestions. Whenever a hard-coded value (a constant) can be substituted with a variable, it can make for a more flexible design and offer added functionality -- at little expense and complexity by the program.
Any technology distinguishable from magic is insufficiently advanced.
https://robert.hurst-ri.us/rob/retrocomputing
User avatar
Pedro Lambrini
Vic 20 Scientist
Posts: 1132
Joined: Mon Dec 01, 2008 11:36 am

Post by Pedro Lambrini »

Nice idea (so are the suggestions!). :)
"...That of the Eastern tribe being like a multitude of colours as if a rainbow had settled upon its brow..." Daniels 1:3
JoshuaHorn
Vic 20 Drifter
Posts: 37
Joined: Fri Feb 06, 2009 11:03 am

Post by JoshuaHorn »

carlsson wrote:How about adding a second INPUT statement that lets the user select the name and ID of the disk to be formatted? While you're onto it, it is a simple matter to add an option to validate a disk too. I think it is more often required than just initializing it.
Could you refresh my memory on what the validate command is? (the actual code)
Joshua Horn
--
"Just because YOU think it's old, does not me it's useless to ME!" -- Joshua Horn
JoshuaHorn
Vic 20 Drifter
Posts: 37
Joined: Fri Feb 06, 2009 11:03 am

Post by JoshuaHorn »

Tell me if I got this right:

10 REM VIC20 DISK FORMATTER VER 2
20 PRINT "VIC-20 5.25 DISKETTE FORMATTER"
30 PRINT "PROGRAMMED BY JEH "
40 PRINT "TYPE H FOR COMMANDS"
50 INPUT "INIT/REINIT/VAL/NAME DISKETTE";I$
60 IF I$ = "H" THEN PRINT "I - FORMAT NON VIC20 DISK R -
REFORMAT DISK V - VALIDATE A - END H - HELP N - SET DISK NAME & ID":GOTO 60
70 IF I$ = "I" THEN OPEN 1,8,15,"I":CLOSE 1
80 IF I$ = "R" THEN OPEN 1,8,15,"N:NEWDISK,ID": CLOSE 1
90 IF I$ = "V" THEN (THIS IS WHERE THE VALIDATE COMMAND GOES)
100 IF I$ = "A" THEN GOTO 150
110 IF I$ = "N" THEN INPUT "DISK NAME";D$
120 INPUT "DISK ID";N$
130 PRINT "NOW FORMATTING DISKETTE....."
140 OPEN 1,8,15,"N:D$,N$": CLOSE 1
150 GOTO 60
Joshua Horn
--
"Just because YOU think it's old, does not me it's useless to ME!" -- Joshua Horn
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

On the disc command channel:

The floppy command I initialises an already formatted disk. Especially the BAM (Block Allocation Map) is read into floppy RAM. The command can be regarded as a "mount" command in Un*x parlance. It does not format non-VIC disks.

N with ID does a full format of the disc. N without ID merely deletes the directory ("quick-format"). Line 80, and 140 should look like this:

Code: Select all

80 OPEN 1,8,15,"N0:"+D$:CLOSE1
140 OPEN 1,8,15,"N0:"+D$+","+N$:CLOSE1
The control flow in the program will always execute lines 110-140, unless "A" was specified. Maybe you should separate the format commands into a sub-routine, so it only gets called when the user explicitly wants it. Entering "H" will put the program into an infinite loop.

The validate command is "V".

Finally I suggest you put the program into code tags. :)

Greetings,

Michael
JoshuaHorn
Vic 20 Drifter
Posts: 37
Joined: Fri Feb 06, 2009 11:03 am

Making changes, & Overwriting BASIC files

Post by JoshuaHorn »

Hey Mike,

Thanks for the suggestions - I'll change those lines in the program.

Also - What's the usage format of the "V" command, where in the code?

:idea:

BTW - One more question,

Every time I try to overwrite an existing program file on a diskette, my drive complains. - How do you overwrite an existing BASIC program?

Otherwise my drive works fine.

Josh
Joshua Horn
--
"Just because YOU think it's old, does not me it's useless to ME!" -- Joshua Horn
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

The V syntax is just as simple as the I syntax:

OPEN 1,8,15,"V"

Traditionally though, all commands are written as N0, I0, V0 where the zero indicates drive #0 on the particular device. All VIC-20 drives are single anyway but the syntax origins from the days of the PET where dual drives were quite common: I0 would initialize drive #0 and I1 would initialize drive #1.

To overwrite an existing program, you need to use the @ command:

SAVE"@0:PROGRAM",8

It will save PROGRAM under a temporary name, then delete the old file and rename the new file to PROGRAM. There is an infamous bug in this command, most frequently occurring when you're short of disk space and it can't fit another file.
Anders Carlsson

Image Image Image Image Image
JoshuaHorn
Vic 20 Drifter
Posts: 37
Joined: Fri Feb 06, 2009 11:03 am

Post by JoshuaHorn »

Thanks,

I'll show everyone the new program source as soon as I finish it. - I'm at the local library at the moment.

(To be honest, the only computer that I [personally] own is my VIC-20!) :wink:

The other computers in our house include my Father's DELL desktop, his Median laptop and my sisters E-machines desktop. None of which I have access to!

My VIC-20 was given to me as a birthday present this year in February along with the 1541 FDD drive and quite a few carts.
JoshuaHorn
Vic 20 Drifter
Posts: 37
Joined: Fri Feb 06, 2009 11:03 am

Post by JoshuaHorn »

Here's the new code:

10 REM VIC20 DISK FORMATTER VER 1
20 PRINT "VIC20 5.25 DISKETTE FORMATTER"
30 PRINT "PROGRAMMED BY JOSHUA E HORN 2009 "
40 INPUT "F - FULL FORMAT / Q - QUICK ERASE / V - vALIDATE / E - EXIT";P$
50 IF P$ = "F" THEN GOTO 90
60 IF P$ = "Q" THEN GOTO 120
70 IF P$ = "V" THEN GOTO 150
80 IF P$ = "E" THEN END
90 INPUT "DISKETTE NAME";N$
100 INPUT "DISKETTE ID";I$
110 PRINT "NOW DOING FULL FORMAT...PLEASE WAIT!"
120 OPEN 1,8,15, "N0:"+N$=","I$:CLOSE1
120 INPUT "DISKETTE NAME";Q$
130 PRINT "NOW DOING QUICK ERASE...PLEASE WAIT!"
140 OPEN 1,8,15,"N0"+Q$:CLOSE1
150 OPEN 1,8,15,"V":GOTO 40
160 GOTO 40
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

I'd report the following issues:

- There are two lines numbered 120,
- The first line 120 gives a syntax error,
- Line 140 is missing a colon,
- Line 150 doesn't close channel 1, and will fail on the second attempt.
- Any input other than F,Q,V,E on the prompt will also do a full format.
- The control flow executes a quick format, even though a full format already has been done. Same applies to the validate command. You should use subroutines instead.

Here goes the corrected program:

Code: Select all

10 REM VIC20 DISK FORMATTER VER 1.01
20 PRINT "VIC20 5.25 DISKETTE FORMATTER"
30 PRINT "PROGRAMMED BY JOSHUA E HORN 2009, BUG-FIXES BY MIKE"
40 INPUT "F - FULL FORMAT / Q - QUICK ERASE / V - VALIDATE / E - EXIT";P$
50 IF P$ = "F" THEN GOSUB 90
60 IF P$ = "Q" THEN GOSUB 125
70 IF P$ = "V" THEN GOSUB 150
80 IF P$ = "E" THEN END
85 GOTO 40
89 :
90 INPUT "DISKETTE NAME";N$
100 INPUT "DISKETTE ID";I$
110 PRINT "NOW DOING FULL FORMAT...PLEASE WAIT!"
120 OPEN 1,8,15, "N0:"+N$+","+I$:CLOSE1:RETURN
124 :
125 INPUT "DISKETTE NAME";Q$
130 PRINT "NOW DOING QUICK ERASE...PLEASE WAIT!"
140 OPEN 1,8,15,"N0:"+Q$:CLOSE1:RETURN
149 :
150 PRINT "VALIDATING DISK...PLEASE WAIT!"
160 OPEN 1,8,15,"V":CLOSE1:RETURN
Greetings,

Michael
JoshuaHorn
Vic 20 Drifter
Posts: 37
Joined: Fri Feb 06, 2009 11:03 am

Post by JoshuaHorn »

Hey Michael,

I noticed the error when I printed out the code and had already left this computer and gone to my VIC-20. When it did not work, I noticed the errors. Thanks for the corrections!

:oops:

:D

Josh
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

How do you transfer programs if you have no access to neither of your family members' PCs, forcing you to go to the library to e.g. read email and surf the Internet? I suppose you jot down the instructions on paper or perhaps has a printer connected to the VIC-20, then retype what's on the paper at least when you enter it in the forum?
Anders Carlsson

Image Image Image Image Image
JoshuaHorn
Vic 20 Drifter
Posts: 37
Joined: Fri Feb 06, 2009 11:03 am

Post by JoshuaHorn »

You are correct - I either write it down from the library or print it from there. - That would be most of the errors, my own typos! :oops:
Post Reply