File Import and Export

For relatively small files using the Edit → Paste menu is an easy way to get a file into the emulator. For example, a BASIC program file can be pasted into the emulator and then saved to diskette or other emulated media in the usual way (e.g., SAVE"PROG/BAS").

Conversely BASIC programs can be exported by simply listing them to the printer with LLIST and then copying the output seen in the Printer → Printer... window. Or for very short files a File → Copy of what is on the screen will suffice.

The File → Load... menu entry can load a program file into memory. Most of the TRS-80's have either a DUMP or SAVEM command you could use to subsequently save the program to diskette. However, you'll need to know where the file loads into memory and the execution address if it ia a program file.

For exporting binary data keep the Record -> RAM command in mind. A LOAD PROG/CMD or LOADM can bring a file into memory which can then be extracted from the saved copy of RAM.

Another approach is to use some kind of file transfer program in the emulator that can send or receive files over the RS-232. Since the RS-232 can be hooked to a TCP/IP connection it should be possible to get some kind of utility than can speak xmodem or the kermit protocol or what have you. Or even something of your own devising.

These may not be the most desirable approaches but I mention them as they can be surpisingly handy. Pasting in a basic program from your PC editor and then capturing local edits with LLIST is a fairly decent if somewhat hand-crank development environment. Or sometimes you just need to get something in once to bootstrap a more powerful technique. And some of the tedium can be automated with trs80gp's automatic input facilities.

Model 1,2,3,4,12,16,6000

The built-in utilities floppy has IMPORT2 and EXPORT2 commands to bring files into and out of the emulator. They use the FreHD emulation so trs80gp must be run with the -frehd option for them to work or activated by the Hard Drive → FreHD menu. Otherwise they will say No FreHD attached and exit. Most Model II operating systems will require the hard drive controller to be disabled (-hx) for the utilities to function.

IMPORT2 reads a file from the host computer and writes it to a TRS-80 disk file.

Usage: IMPORT2 [-lnepvr] hostfile [trs80file]

If the trs80file parameter is omitted the last component of the hostfile is used with '.' changed to '/'. If this is not a legal TRS-80 file name you will get an error message.

Options:

-l
Convert the host file name to lower case. This is needed for NEWDOS/80 which insists on uppercasing the command line.
-n
Change all newlines ('\n') in the host file to carriage return ('\r')
-e
Most Models: Use the NEWDOS/80 end of file convention. This is required for DOSes such as DOSPLUS which use the NEWDOS/80 convention but are not detected by IMPORT2.
Model II: Write the file with a logical record length of 1. This is required for JCL files and some other text files.
-p
Model II TRS-DOS only - write a program rather than a data file. This must be speficied when importing executables (i.e., /CMD files).
-v
Model II TRS-DOS only - write input text file as a variable length record file. Lines longer than 255 characters will be split up.
-r
Model II TRS-DOS only - input file is a raw a variable length record file. This is required if the file was originally exported with the -r option.

EXPORT2 reads a file from the TRS-80 and writes it to the host computer.

Usage: EXPORT2 [-lner] trs80file [hostfile]

If the hostfile parameter is omitted the trs80file is used with '/' changed to '.'.

Options:

-l
Convert the host file name to lower case. This is needed for NEWDOS/80 which insists on uppercasing the command line.
-n
Change all carriage returns ('\r') in the TRS-80 file to newlines ('\n')
-e
Use the NEWDOS/80 end of file convention. This is required for DOSes such as DOSPLUS which use the NEWDOS/80 convention but are not detected by EXPORT2.
-r
Model II TRS-DOS only - if the export file has variable length records it will be written in raw variable length record format. This allows guaranteed preservation of variable length record files on export and import. The default translation of them to text files could introduce errors if, for some reason, the file type was not holding a text file.

