[comp.os.cpm] WS document to ASCII

THRA004@cms.ulcc.ac.uk (Christopher Currie) (12/18/90)

 
>If you do accidently [sic] create a file in document mode, you can always use
>good ol' pip to strip the high bits off:
 
>    pip ascii.txt:=highbits.doc[z]
 
I always used to use this method. An alternative is to get the PD VDE 2.66
editor from Simtel20. With this, you can load up a file in document mode
and save it back in non-document mode with the high bits stripped. Frankly
after using VDE on CP/M I wouldn't go back to Wordstar 3 unless I absolutely
had to (e.g. for a large file which VDE can't handle).
 
However, the high-bit problem isn't the only one you need to get round to
produce a pure ASCII file from a WS document file.
 
 If you have used print control
codes (e.g ^A, ^S, ^T, ^B etc.) you will need to strip those out too. WS
3.3 will replace most of them by nothing in a  global replacement, but it
won't recognize ^S (underline) in replacement mode. WS 4 (at least the DOS
version) will. With VDE, you could write a macro to do it. Alternatively,
having stripped the high bits with PIP ..[Z], you would need to run the file
through a second filter to get rid of the control codes. The following bit
of MS-BASIC code gives an idea:
 
[Initialization]
ctrl%=""
FOR n= 1 to 9
ctrl%=ctrl%+chr%(n)
next
for n=11 to 12
ctrl%=ctrl%+chr%(n)
next
For n=14 to 25
ctrl%=ctrl%+chr%(n)
next
[leave chr%(10) and (13) in]
....
[processing the file]
(assumes that infile is no. 1, outfile no. 2)
 
while not eof(1)
 line input #1, a%
 for count=1 to len(ctrl%)
  x=instr(a%,mid%(ctrl%,count,1))
  while x >0
   mid%(a%,x,1)="":' [or " " if you're worried about zero bytes]
   x=instr(a%,mid%(ctrl%,count,1))
  wend
 next count
 print #2,a%
wend
 
My syntax may be a bit ropey, but this gives the general idea. Let's
have a C version, please.
 
Christopher