home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / P1351.ZIP / P1351.PAS
Encoding:
Pascal/Delphi Source File  |  1985-12-28  |  8.4 KB  |  220 lines

  1. {              toshiba -/send printer codes to the TOSHIBA printer           }
  2.  
  3. program toshiba;
  4.  
  5. const
  6.   program_name       = 'P1351';
  7.   rev_no             = '1.21';
  8.   rev_date           = '10/11/85';
  9.   sys_date           : string[8] = '        ';
  10.  
  11. type
  12.   string4      = string[4];
  13.   string64     = string[64];
  14.   string127    = string[127];
  15.  
  16. var
  17.   line,select_code,rc : integer;
  18.   escape,
  19.   bel                 : char;
  20.   parm_select         : string127;
  21.   select              : string[2];
  22.   in_line_command     : boolean;
  23.  
  24. { ************************************************************************** }
  25.  
  26. procedure colors(text,background : integer);
  27.  
  28. {     This procedure permits the change of both text and background colors    }
  29. {     with one procedure call, available colors are:                          }
  30.  
  31. {         0 = black          6 = brown            12 = light red              }
  32. {         1 = blue           7 = light gray       13 = light magenta          }
  33. {         2 = green          8 = dark gray        14 = yellow                 }
  34. {         3 = cyan           9 = light blue       15 = white                  }
  35. {         4 = red           10 = light green                                  }
  36. {         5 = magenta       11 = light cyan                                   }
  37.  
  38. {     text colors from 16 thru 31 will blink                                  }
  39.  
  40. begin
  41.     textcolor(text);
  42.     textbackground(background);
  43. end;
  44. { *************************************************************************** }
  45.  
  46. procedure clear_screen(text,background : integer);
  47. begin
  48.     colors(text,background);
  49.     clrscr;
  50.     colors(15,0);
  51.     write('Program: ',program_name:8,'    Rev number:',rev_no:5);
  52.     gotoxy(1,3);
  53.     colors(text,background);
  54. end;
  55.  
  56. { ************************************************************************** }
  57.  
  58. procedure getparm(var s:string127);
  59. var
  60.   parms : string127 absolute CSEG:$80;
  61. begin
  62.   s := '';                        { parms[1] exists even when length is zero }
  63.   while (length(parms) > 0) and (parms[1] = ' ') do
  64.       delete(parms,1,1);
  65.   while (length(parms) > 0) and (parms[1] <> ' ') do
  66.     begin
  67.       s := s + Parms[1]; delete(parms,1,1)
  68.     end
  69. end;
  70.  
  71. { ************************************************************************** }
  72.  
  73. procedure selection_menu;
  74. begin
  75.   clear_screen(15,0);
  76.   writeln('  2 - Expanded Print On                  4 - Condensed Print On');
  77.   writeln('  3 - Expanded Print Off                 5 - Condensed Print Off');
  78.   writeln;
  79.   writeln('  6 - Six Lines/Inch   7 - Eight Lines/Inch   8 - Nine Lines/Inch');
  80.   writeln;
  81.   writeln('  9 - Data Mode - Character Font 0 (12 cpi)');
  82.   writeln(' 10 - Data Mode - Character Font 0 (10 cpi)');
  83.   writeln;
  84.   writeln(' 11 - Courier - Character Font 1 (12 cpi)');
  85.   writeln(' 12 - Elite --- Character Font 2 (10 cpi)');
  86.   writeln;
  87.   writeln('    (P1351 and P351 Only)               (P351 Font Cartridge Only)');
  88.   writeln(' 13 - Font 4    14 - Font 5             15 - Font 6   16 - Font 7');
  89.   writeln;
  90.   writeln(' 17 - 10 CPI   18 - 12 CPI   19 - 15 CPI   20 - 17 CPI   21 - 20 CPI');
  91.   writeln;
  92.   writeln(' 22 - Initialize Printer');
  93.   writeln;
  94.   writeln(' 99 - EXIT TO SYSTEM                         98 - Command Line Instructions');
  95.   writeln;
  96.   writeln(' Select desired option by number : ');
  97.   writeln(' Options selected = ');
  98.   line:=20;
  99. end;
  100.  
  101. { ************************************************************************** }
  102.  
  103. procedure program_instructions;
  104. begin
  105.   clear_screen(15,0);
  106.   writeln('Command format -  P1351 <c> <c1> <c2> ... <cn>');
  107.   writeln;
  108.   writeln('    If no inline codes are specified the program will display the selection');
  109.   writeln('    menu as it is now doing.');
  110.   writeln;
  111.   writeln('    If inline codes are specified the program will send the appropriate');
  112.   writeln('    code(s) to the printer and then stop execution.  No selection menus');
  113.   writeln('    will be displayed and no opportunity to select additional code will be');
  114.   writeln('    given.');
  115.   writeln;
  116.   writeln('    Codes are specified in the command line by specifying the selsction');
  117.   writeln('    number from the selection menu.');
  118.   writeln;
  119.   writeln('    Examples:');
  120.   writeln('        C>P1351 3          will send compressed print codes to the printer.');
  121.   writeln('        C>P1351 7          will send 8 lines per inch code to the printer.');
  122.   writeln('        C>P1351 4 17 14    will set the printer to non-compressed mode');
  123.   writeln('                           select 10 cpi and font 4.');
  124.   writeln;
  125.   writeln('Press any key to return to selection menu');
  126.   repeat read(kbd) until keypressed;
  127.   selection_menu;
  128. end;
  129.  
  130. { ************************************************************************** }
  131.  
  132. procedure send_code;
  133. begin;
  134.   case select_code of
  135.       1 : write(lst,^G);                                               { bel }
  136.       2 : write(lst,^['!');                                    { expanded_on }
  137.       3 : write(lst,^['"');                                   { expanded_off }
  138.       4 : write(lst,^['*0'^['[');                     { font0 & condensed on }
  139.       5 : write(lst,^[']');                                  { condensed_off }
  140.       6 : write(lst,^['L08');                                      { six_lpi }
  141.       7 : write(lst,^['L06');                                    { eight_lpi }
  142.       8 : write(lst,^['L05');                                     { nine lpi }
  143.       9 : write(lst,^['*0'^['E10');                     { font0 & twelve cpi }
  144.      10 : write(lst,^['*0'^['E12');                        { font0 & ten cpi }
  145.      11 : write(lst,^['*1'^['E10');                     { font1 & twelve cpi }
  146.      12 : write(lst,^['*2'^['E12');                        { font2 & ten cpi }
  147.      13 : write(lst,^['*4');                                         { font4 }
  148.      14 : write(lst,^['*5');                                         { font5 }
  149.      15 : write(lst,^['*6');                                         { font6 }
  150.      16 : write(lst,^['*7');                                         { font7 }
  151.      17 : write(lst,^['E12');                                      { ten cpi }
  152.      18 : write(lst,^['E10');                                   { twelve cpi }
  153.      19 : write(lst,^['E08');                                  { fifteen cpi }
  154.      20 : write(lst,^['E07');                                { seventeen cpi }
  155.      21 : write(lst,^['E06');                                   { twenty cpi }
  156.      22 : write(lst,^[^Z'I');                                   { initialize }
  157.    else
  158.        writeln('Illegal printer code: ',select_code:4);
  159.    end;
  160. end;
  161.  
  162. { ************************************************************************** }
  163.  
  164. procedure selection;
  165. begin
  166.   selection_menu;
  167.   repeat
  168.       repeat
  169.         begin
  170.           gotoxy(36,23);
  171.           write('  ');
  172.           gotoxy(36,23);
  173.           select:='**';
  174.           buflen:=2;
  175.           read(select);
  176.           val(select,select_code,rc);
  177.         end;
  178.       until select_code in [2..7,9..22,98,99];
  179.       if select_code = 98 then
  180.           program_instructions
  181.       else
  182.           send_code;
  183.       gotoxy(line,24);
  184.       write(select:5);
  185.       line:=line+5;
  186.   until select_code = 99;
  187. end;
  188.  
  189. { ************************************************************************** }
  190.  
  191. begin;
  192.                                         { determine if inline commands exist }
  193.   getparm(parm_select);
  194.   if parm_select = '' then
  195.       in_line_command := false
  196.   else
  197.       in_line_command := true;
  198.                                                    { process inline commands }
  199.   if in_line_command then
  200.       repeat
  201.           val(parm_select,select_code,rc);
  202.           send_code;
  203.           getparm(parm_select);
  204.       until parm_select = '';
  205.                                  { display menu and capture command requests }
  206.   if not in_line_command then
  207.     begin
  208.       selection;
  209.       clear_screen(15,0);
  210.     end;
  211. end.
  212.  
  213.  
  214.  
  215. { REV 1.20 09/15/85                                                          }
  216. {         The Code was modified so that inline commands would be sent        }
  217. {         to the printer without presenting the selection menu.              }
  218. {         Instructions for using the command line were added and variables   }
  219. {         were replaces with literals.  Some undocumented codes were added.  }
  220.