Getting in a mess with your Microdrives? Gavin Monk's menu driven utility - published this week and next - will help sort you out.
Microdrive Mastery
Getting in a mess with your Microdrives? Gavin Monk's menu-driven utility - published this week and next - will help sort you out
Now that Sinclair has dropped the price of Microdrive cartridges from £4.95 to £1.99, both QL and spectrum owners can use them in the way that they were intended - as a cheap and efficient storage medium. QL users should find more software appearing at very reasonable prices soon.
The first sign has come from Hisoft (which is best known for its Z80 machine code programs) with the release of MonQL, a full 68000 disassembler/debugger retailing at only £19.95.
However, as the QL has no cassette port, all the files and programs must be stored on Microdrives. After a few hours use, you will be left with files scattered on several cartridges.
On a more expensive micro, such as an IBM PC, it would take very little time to delete unwanted files, rename files, backup files, etc. But because of the way QL Microdrives have to be accessed from SuperBasic, the process can take some time on the QL. The aim of this program is to provide a menu-driven utility which will help tidy up Microdrive cartridges after a heavy day's use.
How It Works
Because QDOS is a multi-tasking operating system it can control Microdrives while SuperBasic is still running. However, QDOS, as yet, contains no error trapping so when a drive error occurs the user is returned to SuperBasic with one of 21 error messages. Why the QL has only 21 remains a mystery to me. Even the Spectrum with Interface 1 attached has 48!
Using Microdrives on the QL does have other problems. If more than 20 files are on a single cartridge, then the directory will overflow the screen, meaning that files cannot easily be renamed, and cartridges cannot be backed up in one go.
QL Microdrive Master solves these problems and also gives you several other features, such as:
- Setting of the time and date with full error trapping
- Multiple formatting of cartridges with an added safety trap
- Loading of a program from a full directory of a cartridge
- Merging of a program from a full directory
- Saving of a program with error trapping on the file name. If the file already exists, replacing it with the new file
- Multiple deletion of files by selecting from a full directory of the cartridge; all files containing a given string, i.e. all files containing '_bas'., or both i.e. the files 'demo1', 'demo2' and all files containing '_bas'
- Multiple renaming of files. If the new name exists, then option to replace it with the new file
- Multiple printing of files with dated titles selected as in 6
- Backing up of files with the following options: a whole cartridge; selected files; optional or compulsory overwrite of namesakes
All these features include the option to select the drive number from 1 to 8.
Using The Program
Type in the program and save it onto Microdrive cartridge by typing:
SAVE mdv1_Mdv1_Master_bas (ENTER)
Now run the program. First you will be prompted to input the date in the format DDMMYY and then the time in the format HHMMSS. If you have input an invalid date or time, say a date of 290285, then you will be told so and prompted for it again. Once the date and time have been input correctly, the QL's clock will be set and the file 'last_date_dat' will be saved onto mdv1.
The next time it is loaded, this will give defaults for the date and time prompts. For example, if you entered a date of 010185 and a time of 105800, these values would be used as the defaults the next time and ENTER can be pressed to accept them.
Once the date has been set you are presented with the main menu with the following options:
-
Format a cartridge
This allows you to format a cartridge between one and four times. You will first be prompted for the drive number, then the cartridge name, and finally the number of format times. After entering this date you will be asked to press both CTRL and ENTER to format the cartridge or ESC to return to the main menu. -
Load a file
Using this option will remove the Microdrive Master program from the QL and load the required program and then run it. Selection of the required file is via the selection screen. -
Save a file
Save a program that has been developed after Microdrive Master was loaded. Microdrive Master will not be saved with the program and the program should only use line numbers between 1 and 24999. If the file that you specified already exists on the cartridge, then you will be given the option to replace it with a new file or return to the main menu. -
Merge a file
Similar to load option except that Microdrive Master will remain in memory and the requested program will not be run on loading. The program shouldn't contain line numbers greater than 24999. After it has been merged you will be returned to the main menu. -
Delete file(s)
By using the selection screen, any number of files on a cartridge can be deleted in one go. -
Print file(s)
As option 5, except that files will be printed instead of deleted. The printer should be attached to the first serial port. -
Backup a cartridge
Selecting this option leads to another menu with four options on it. The first allows you to backup a whole cartridge in one go, the second asks you to select which files you require to be backed up, the third turns auto overwrite on or off, and the fourth allows you to change the source and destination drive numbers. If file to be backed up already exists on the destination cartridge it will overwrite it, if auto overwrite is on, or ask if you want it overwritten if it is off. -
Rename file(s)
This requires some temporary cartridge space and you will be prompted to enter the drive number for this temporary storage. It can be the same drive that contains the file to be renamed, but for large files a different drive number should be entered. The files to be renamed and selected via the selection screen and you will be prompted for the new file names as they are renamed. If a file with the new name already exists on the drive then the option to replace it will be given.
The Selection Screen
Any number of files can be selected from those displayed on the screen. The files are displayed in thre columns and the selection mode is indicated in the top right hand corner of the window. To select a file or several files, the following procedure should be followed:
- Using the cursor keys, move the flashing question mark to the right of the file name to be selected
- Press the letter key indicated by the mode
- Select further files by repeating the process
- If required, press F2 to select a file group. Files already selected by using 1 and 2 will be included in with this file group.
- Press ENTER
Note: If you are using the load or merge options, only one file can be selected and this will be loaded or merged as soon as it is selected.
How It Works
When the program is first run, the QL will look on mdv1_ for a file named 'last_date_dat'. If this is found, the values contained in it will be used to provide the defaults for the date and time input screen. If it is not found, the defaults will be the same as the date currently set up.
Once the date and time have been input the values are checked to make sure that they are valid and the QL's clock is set. A file containing this date is now added to mdv1_ or updated if it already exists. The heart of the program is the main menu and from this all of the other procedures are called by using the select statement.
Procedures and Functions
-
dir_to_file$(drive_no)
This reads a directory from (drive_no) and stores the cartridge name in cart_name, the cartridge space in cart_space, the file names in file$, and the number of files in no_of_files. -
file_ondrive(drive_no,file_name)
This first calls dir_to_file$ and then looks through files$ to see if file_name is on the drive. If it is, 1 is returned, otherwise 0 is. -
get_drive_no
Prompts the user to enter a drive number between 1 and 8. -
get_file_name
Prompts the user to enter a file name. -
get_drives
Calls get_drive_no twice to get two differnt drive numbers which are returned as from_drive and to_drive. -
display_files
Displays the file names held in file$ in three columns on the screen -
select_files(mode$)
Allows the user to select files from those displayed by display_files. A select statement is used to detect which keys have been pressed. selected$ will be returned containing an index to the selected file names. -
back_up(all)
If all=1 then a whole cartridge will be backed up; otherwise, only the files selected. -
back_up_cart(from_drive,to_drive,overwrite)
Displays the backup options and allows the user to select the required ones and then calls back_up -
merge_error
Certain restrictions exist on the use of merge and if it's used at the wrong time the error message 'Not Implemented' will be displayed by QDOS. This procedure tells you if merge cannot be used. -
llist(file_name$,drive_no)
Prints the file name and date to the printer followed by the file from the drive -
title
Prints the title in the top window. -
menu
Displays the main menu. -
set_up_date
Checks to see if the QL's clock has been set and if it has not calls get_new_date. -
get_new_date
Prompts the user to set up the date. -
check_date and check_time(string)
These two functions check that the date or time in string is a valid one. The format used is set at DDMMYY and HHMMSS. If the date/time is invalid, then 0 will be returned, otherwise a 1. -
rename_file, print_file, load_file, delete_file, save_file
These allow the user to select which file(s) are to be operated on and carries out the operation -
format_cart
Formats a given cartridge a number of times between 1 and 4.
Improvements
Put the files $ array into order, as the QL (unlike the Spectrum) does not sort the Microdrive directories into alphabetical order. The speed of backup can be improved by storing the list of files on the destination cartridge in a different array to files$. This can be checked to see if the file to be backed up already exists on the destination cartridge. Because file_on_drive doesn't have to be called for every different file name, this speeds up the process. Add the following lines:
26042 dim new_files$(51,32)
26044 dir_to_files$ to_drive
26046 for i=1 to no_of_files:new_file$(i)=file$(i)
24048 no_of_files_on_destination(file_name$)
30010 local found,i
30020 found=0
30030 for i=1 to no_of_files_on_destination
30040 if new_file$(i)==file_name$):found=1
30050 next i
30060 return found
30070 end def file_on_destination
Change line 26140 to
26140 if file_on_destination files$(i)