home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 036 / lj4disp.zip / LJ4DISP.C < prev    next >
C/C++ Source or Header  |  1994-12-04  |  4KB  |  98 lines

  1. /*
  2.    File:         lj4disp.c   
  3.    Description:  Send display message to HP4 Printer.
  4.    Author:       Larry Tanner
  5.    Date Written: 2/21/94
  6.  
  7.    rev 2.0  09/26/94
  8.     revision by:    Jeff Steinmetz of Urge Productions
  9.                     jeffsteinm@aol.com
  10.  
  11.     Added printer error routine.  Now if printer error occurs,
  12.     it will abort the program, instead of asking Abort, Retry, Fail.
  13.     This will allow you to put it in your autoexec.bat file,
  14.     and it will not pause if your printer is turned off.
  15.     Of course it will not program your HPL4 if this is the case,
  16.     but at least your AUTOEXEC.BAT will continue unattended.
  17.  
  18. */
  19.  
  20. #include <stdio.h>               /* standard i/o routines        */
  21. #include <conio.h>               /* clrscr function              */  
  22. #include <dos.h>                 /* error handling */
  23.  
  24. /* prototypes */
  25. void print_display( char *line );
  26. void _far harderr_handler(
  27.             unsigned deverror,
  28.             unsigned errcode,
  29.             unsigned _far *devhdr);
  30.  
  31. /* constaints */
  32. #define maxline 18               /* set max input string length */
  33.  
  34. void main( int argc, char *argv[] )
  35. {
  36.    char line[maxline];           /* line used in message prompt */
  37.    char command_parm[80];        /* command line parm           */
  38.    int nctr;                     /* counter for command parm    */
  39.  
  40.     printf ("Hewlett Packard LasterJet 4 Display Message Editor\n");
  41.     _harderr(harderr_handler);
  42.  
  43.     if ( argc > 1 )
  44.       {
  45.          command_parm[0] = '\0'; /* initialize the command parm */
  46.          for ( nctr = 1; nctr < argc; nctr++ )
  47.             {
  48.                strcat( command_parm, argv[nctr] );
  49.                strcat( command_parm, " " );
  50.             }
  51.          command_parm[17] = '\0'; /* cut line down to 16 characters */
  52.          print_display( command_parm );
  53.       }
  54.    else
  55.       {
  56.          printf( "\n" );                   /* print a blank line    */
  57.           printf( "Enter message to display on the HP4 (up to 16 characters).\n" );
  58.           printf( "If you do not enter any value, the printer will be reset\n" );
  59.           printf( "to the default '00 READY'.\n" );
  60.          printf( "________________\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" );
  61.           fgets( line, maxline, stdin );   /* read input line from screen */
  62.           line[strlen( line ) - 1] = '\0'; /* remove LF that fgets put in */
  63.          print_display( line );
  64.       }
  65. }
  66.  
  67. void print_display( char *line )                 /* send info to printer   */
  68. {
  69.    fprintf( stdprn, "\033%%-12345X@PJL \n" );    /* init printer for input */
  70.     if ( strlen( line ) == 1 )                    /*      if no info passed */
  71.         fprintf( stdprn, "@PJL RDYMSG DISPLAY = \"\" \n" ); /* clear message */
  72.     else                                              /* if info to process */
  73.         fprintf( stdprn, "@PJL RDYMSG DISPLAY = \"%s\" \n", line ); /* do it */
  74.     fprintf( stdprn, "@PJL ENTER LANGUAGE = PCL \n" );  /* set language PCL */
  75.     fprintf( stdprn, "\033%%-12345X@PJL \n" );          /* reset printer    */
  76.  
  77.    printf( "\nThis program is a courtesy of Grover Technology Inc.\n" );
  78.    printf( "Revision 2.0 by Jeff Steinmetz, Urge Productions.\n");
  79.  
  80. }
  81. void _far harderr_handler(
  82.             unsigned deverror,
  83.             unsigned errcode,
  84.             unsigned _far *devhdr) {
  85.  
  86.     /* shut the compiler up */
  87.     errcode=errcode;
  88.     devhdr = devhdr;
  89.  
  90.     if(!(deverror & 0x8000)) {
  91.         printf ( "A disk error has occurred.  Please re-check the disk system.\n");
  92.     } else {
  93.         printf ( "A printer error has occurred.  Please re-check the printer.\n");
  94.     }
  95.  
  96.     _hardresume(_HARDERR_ABORT);
  97. }
  98.