[net.micro.trs-80] TRS-80 Model 100 - how to write NUL to files?

rex@mhuxh.UUCP (GODBY) (03/21/86)

How can I write a string to a RAM file from Model 100 BASIC
if the string contains NUL (ASCII 00) characters?  If I
use PRINT or PRINT USING, BASIC seems to strip the NUL
characters.  I would be very grateful for any suggestions.

Rex Godby      ihnp4!mhuxh!rex         (201) 582-3628

perry@vu-vlsi.UUCP (Rick Perry) (03/23/86)

In article <341@mhuxh.UUCP>, rex@mhuxh.UUCP (GODBY) writes:
> How can I write a string to a RAM file from Model 100 BASIC
> if the string contains NUL (ASCII 00) characters?

   There are three characters that M100 BASIC doesn't like to write to
.DO files: 0 (NUL), 26 (ctrl/z), and 127 (DEL).  The only one that really
is impossible to get there is ctrl/z, since that is used as the end-of-file
marker (if a ctrl/z were to appear in the middle of a .DO file, a certain
cold-start would occur eventually as the M100 uses that to determine .DO
file size when things are deleted or otherwise moved about in the RAM
file system).

   The only way I know of to get a NUL into a file from BASIC is: write
some other character there first, as a place holder.  Then close the file
and get's its start address from the RAM directory map, and POKE the
NUL's in.

   The question arises though, why do you want those NUL's in there in the
first place?  If they are going to be read or used by some other program,
maybe you could use a different character (like 128).  Uploading a file
with 7-bit stat setting should should strip the high bit off of a chr(128)
and end up sending a null.

...Rick                         ..{pyrnj,psuvax1}!vu-vlsi!perry