home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / LASER / HPSET2.ZIP / HPSET2.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-04-27  |  4.3 KB  |  163 lines

  1. Program HPset;
  2. uses crt,dos,printer;
  3. type
  4.   st80  = string[80];
  5.  
  6. var
  7.   e,null,ff,HPreset,HP8lpi,HP6lpi,HP16cpi,HP10cpi,HPland,HPport,HPmanu,HPleg,HPlet,HPauto  : st80;
  8.   history : st80;
  9.   pick    : char;
  10.   done, gotit  : boolean;
  11.   IOcode  : integer;
  12.  
  13. FUNCTION PrinterReady(TimeOutSeconds : integer) : Boolean;
  14.   {provided by Dan Strenczewilk on BORPRO forum (thanks, Dan)}
  15.  VAR
  16.   R : Registers;
  17.   hour, min, sec, hun, StartTime, i : WORD;
  18.  BEGIN
  19.   GetTime(hour,min,sec,hun);
  20.   StartTime := (min*60)+sec;
  21.   REPEAT
  22.     R.AX := $4407;      { IOCTL function 7 - Get output status }
  23.     R.BX := $0004;      { standard Printer device handle }
  24.     MsDos(R);
  25.     i := IOresult;
  26.     GetTime(hour,min,sec,hun);
  27.   UNTIL ((R.Flags and fcarry = 0) AND (R.AL = $FF))
  28.         or ((min*60)+sec-StartTime > TimeOutSeconds) or (i <> 0);
  29.   PrinterReady := (R.Flags and fcarry = 0) and (r.AL = $FF) and (i = 0);
  30.  END;
  31.  
  32.  
  33. BEGIN
  34.  
  35. {Printer strings}
  36. e           := CHR(27);
  37. null        := CHR(0);
  38. ff          := CHR(12);
  39.  
  40. HPreset     := null+e+'E'+e+'(8U'+e+'(s10h3T';
  41. HP8lpi      := e+'&l8D';
  42. HP6lpi      := e+'&l6D';
  43. HP16cpi     := e+'(s16.66h0T';
  44. HP10cpi     := e+'(s10h3T';
  45. HPland      := e+'&l1O';
  46. HPport      := e+'$l0O';
  47. HPmanu      := e+'&l2H';
  48. HPleg       := HPmanu+e+'&l1O'+e+'&l3A'+e+'(s16.66h0T'+e+'&l8D';
  49. HPlet       := e+'&l2A';
  50. HPauto      := e+'&l1H';
  51.  
  52. writeln('Set up HP LaserJet');
  53. writeln;
  54. history:=' ';
  55. pick := '1';
  56. done := false;
  57. while not done do
  58.   begin
  59.   ClrScr;
  60.   writeln;
  61.   write('                        ');
  62.   TextColor(0);
  63.   TextBackground(7);
  64.   writeln ('S e t   u p   H P  L a s e r J e t');
  65.   TextColor(7);
  66.   TextBackground(0);
  67.   writeln;
  68.   write ('Selected so far : ');
  69.   write(history);
  70.   writeln;
  71.   writeln('   1: Reset Printer');
  72.   writeln('   2: 8 lines per inch - (close spacing)');
  73.   writeln('   3: 6 lines per inch - (normal spacing)');
  74.   writeln('   4: 16 chars. per in. - condensed, LinePrinter');
  75.   writeln('   5: 10 chars. per in. - normal Courier');
  76.   writeln('   6: Landscape - sideways');
  77.   writeln('   7: Portrait - upright' );
  78.   writeln('   8: Legal paper, manual, landscape, condensed, 8 li./in.');
  79.   writeln('   9: Letter paper');
  80.   writeln('   A: Manual Feed');
  81.   writeln('   B: Auto Feed');
  82.   writeln('   T: Test');
  83.   writeln('   F: Form Feed - eject page');
  84.   writeln('   0 or Esc: QUIT');
  85.   writeln;
  86.   write('>> ');
  87.   gotit := false;
  88.   while not gotit do
  89.   begin
  90.     pick := UpCase(ReadKey);
  91.     case pick of
  92.       #27      : halt;
  93.       '0'      : halt;
  94.     end;
  95.     if pick in ['1','2','3','4','5','6','7','8','9','A','B','F','T'] then gotit := true;
  96.   end;
  97.  
  98.   if printerready(2) = false then
  99.   begin
  100.     writeln(chr(7), 'PRINTER ERROR - PRINTER NOT ON-LINE!!!');
  101.     halt;
  102.   end;
  103.   case pick of
  104.     '1': begin
  105.          write(lst,HPreset);
  106.          history := pick;
  107.          end;
  108.     '2': begin
  109.          write(lst,HP8lpi);
  110.          history := history+' '+pick;
  111.          end;
  112.     '3': begin
  113.          write(lst,HP6lpi);
  114.          history := history+' '+pick;
  115.          end;
  116.     '4': begin
  117.          write(lst,HP16cpi);
  118.          history := history+' '+pick;
  119.          end;
  120.     '5': begin
  121.          write(lst,HP10cpi);
  122.          history := history+' '+pick;
  123.          end;
  124.     '6': begin
  125.          write(lst,HPland);
  126.          history := history+' '+pick;
  127.          end;
  128.     '7':begin
  129.          write(lst,HPport);
  130.          history := history+' '+pick;
  131.          end;
  132.     '8': begin
  133.          write(lst,HPleg);
  134.          history := history+' '+pick;
  135.          end;
  136.     '9': begin
  137.          write(lst,HPlet);
  138.          history := history+' '+pick;
  139.          end;
  140.     'A': begin
  141.          write(lst,HPmanu);
  142.          history := history+' '+pick;
  143.          end;
  144.     'B': begin
  145.          write(lst,HPauto);
  146.          history := history+' '+pick;
  147.          end;
  148.     'T': begin
  149.          write(lst,'This is a test of the state of the printer.');
  150.          writeln(lst);
  151.          writeln(lst,'Selections so far: '+history);
  152.          history := history+' '+pick;
  153.          writeln(lst);
  154.          end;
  155.     'F': begin
  156.          write(lst,ff);
  157.          history := history+' '+pick;
  158.          end;
  159.   end;
  160.  
  161. end;
  162.   END.
  163.