< Previous | Contents | Next >
13 : File Transfer | |||
With the wide variety of incompatible computers around today, it is important to have methods of transferring data between machines. The Master 512 is an excellent tool for this task. Data can easily be transferred between BBC and DOS formats, and if necessary, onward to other systems.
A common requirement of 512 users is to be able to move a file created with a PC program to a BBC format disc. Possible reasons for doing this include, transferring PC files to a modem, using BBC-based terminal software, assembly of large machine code programs prepared in a PC-based text editor, and movement of other program data.
To transfer files to the BBC format, you should use the utility supplied called PUTFILE. This will take any PC disc file, and transfer it to a BBC format disc. The syntax is:
PUTFILE <DOS filename> <BBC filename> (/<filing system>)
PUTFILE does, however, have two serious limitations. Firstly, it does not provide you with a 'shell' environment that you can work from within. This means that it is the files you work with, and the source and destination media must be available on current media. Secondly, PUTFILE won't allow operations such as a transfer from Disc B of DOS to Disc 1 of DFS – obviously the same disc – and stop and prompt the user with a 'now insert DFS disc' message. Instead it just tries to write the file to the same disc, and fails with a Disc Fault error, as it is looking for a DFS disc, and finding only a DOS disc.
This means that, unless you are using a hard disc, you must either place PUTFILE in the memory disc (see Chapter Nine) or on the same disc as the file(s) you are going to transfer. With a memory disc installed copy PUTFILE into it as follows:
1) | Place the DOS DISC 1 in drive A | |
2) | Type: MEMDISK | |
3) | Type: COPY A:PUTFILE.CMD M: | |
4) | Place the DOS disc containing the files to be transferred in drive A | |
5) | Place a DFS or ADFS disc in drive B (drive 1) | |
6) | Type: M:PUTFILE A:<filename> :1.$.<filename> /<fsname> | |
7) | Repeat Step 6 for each file to be transferred |
If, for example, you were copying a file called WORK.TXT to the BBC, where it would be stored on the ADFS disc as 'Work' in directory $.Text, you would type at Step six:
M:>PUTFILE A:WORK.TXT :1.$.Text.Work /ADFS
The /ADFS is in fact optional, as the PUTFILE command selects ADFS by default. Alternative filing systems should be specified exactly as they are invoked, eg /NET, /IEEEFS. The TAPE system seems to work insofar as the file is transferred, but the system then hangs and does not return to DOS. For ADFS, the program insists on a full file specification, ie:
d:{<dir>.{<dir>...}.} <filename>
The other filing systems are not trapped, and whatever you type is simply passed to the filing system.
If you are using the DFS filing system, the PUTFILE command must be suffixed with /DISC or /DISK, each time you use it. Remember when transferring files that you must use suitable names. If you transfer FRED.TXT as it is, ADFS will try to save the file as 'TXT' in a directory called FRED. If directory FRED doesn't exist, you will get an error. Similarly with DFS, this will accept full stops in the middle of filenames, for example JOB.DOC would transfer under that exact name, but there you are limited to seven characters in total.
A useful method for transferring a group of files at once is to use the DOS Plus batch command FOR (see Chapter 11). This does have a few limitations, although these are not a problem. To perform a batch file copy, place all the files you wish to transfer on the same disc, in the same directory, and give them all a null suffix, ie rename them without a suffix, for example, if all the relevant files currently have the suffix TXT, type:
REN *.TXT
Working again from our example of the memory disc, if drive M contains only the following files:
PUTFILE.CMD
TEXT1 .
NOTES .
TEXT2 .
SUMMARY.
the latter four needing transfer, and they were all to be transferred to DFS drive 1, type at the prompt:
FOR %A IN (*) DO PUTFILE %A :1.%A /DISK
This single command will transfer all the files. The (*) means 'all the files without a suffix (in this directory)', and the FOR command assigns each file IN that description in turn to the variable %A, and then DOes the task, inserting values for variables. This is why the files need to have BBC-compatible names before you start.
If you have a dual drive, an alternative to using a memory disc would be to keep a special disc just to handle file transfers. You could keep PUTFILE, and maybe a batch file to handle transfers on the disc, and copy all the files to be transferred to it.
If you have a hard disc, then PUTFILE will transfer files perfectly successfully from drive C to the ADFS portion of the hard disc, which is, of course, drive 0. Note that with a hard disc, floppy drives are referred to as 4 and 5 in ADFS, not 0 and 1. DFS discs are still 0 and 1, as DFS does not recognise the hard disc.
It is possible to check afterwards that the files have been correctly copied to DFS/ADFS using the STAR command in DOS. With a disc containing STAR present, type STAR and press RETURN. The '*' prompt can then be used to CAT, EX, TYPE etc. from the BBC. The 512 system reselects ADFS before every operation, so even if you have just copied a file to a DFS disc, you will still have to type *DISC before cataloguing the disc.
This is also an important requirement, for incoming modem data, transferring old BBC files to your new PC packages and so on. The method of transferring BBC files to the 512 format is more or less the reverse of the above. Within DOS, the command is:
GETFILE <BBC filename> <DOS filename> /<BBC filing system>
where <BBC filename> is the full specification of the file on the BBC disc, <DOS filename> is the full specification of the file as saved to the DOS disc, and the <BBC filing system> is as above, optional for ADFS, but explicitly necessary for DISC, TAPE, IEEEFS, ROM, VFS, and so on. Again, if you are not using ADFS, you must specify the filename correctly. With ADFS you will get a GETFILE error message if the full path is not given.
For example, to transfer the file 'jobs' in directory $.Software.Diary, on the ADFS portion of your hard disc, to a file of the same name in the root directory of the DOS portion of your hard disc, the syntax would be:
C>GETFILE :0.$.Software.Diary.jobs C:\JOBS
The FOR...DO loop for transferring multiple files cannot be used for moving files in this direction, as it is DOS which is providing the 'wildcard' facility, and this can only be done by reading an existing DOS directory.
The equivalent procedure to that above for transferring a group of files from a BBC disc to DOS is as follows:
1) | Place the DOS DISC 1 in drive A | |
2) | Type: MEMDISK | |
3) | Type: COPY A:GETFILE.CMD M: | |
4) | Type: COPY A:STAR.CMD M: | |
5) | Place the DOS disc onto which you will copy the files in drive A | |
6) | Place the DFS or ADFS disc containing the files in drive B (drive 1) | |
7) | Type: M:STAR. A '*' prompt will appear | |
8) | If the BBC disc is DFS, type *DISC | |
9) | Type: *CAT :1 and make a note of the filenames to be transferred | |
10) | Type: M:GETFILE :1.$.<filename> A:<filename> /<fsname> | |
11) | Repeat step 10 for each file to be transferred |
If you forget a filename, repeat steps seven to nine.
If you are sure of the filenames to be transferred, omit steps five, seven, eight and nine.
Note that early versions of the GETFILE and PUTFILE utilities did not work properly. The version supplied with DOS Plus 2.1 does work correctly, and if you have a earlier version of DOS Plus, you should seriously consider upgrading to the latest version.
The GETFILE and PUTFILE utilities will work with any length of file. They are not restricted to the amount of memory in the BBC, or even in the Master 512. Note however, that if you have a very long file (say a 60k text file) created by PC software, you may have difficulty loading it in to any BBC software. You should consider this and possibly break up the file with your PC program before transferring it.
The GETFILE and PUTFILE utilities do not alter the files in any way. Naturally, BBC and DOS programs are not the same, and a file created by one system may not be recognised by another. This is fairly obvious when dealing with graphics, numbers and so on, but even with text files there may be some inconsistency. The most common problems are padded lengths and linefeed characters.
The PUTFILE utility always transfers files in exact page sizes. This means that the length of the file copied onto the BBC disc is an exact multiple of 256 bytes, being padded with extra bytes to make up this length. The value of the padding byte is 26 decimal, the DOS 'end of file' character. The effect of this is to add a few bytes of 'garbage' to the end of the file. Wordprocessing packages will generally suffer no ill effect with these bytes in place, but you should, nevertheless, remove the characters after copying. In Wordwise, these will appear as '|' characters at the end of the file, and in VIEW they will be 'soft' spaces.
The other difficulty is linefeed characters. On the PC, the end of each line of text is signified with a carriage return byte (ASCII 13) and a linefeed byte (ASCII 10). On the BBC most packages only require the first byte, although no harm is usually done by having the linefeed there as well. However, if you do have problems, both padding characters and linefeeds can easily be removed.
If you have a Master, and the file to be cleaned up is less than about 25k in length, then the system editor – EDIT – offers the quickest method of removing the offending bytes. If the text file just transferred was called JOHN, then follow these steps:
1) | Switch off the 512 co-processor by running NOTUBE on DISC 1 | |
2) | Press CTRL-BREAK | |
3) | Place the disc containing JOHN in drive 0 and select the correct filing system | |
4) | Type: *EDIT JOHN (if this gives Bad Command, is the ROM unplugged?) | |
5) | Press f5 (Global search/replace) | |
6) | At the f5 prompt type |J/ | |
7) | Press RETURN | |
8) | Press f5 again, and at the prompt: |Z/ | |
9) | Press f3 then COPY then RETURN. The amended file is saved. | |
10) | Press f1 and type: BASIC then RETURN |
Step six replaces CTRL-J (ASCII 10) with nothing, and step eight replaces CTRL-Z (ASCII 26) with nothing. You can, if you wish, actually type CTRL-J and CTRL-Z as key sequences, in which case they will appear on the prompt line as J and Z in inverse video. If you haven't got EDIT, or the file is too big, the following program will create a file with the offending bits removed. Note that the program does not check that the source file actually exists, or that the right filing system etc is selected.
10 REM Remove LFs and EOFs
20 REM Master 512: A Dabhand Guide
30 REM by Chris Snee
40 REM (c) Chris Snee 1989
50 :
60 INPUT "Existing text file name : " I$
70 INPUT "New text file name : " O$
80 I%=OPENIN I$
90 O%=OPENOUT O$
100 REPEAT
110 C%=BGET#I%
120 IF C%=10 OR C%=26 ELSE BPUT#O%,C%
130 UNTIL EOF #I%
140 CLOSE #O%
150 CLOSE #I%
160 PRINT O$;" created without EOFs and LFs"
170 END
The technique described above should not be used for non-text files, because, in these, the 10 and 26 characters may have some significance. If you are handling PC application formatted data on the BBC side, you probably already know what you are doing, but it is worthwhile saying that the padding characters can easily be removed by checking the length of the file on the PC side, and altering the length of the BBC file accordingly, with this program which only works on DFS systems.
10 INPUT "Name of file just transferred : " I$
20 INPUT "Length on PC side (as shown by DIR) : " L%
30 I%=OPENUP I$
40 EXT#I%=L%
50 CLOSE #I%
It is possible to make sense of non-text data transferred between the BBC and DOS environments. This is covered below.
On the DOS Plus 2.1 disc, there is a new command MOVE, which provides a much more flexible method of transferring files between DOS and the BBC filing systems. The MOVE command is fully documented in the Master 512 Technical Guide, also published by Dabs Press.
There are other ways of moving files between the BBC and DOS. One utility called DOSCOPY by Baksoft (all addresses at end of chapter) runs on the BBC, and moves files in both directions, performing the linefeed addition and removal, all in the same disc drive. DOSCOPY does not require a Master 512 to operate, but is of limited appeal to Master 512 owners. It does, however, support a wide range of other disc formats such as CP/M, Atari ST, Nimbus etc.
BEEBDOS, from BOSS Software, is a PC-based program, which performs the operations from a PC. The disc reading facilities are not of great interest, but the conversion utilities are. Not only will it handle incoming text files, inserting the linefeeds as it goes, but also the program will handle graphics, converting a BBC screen to IBM format, so that it may be read, for example, by IBM display programs. Even more useful, you can design your own filters with BEEBDOS, and perform just about any conversion you like.
Another item of interest to those moving data between the PC and BBC is the PC version of BBC BASIC, published by M-Tec Computer Services. This will run virtually all BBC BASIC programs on the 512, using the extra speed and memory available. An in-line 8086 assembler is also provided. Existing programs written on the BBC can be transferred, as they are, with GETFILE, and a supplied utility will make the slight token changes required.
Another area of compatibility is available for users of View Professional on the BBC. This package has a more powerful PC cousin – PipeDream from Colton Software, which has a totally compatible file format, and can therefore accept View Professional files transferred via GETFILE.
The Master 512 can read some CP/M formats, and equipped with a 3.5" disc drive, can read discs from an Atari ST, which conform to the 720k (IBM 512x9) format. The Archimedes PC Emulator also reads the 720k format, and so, again subject to having a 3.5" drive, you can read discs for this system. The 512 can read a host of PC formats, as shown on the list in the FORMAT option of the DISK program. Not shown, but readable, are the single sided versions of the the 320k and 360k formats. This means that you could use your 512 as a disc conversion machine, providing a bridge between two incompatible machines.
The only PC formats that cannot be handled by the 512 are the special high-density formats used on the IBM AT and other 80286/80386 machines – 1.2Mb for 5.25" drives, and 1.44Mb for 3.5" drives. Even if you fitted the right kind of disc drive, the 1770 controller on the system just cannot handle the way these discs are formatted.
Conversely the 640k and 800k formats supported by the 512 are unique to this system, and cannot easily be read by other PCs. If you intend to swap discs with standard PC owners, stick to the 5.25" 360k (IBM 512x9) and (normally) 3.5" 720k (IBM 512x9) formats, which are common to all PCs.
All Master 512 formats are technically capable of being read by the BBC in native mode. The 640k mode is sector-compatible with ADFS, and can be read with an ADFS disc sector editor, or by using the standard OSWORD calls to read and write ADFS sectors. To read the other modes, you need special software such as the Advanced Disc Investigator by PRES, which can read any format which the 1770 can support. (It is possible to read the 800k format using ADFS OSWORD &72 but not straightforward) If you wish to unravel the directory structure of the DOS disc, you could write your own direct conversion utilities, and with the 640k format, you wouldn't even have to do anything complicated on the disc reading side. This subject is handled in more detail in the Master 512 Technical Guide.
Baksoft, 20 Leys Avenue, Cambridge CB4 2AW.
BOSS Software, 3 Hadleigh Rd Frinton Essex CO13 9HG.
M-Tec Computer Services, 4 Church Hill, Reepham, Norfolk, NR10 4JL.
Colton Software, 149-151 St. Neots Rd, Hardwick, Cambridge, CB3 7QJ.
PRES Ltd, 6 Ava House, Chobham, Surrey, GU24 8LZ.
< Previous | Contents | Next >