64 <p1<POJL
Wolstrup article:Copyaid.Utility for Newdos/80Page ###
<PEJL
Wolstrup article:Copyaid.Utility for Newdos/80Page ###
<jl
Lance Wolstrup
20311 Sherman Way #101
Canoga Park, Ca. 91306
(818) 716-7154





<jc
COPYAID
(a NEWDOS/80 copying utility for TRS-80 model III)


<jb,l2
When it comes to operating systems for the Model III,NEWDOS/80 is, in my opinion, the best. This is not to belittleLDOS, DOSPLUS or TRSDOS, as they all certainly meet or exceedthe standards of what an operating system should be. ButNEWDOS/80 is a shining example of what an operating system CANbe. Not only does it offer some powerful utilities, such asSUPERZAP, LMOFFSET and DISASSEM, but the system itself is fastand offers the user many more options than the other operatingsystems.
This is both good and bad. It is good because you gain a lotof power over your machine. It is bad because power demandsknowledge, and even though the infomation-packed NEWDOS/80manual is excellent, it is not easy reading since the people atApparat went out of their way to document just about everylittle detail. This is great for programmers, but can beoverwhelming and confusing to the average user.
Some time ago, a couple of students in my Advanced Basicclass asked me how they could copy TRSDOS 1.3 files toNEWDOS/80. "There is no CONV or CONVERT command the way there isin LDOS or DOSPLUS", they said. True, no such command exists inNEWDOS/80. However, as explained in the Newdos/80 manual, theconversion ability DOES exist. The trick is to fool the drivewith the TRSDOS diskette (usually drive :1) into thinking thatit is being operated by TRSDOS. This can be accomplished byusing the PDRIVE command to temporarily set up drive :1 to actas a TRSDOS drive.
If you type PDRIVE,0 from DOS ready, you will see a list ofspecifications for 10 drives. Specification number 4 should holdthe following:
TI=AM,TD=E,TC=40,SPT=18,TSR=3,GPL=6,DDSL=17,DDGA=2
If you have a different spec, change it to the above bytyping:
PDRIVE,0,4,TI=AM,TD=E,TC=40,SPT=18,TSR=3,GPL=6,DDSL=17,DDGA=2,A
You can now at will change drive :1 to recognize a TRSDOS 1.3diskette and copy the content to a NEWDOS/80 diskette in drive:0 by typing:
COPY1,0,,CBF,CFWO,SPDN=4
It works--but unfortunately it is not simple, and it was outof this frustrating lack of simplicity that COPYAID wasconceived.
COPYAID started out as a demonstration program to illustrateconversion procedures from TRSDOS 1.3 to NEWDOS/80 and fromNEWDOS/80 to TRSDOS 1.3. It became -- thanks to the suggestionof the students -- a utility program written in BASIC to makethe most common file handling commands easier.
Aside from the conversions back and forth between NEWDOS/80and TRSDOS 3.1, you can FORMAT a diskette in either drive :0 ordrive :1, BACKUP NEWDOS to NEWDOS from :0 to :1 or from :1 to:0, COPY individual NEWDOS files from :0 to :1 or from :1 to :0,DELETE (KILL) individual NEWDOS user files in drive :0 or drive:1, DELETE (KILL) all user files on drive :0 or drive :1 andability to read the directory on either drive :0 or drive :1.
As an afterthought, options for disabling or enabling theDATE-TIME prompt when booting the diskette, disabling orenabling password recognition, copying NEWDOS to DOS PLUS orLDOS and finally copying DOSPLUS or LDOS to NEWDOS were added.
COPYAID is menu driven and you simply press the number orletter associated with the option desired and you will instantlybe placed in that module.
Should you find yourself in a module you decide you don'twant to be in, just press Q to any of the 'drive number:'prompts and you will be returned to the menu.

Let's look at these file handling commands in more detail:
1. Format diskette
Format in either drive :0 or drive :1.
Once the drive number has been entered from the keyboard, youwill no longer be able to escape. If escape is desired, you mustreset the machine, otherwise just follow the prompts.

2. Backup NEWDOS diskette
Backup from drive :0 to :1 or from :1 to :0 is supported.
Destination diskette will automatically be formatted beforebackup.

3. Copy individual files
Copying NEWDOS user files from drive :0 to drive :1 or from:1 to :0 is supported.
The destination diskette is NOT automatically formatted.
The files will be displayed one at a time and you will beprompted if you wish to copy it.

4. Copy TRSDOS to NEWDOS
TRSDOS diskette (source) must be placed in drive :1. Theprogram will display each TRSDOS user file one at a time andprompt you if you wish to copy it. System and invisible fileswill not be displayed nor copied.
Using this feature with the Password protection disabled (seeoption P) allows you to copy most of the protected software fromRadio Shack and other vendors. As long as the diskette hasTRSDOS and is using only password protection, COPYAID will copyit.
However, this is to be used ONLY for backing up your owndiskettes to protect yourself from loss.
This is NOT a license to duplicate copyrighted software fortrading purposes.
Before returning to the menu, drive :1 will be restored tonormal Newdos status.

5. Copy NEWDOS to TRSDOS
TRSDOS diskette (destination) must be placed in drive :1.
The program will display each NEWDOS user file one at a time andprompt you if you wish to copy it. System and invisible fileswill not be displayed nor copied.
Before returning to the menu, drive :1 will then be restoredto normal Newdos status.

6. Delete individual files
This module uses the PURGE function and you may delete userfiles from drive :0 or drive :1.
Each user file from the selected drive will be displayed oneat a time and you will be prompted if you wish to delete it.System and invisible files will not be displayed nor deleted.

