\ btof.fth
\ Convert from block files to stream files.
\
\ Block files contain a sequence of records each with 64
\ upper case characters.
\
\ Stream files contain variable-length lines terminated
\ by a newline character, without trailing blanks.  Characters
\ are lower case.
\
\ btof 	\ block-file stream-file  ( -- )
\	Convert block file to stream file
\
\ If your block files contain anything interesting in block 0,
\ comment-out the
\ " pad d# 1024 ifd @ fgets drop " line in btof.

: fcr		( fd -- )
	carret  over fputc  newline swap fputc ;
: 1line-b-f	( -- end? )  \ True when end of input file
	pad d# 64 ifd @ fgets  ( #gotten)      \ Grab a record
	?dup
	if	pad swap  -trailing	( addr len) \ Strip trailing blanks
		2dup lower		( addr len) \ Change to lower case
		ofd @ fputs		( )         \ Write to output file
		ofd @ fcr
		false
	else true
	then ;
: btof  \ in-file-name out-file-name ( -- )
	reading  writing
	pad d# 1024 ifd @ fgets drop		\ omit if block 0 is interesting
	begin 1line-b-f until
	ifd @ close  ofd @ close ;
