home *** CD-ROM | disk | FTP | other *** search
-
- #include "stdio.h"
- #include "stdlib.h"
- #include "conio.h"
- int e_line,start_page,tln;
- char filename[22],line[600],lnn;
-
- void error(int code);
- void set_screen();
- void continue_print();
- void single_print();
-
- main()
- { FILE *fs,*ft;
- int ln,s_c=1;
- char es_line[3],s_page[4],s_c1[2];
- set_screen();
- window(1,8,79,20);
- textbackground(BLUE);
- textcolor(CYAN);
- clrscr();
- while(1)
- { gotoxy(20,2);cprintf("Enter Source File:");
- gets(filename);
- if((fs=fopen(filename,"rt"))!=NULL)
- break;
- error(1);
- }
- if((ft=fopen("c:print.doc","wt"))==NULL)
- {error(2);
- exit(1); }
- ln=1;
- while(fgets(line,512,fs)!=NULL)
- {if(fprintf(ft,"%-6d%s",ln++,line)==EOF)
- {error(3);
- fclose(fs);
- exit(1);
- }
- gotoxy(35,4);cprintf("Total lines: %d",ln-1);
- tln=ln-1;
- }
- fclose(fs);fclose(ft);
- gotoxy(20,6);cprintf("Every page lines (default 55):");
- gets(es_line);
- e_line=atoi(es_line);
- if(e_line==0) e_line=55;
- gotoxy(20,7);cprintf("Start page number (default 1):");
- gets(s_page);
- start_page=atoi(s_page);
- if(start_page==0) start_page=1;
- gotoxy(20,8);cprintf("Print line number (y/n) (default yes):");
- ln=getchar();
- if(ln=='')
- ln='y';
- gotoxy(15,9);cprintf("Please print mode (1:continue paper 2:single paper):");
- gets(s_c1);
- s_c=atoi(s_c1);
- if(s_c==0) s_c=1;
- fprintf(stdprn,"%c%c",0x1b,0x40);
- fprintf(stdprn,"%c%c%c",0x1b,0x43,66);
- if(s_c==1)
- continue_print() ;
- else
- single_print();
-
- system("del print.doc");
- }
-
- void set_screen()
- {
- textbackground(BLUE);
- clrscr();
- window(10,2,70,6);
- textbackground(LIGHTGREEN);
- textcolor(YELLOW);
- clrscr();
- gotoxy(23,2); cprintf("Double Side Print");
- gotoxy(18,3);cprintf("===========================");
- gotoxy(5,4);cprintf("Computer Centre of Main Sub-branches at SONG YUAN City");
- window(5,22,75,24);
- textbackground(RED);
- textcolor(YELLOW);
- clrscr();
- }
- void error(int code)
- {
- window(5,22,75,24);
- textbackground(RED);
- textcolor(YELLOW);
- clrscr();
- gotoxy(20,2);
- switch(code)
- {case 1:cprintf("Cannot open source file");
- break;
- case 2:cprintf("Cannot create file");
- break;
- case 3:cprintf("Cannot write to print file");
- break;
- }
- window(1,8,79,20);
- textbackground(BLUE);
- textcolor(CYAN);
-
- }
-
- void continue_print()
- { FILE *ft;
- int i,j,k,page,ln;
- if(lnn=='y'||lnn=='Y')
- ft=fopen("print.doc","rt");
- else
- ft=fopen(filename,"rt");
- page=0;ln=0;
- for(i=1;i<=2;i++)
- {rewind(ft);
- ln=0;
- while(!feof(ft))
- {if((ln/e_line)==page)
- {fprintf(stdprn," │╠╨≥├√: %s │╠╨≥╫▄╨╨╩²: %d \n",filename,tln);
- fprintf(stdprn,"⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ\n");
- for(j=0;j<e_line;j++)
- {if(fgets(line,512,ft)==NULL)
- {for(k=j;k<e_line;k++)
- fprintf(stdprn,"%c%c",0x0d,0x0a);
- break;
- }
- fprintf(stdprn,"%s",line);
- ln++;
- }
- fprintf(stdprn,"\n==========================================╡┌ %d ╥│====================================\n",page+start_page);
- fprintf(stdprn," ╦╔╘¡╜¿╔Φ╥°╨╨╡τ╦π┐╞\n");
- page+=2;
- fprintf(stdprn,"%c",0x0c);
- }
- else
- { for(j=0;j<e_line;j++)
- {if(fgets(line,512,ft)==NULL)
- break;
- ln++;
- }
- }
- } /*end while */
- if(ln<e_line) break;
- page=1;
- if (i==1)
- { gotoxy(12,12);cprintf("Please turn over the paper ,then press any key to continue");
- getch();}
- } /*end for*/
- fclose(ft);
- }
-
-
-
- void single_print()
-
- { FILE *ft;
- int page,j,k;
- if(lnn=='y'||lnn=='Y')
- ft=fopen("print.doc","rt");
- else
- ft=fopen(filename,"rt");
- page=0;
- while(!eof(ft))
- {fprintf(stdprn," │╠╨≥├√: %s │╠╨≥╫▄╨╨╩²: %d \n",filename,tln);
- fprintf(stdprn,"⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ⌐Ñ\n");
- for(j=0;j<e_line;j++)
- {if(fgets(line,512,ft)==NULL)
- {for(k=j;k<e_line;k++)
- fprintf(stdprn,"%c%c",0x0d,0x0a);
- break;
- }
- fprintf(stdprn,"%s",line);
- }
- page++;
- fprintf(stdprn,"==========================================╡┌ %d ╥│====================================================",page+start_page);
- fprintf(stdprn," ╦╔╘¡╜¿╔Φ╥°╨╨╡τ╦π┐╞");
- gotoxy(12,12);cprintf("Please turn over the paper ,then press any key to continue");
- getch();
- }
- fclose(ft);
- }
-