IMPORT2 and EXPORT2 are my modified versions of Frederic Vecoven's modified version of Timothy Mann's originals. VHDUTL is a modified version of Frederic Vecoven's original. My main change was to add support for the Model II operating systems. Note that although there is a utility floppy image for each DOS and model the executables are all identical. The copies are only required because of their incompatible file systems and floppies. The executables themselves detect the DOS they are run under and use the correct system calls.

Except for the Model II they should work on a real machine with a FreHD hard drive emulator. I have not tested this.

For bulk import and export I recommend either creating a /JCL (batch/script file) containing all the commands or using the -i options to have trs80gp do all the typing. There are also command line and GUI utilities to read and write files for many TRS-80 floppy image formats. I recommend the graphical TRSTools utility or the command line trsread & trswrite utilities. Neither have any support for the Model II which was the primary motivation to add IMPORT2 and EXPORT2 to trs80gp.

Variable Length Record Files

Model II TRS-DOS variable length record files show up with V as the "FILE TYPE" in a DIR. They are an unusual feature of Model II TRS-DOS. Instead of consisting of a set of fixed-size records they are a series of records of length anywhere between 0 and 255 bytes. A Model II program can only read or write them sequentially.

Normally they are exported and imported as text files in the standard TRS-80 format with carriage return (character 13) terminated lines. It appears that these variable length record files are primarily used for program source code with each record holding a single line.

When they are exported in raw format each record is preceeded by a length byte which gives the size of the record including the length byte. A length byte of 1 will have no following data. A length of 44 will be followed by 43 bytes of data. A length of 0 is followed by 255 bytes of data.

Model 16, 6000 Xenix Import and Export

A pretty good way to get files into or out of Xenix is the xtar utility. It works like the usual unix tar command except that it knows how to read and write floppy disk images. xtar can take an entire directory and write out multiple floppy disk images that Xenix's tar will know how to extract. Or it can take the multiple floppy disk images that a Xenix tar can create and extract the files.

There is also the xfile utility. It can read (but not write) Xenix hard drive images. Once trs80gp has been shut down xfile can list or extact files directly from the hard drive image file.

For truly massive file import and export there is a technique where tar archives can be placed into hard drive images. Credit to John Elliott IV for the technique and these instructions on how to do it.

Make a copy of your root filesystem DSK (both the DSK & CFG). Name it something else like scratch.dsk and scratch.cfg. Launch trs80gp, and use the Hard Drive menu to mount the new image on a free drive. On my system, I have HD0 as root and HD1 as /home, so I mount on HD2. On the emulator’s Hard Drive menu, that’s root on :4, home on :5, and ‘scratch’ my extra drive on :6.

Boot XENIX & login. su to root.

To bring files in, on your host system you create a tar file with the items you wish to import. Next, on your host system, you run this command:

	dd if=my-stuff.tar of=/path-to/scratch.DSK obs=512 seek=34

What that does is skip the boot tracks on the HD image and write the tar file to the data portion of the HD image. On your XENIX system, just run tar xvf /dev/hd2. You’ll see the files extracted that you tar’d up on your host system.

To transfer files OUT of the emulator, create a tar file on /tmp or wherever. Next, DD the tar file to /dev/hd2 (in my case, or wherever your ‘scratch’ drive is). So, for example, let’s say I want to get something out of my source directory:

     % su –
     Password:
     # cd /home/iv/src
     # tar cvf /tmp/vim-4.5.tar vim-4.5

     [tar outputs stuff]
     # dd if=/tmp/vim-4.5.tar of=/dev/hd2 obs=512
     iiii blocks in
     oooo blocks out
Now, you may be wondering why not tar directly to HD2? The reason is, to extract on the host system side we need the exact number of 512 blocks, and dd gives that to us, the oooo before blocks out.

Next, on your host system, extract your tar file with dd:

    % dd if=scratch.DSK of=/tmp/vim-4.5.tar ibs=512 skip=34 count=oooo
Voila, you have fast in and out. The only limit is the size of the scratch HD image you’re using. Well, that and the free space wherever you’re going to extract it.