{$R- No runtime checks } program UNPACK (tty); { This program converts the concatenated sources of a packed source file into separate files. Each module must start with one line giving the file name and end with one line containing '****'. Such packing is performed by the program PACK. } var inp, outp: text; filnam: packed array [1..22] of char; i, nstar: integer; c: char; eom: boolean; procedure exitst ( x: integer ); extern; { Exit with status } begin write ('Name of packed file: '); break; readln; read (filnam); reset (inp, filnam); if eof(inp) then writeln (filnam, 'not found') else while not eof(inp) do begin read (inp, filnam); readln (inp); rewrite (outp, filnam); writeln (filnam); if ioresult(outp) < 0 then begin writeln ('Error creating ', filnam, ioresult(outp)); exitst (2) end; eom := false; while not eom do begin nstar := 0; for i := 1 to 4 do if inp^ = '*' then begin nstar := nstar + 1; get (inp) end; if nstar = 4 then eom := true else begin for i := 1 to nstar do write (outp, '*'); while not eoln(inp) do begin read (inp, c); write (outp, c) end; writeln (outp); if ioresult(outp) < 0 then begin writeln ('Error writting to ', filnam, ioresult(outp)); exitst (2) end end; { else } readln (inp) end; { not eom } end { while not eof(inp) } end.