文件的折页打印程序

Author: 广 西 刘东明 Date: 1993-04-09

        本程序在AST386SX/16(EGA)、CCDOS2.13H环境下运行通过。附源程序清单:
        program  fold;
        {$u+}
        var  filename:string[12];
        name:text;
        charstr:array[-10..523]ofstring[120];
        fyf,ch:char;pzx:string[10];
        zj,hj:string[2];
        pyk:string[3];
        yk,phs,i,hs,ro,zks,hk:integer;
        zx:'A'..'Z';
        begin
        inline($b0/$10/$b4/$00/$cd/$10);{CGA则应为inline($b4/$00/$b0/$42/$cd/$10)}
        write('':28,'请输入文件名:');readln(filename);assign(name,filename),
        {$i-}
        reset(name);
        {$i+}
        write('':28,'字型:');readln(zx);
        write('':28,'字距:');readln(zj);
        write('':28,'行距:');readln(hj);
        write('':28,'行宽:');readln(hk);
        write('':28,'中间空格数:');readln(zks);
        write('':28,'每页打印多少行:');readln(ro);
        write('':28,'消除分页符(y/n):');readln(fyf);
        hs:=-10;
        {$R+}
        while  not  eof(name)  do
        begin
        read(name,charstr[hs]);
        if(length(charstr[hs])>=2)then
        begin
        if  ord(copy(charstr[hs],1,1))=$8athen  delete(charstr[hs],1,1);
        end;
        readln(name);
        hs:=hs+1;
        end;
        phs:=-10;
        pzx:=chr(96)+zx+chr(38)+hj+chr(94)+zj+chr(96);
        writeln(lst,pzx);
        repeat
        if  upcase(fyf)='N'  then
        begin
        write('':28,'请输入打印页号:');readln(yk);
        end;
        i:=0;
        textmode(80);textcolor(yellow);
        textbackground(red);clrscr;
        gotoxy(30,12);write('Now  printing.....!
        ');
        while(i<ro)do
        begin
        if  phs<hs  then  write(lst,charstr[phs]);
        write(lst,'':(hk-length(charstr[phs])),'':zks);
        if  phs+ro<hs  then
        writeln(lst,charstr[phs+ro])
        else  writeln(lst,'');
        i:=i+1;phs:=phs+1;
        end;
        textbackground(black);clrscr;
        gotoxy(1,1);
        inline($b0/$10/$b4/$00/$cd/$10);{同上}
        phs:=phs+ro;
        if  upcase(fyf)='N'  then
        begin
        writeln(lst,'');
        writeln(lst,'');
        str(yk,pyk);write(lst,'':36,'~',pyk,'~');
        str(yk+1,pyk);writeln(lst,'':84,'~',pyk,'~');
        end;
        if  phs<hs  then
        begin
        write('按任意键继续打印...!');read(kbd,ch);
        gotoxy(1,1);
        end;
        delline;
        until  phs>=hs;
        close(name);
        end.