7. Delete ALL files
Using this module allows you to delete all the user filesfrom either drive :0 or drive :1. System and invisible fileswill not be deleted.
An intersting programming technique was used to accomplishthis task, and it will be explained in detail below.

8. Disk directory
Display short directory from drive :0 or drive :1.
Only NEWDOS diskettes will be able to display directories. If byaccident try to get a directory of an alien diskette, you willget an error message and then returned to the menu.

9. Exit program
Ends program and returns to BASIC.

D. Date - time on/off
One of the things I dislike the most about TRSDOS and LDOS isthe mandatory entering of the date when cold-booting the system.(DOS PLUS does not require this).
NEWDOS is even worse. It mandatorily requires both the dateand the time before allowing you to get to DOS ready.
Using this module you may at your discretion disable orenable this feature on any system diskette in drive :0.

P. Password protection on/off
You may at your discretion disable or enable passwordprotection for your files on any system diskette in drive :0.

M. Copy Dos+ or Ldos to Newdos
Dos+ or Ldos diskettes cannot be read directly by Newdos.What we must do, is take advantage of the fact that all 3Dos'es can read Model I, 35 track, single density diskettes.
From Dos+ or LDOS, format a 35 track, single densitydiskette. (type 35 when asked the track number and type S whenprompted for density).
When the formatting is completed, use the Dos+ or LDOS COPYcommand to transfer the Dos+ or Ldos files over to the singledensity diskette.
This diskette is now readable by COPYAID and by using the Moption, the files will be copied from the single densitydiskette (placed in drive :1) to a Model III NEWDOS systemdiskette in drive :0.
Drive :1 will then be restored to normal Newdos Model IIIstatus.

N. Copy Newdos to Dos+ or Ldos
Place empty diskette in drive :1. Pressing Y to the warningmessage configures drive :1 to a 35 track, single density drive.Then the diskette in that drive is formatted. Next the Newdosfiles from drive :0 is copied to drive :1. Drive :1 is thenrestored to Newdos Model III status.
The destination diskette is now directly readable by Dos+ orLdos.

Delete ALL files - explained:

All options, except 7 and 9, uses simple DOS calls toaccomplish their tasks. Option 9 just ends the program.
Option 7 (Delete ALL files) does not use a DOS call as none isavailable. The desired result is to have the program delete allthe user files automatically (without prompts), while leavingthe system and invisible files on the diskette.
A solution to this is: first the directory of the desireddrive is displayed on the screen. Then read the filenames byPEEKing the screen, store the file names in an array, and thenfinally KILL what is stored in each segment of the array.

The routine starts in line 1790. Clear the screen and removethe scroll protect. (we will potentially need the entire screenfor the directory).
1800: error trap. If directory cannot be read, return to menu.
1810: prompt for choosing the drive number.
1820: get INKEY$ subroutine in 220
1830: check if Q or q has been pressed, if so return to menu.
1840: make sure drive number is either 0 or 1.
1860: load DI$ with DIR drivenumber then execute DOS call.
Directory erases screen, displays DOS file information on
line 0. Leaves a blank line and then displays directory
on the following lines as needed.
1870: erase DOS information on line 1. Write message on line 1.
1890: erase PR$(0) through PR$(63). Set file counter C to 0.
1900: set up loop to read screen 1 line at a time, starting
with 3rd line. Store entire line in PR$.
(15360 is the first pixel of the screen).
Therefore PR$=PR$+(CHR$(PEEK(15360+Y+(64*X))) will store
the character found on line 3, column 1 (15428) in PR$,
then, with NEXT Y, go on and add the character in column
2 to PR$, etc., until the entire line (64 characters) is
stored in PR$.
1910: if an entire line (stored in PR$) is found to contain all
blanks-STRING$(64,32)-then we have found the end of the
directory. Exit the loop and branch to line 1960.
1920: set up loop to parse the line in stored PR$. Read PR$ one
character at a time and store that character in P$.
P will keep track of what position the character is in.
When P$ encounters a blank (space) we branch to line 1940
1930: we did not encounter a blank in line 1750, so we add the
non-blank character we found to PR$(C). Then we go back
for more characters until we reach the end of the line.
P=63. (the 64th character). Then we increment the X loop
(line 1950) to read the next line.
1940: we got here because we encountered a blank in line 1920.
if the ASCII value of P$ is 32 (a blank) AND the previous
character looked at is also a blank, then increment P so
we can look at the next character.
If the previous character (P-1) was a non-blank, we have
then found a complete file name and it is stored in
PR$(C). We then increment C and go back to line 1920 to
test the next character.
1950: end of line. Go back to line 1890 and test the next line.
1960: we have now found all the file names in the directory, so
erase 'wait' message on first line, then add drive number
to file name.
1970: if the file name+extension+drive number is shorter than 3
characters, we have a blank file name. Therefore skip it
by branching to line 2020.
1980: erase what might be written at bottom of screen by
printing 120 blanks, starting at location 832.
1990: print message that we are killing 'filename', at location
832.
2010: actually KILL filename. - stored in PR$(X).
2020: increment X and repeat until end of files.
2030: erase screen and go back to line 150.

This routine is not the fastest in the world, especially ifthere are many files on the disk. It does, however, enable theuser to reclaim an empty DOS diskette without having to gothrough all the prompts in option 6 or, even worse, typing KILL'filename' manually dozens of times.


COPYAID was fun to write, and I hope you will find it usefuland timesaving. Anyone having questions, comments orimprovements to the program, please contact me in writing at thefollowing address:
Lance Wolstrup.9666 Owensmouth #C.Chatsworth, Ca. 91311.
I will respond to all correspondence with a stampedself-addressed envelope.
 