home *** CD-ROM | disk | FTP | other *** search
- {
- Read a packed window file and write it to a text file. The PWF is usually
- written by PSCREEN, version 1.0, from Object Professional. The text file is
- suitable for incorporating in a word processor. PWF2TXT decompresses the PWF
- file and strips out video attributes. It does not remove control characters
- (arrows, smiley faces, and the like), so be careful with these, especially ^Z
- (#26).
-
- Written 12/10/89, Kim Kokkonen, TurboPower Software
- CompuServe 76004,2611
-
- Requires Object Professional to compile.
- }
-
- {$R-,S-,I-,V-}
-
- program Pwf2Txt;
- {-Write packed window to text file}
- uses
- dos,oproot,opstring,opcrt,opframe,opwindow;
- var
- pwfname : pathstr;
- txtname : pathstr;
- txt : text;
- pw : packedwindow;
- vs : virtscreen;
- i : word;
- r : word;
- s : string[80];
- begin
- {validate command line}
- if (paramcount = 0) or (paramcount > 2) then begin
- writeln('PWF2TXT 1.0, by TurboPower Software');
- writeln;
- writeln('Usage: PWF2TXT PwfFile[.PWF] [TxtFile[.TXT]]');
- writeln;
- writeln('If TxtFile is not specified, writes to PwfFile.TXT.');
- halt(1);
- end;
-
- {build filenames}
- pwfname := stupcase(defaultextension(paramstr(1), 'PWF'));
- if paramcount = 1 then
- txtname := forceextension(pwfname, 'TXT')
- else
- txtname := stupcase(defaultextension(paramstr(2), 'TXT'));
-
- {create virtual screen to display packed window in the background}
- if not vs.alloc(50, 80) then begin
- writeln('Error (', InitStatus, ') allocating virtual screen');
- halt(1);
- end;
-
- {read packed screen}
- if not pw.read(pwfname) then begin
- writeln('Error (', InitStatus, ') reading ', pwfname);
- halt(1);
- end;
-
- {create output file}
- assign(txt, txtname);
- rewrite(txt);
- i := ioresult;
- if i <> 0 then begin
- writeln('Error (', i, ') creating ', txtname);
- halt(1);
- end;
-
- {activate virtual screen and display packed window there}
- vs.activate;
- pw.displayat(1, 1);
- vs.deactivate;
-
- {read characters from virtual screen and write to file}
- for r := 1 to pw.pwRows do begin
- vs.readfrom(pw.pwCols, r, 1, s);
- writeln(txt, trimtrail(s));
- i := ioresult;
- if i <> 0 then begin
- writeln('Error (', i, ') writing to ', txtname);
- halt(1);
- end;
- end;
-
- close(txt);
- i := ioresult;
- if i <> 0 then begin
- writeln('Error (', i, ') closing ', txtname);
- halt(1);
- end;
- end.