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

  1. program turbo_install;
  2.  
  3. {TINSTALL.PAS
  4.  Turbo Pascal Ver. 2.0
  5.  PC-DOS Version
  6.  Copyright 1985 by David W. Carroll
  7.  All commercial rights reserved.
  8.  Date: 6-22-85
  9.  Version 5
  10.  
  11.  As published in Micro/Systems Journal 1-4
  12.                  September/October, 1985
  13.  
  14.  This program will change the start-up display
  15.  mode of pre-compiled Turbo Pascal 2.0 and 3.0
  16.  PC/MS-DOS '.COM' programs.
  17.  
  18.  This program and 300+ other Turbo Pascal programs 
  19.  are available on the High Sierra RBBS-PC at
  20.  209/296-3534 - 300/1200 - 24 hours 
  21. }
  22.  
  23. const
  24.   ASCII_offset = $30;
  25.   logo_byte1 = $07;
  26.   type_byte1 = $55;
  27.   mode_byte  = $6D;
  28.   type_data  : array[0..5,1..21] of char =
  29.              (#$14'Default display mode',
  30.              #$12'Monochrome display'#000#000,
  31.              #$13'Color display 80x25'#000,
  32.              #$13'Color display 40x25'#000,
  33.              #$13'b/w   display 80x25'#000,
  34.              #$13'b/w   display 40x25'#000);
  35.   mode_data  : array[0..5] of byte =
  36.              ($FF,$07,$03,$01,$02,$00);
  37.   logo       : array[1..30] of char =
  38.              'Copyright (C) 198X BORLAND Inc';
  39.  
  40. type
  41.   fil      = file of byte;
  42.   datstr   = string[20];
  43.  
  44. var
  45.   infile              : fil;
  46.   display_type, prog  : byte;
  47.   quit, bad_logo      : boolean;
  48.  
  49. procedure uppercase (var Str : datstr);
  50. var
  51.   indx, len   : byte;
  52.  
  53. begin
  54.   len := length(str);
  55.   for indx := 1 to len do
  56.     str[indx] := UpCase(str[indx])
  57. end;   {procedure  uppercase}
  58.  
  59.  
  60. procedure title;
  61. begin
  62.   ClrScr;
  63.   Writeln('Turbo Pascal Install Program');
  64.   Writeln('Copyright 1985 by David W. Carroll');
  65.   Writeln;
  66.   Writeln('Display Installation for Compiled Turbo Pascal Programs');
  67.   Writeln;
  68.   Delay(3000);
  69.   writeln;
  70.   writeln;
  71. end;   {procedure title}
  72.  
  73. procedure open_file;
  74. var
  75.   goodfile : boolean;
  76.   infname  : string[20];
  77.  
  78. begin
  79.   window(1,6,80,25);    {PC-DOS}
  80.   repeat
  81.     ClrScr;             {PC-DOS}
  82.     write ('Program filename  -->  ');
  83.     readln (infname);
  84.     writeln;
  85.     uppercase(infname);
  86.     if (pos('.COM',infname)=0) then
  87.     begin
  88.       goodfile := false;
  89.       writeln('Must be .COM filetype!'^G);
  90.       delay(3000);
  91.     end
  92.     else
  93.     begin
  94.       assign(infile,infname);
  95.       {$I-} reset(infile) {$I+};
  96.       goodfile := (IOresult = 0);
  97.       if not goodfile then
  98.       begin
  99.         writeln (^G'FILE ',infname,' NOT FOUND');
  100.         delay(3000)
  101.       end;
  102.     end;
  103.   until goodfile;
  104. end;   {procedure open_file}
  105.  
  106. procedure logo_test;
  107. var
  108.   indx : byte;
  109.   test_byte : byte;
  110.  
  111. begin
  112.   bad_logo := false;
  113.   seek(infile,logo_byte1);
  114.   for indx := 1 to 30 do
  115.   begin
  116.     read(infile,test_byte);
  117.     if indx <> 18 then          {ignore units digit of year in logo}
  118.       if (chr(test_byte) <> logo[indx]) then bad_logo := true;
  119.   end;
  120. end;   {procedure logo_test}
  121.  
  122. procedure type_test;
  123.  
  124. var
  125.   indx,dat    : byte;
  126.   display_str : string[20];
  127.  
  128. begin
  129.   seek(infile,type_byte1);
  130.   for indx := 0 to 20 do
  131.   begin
  132.     read(infile,dat);
  133.     display_str[indx] := chr(dat);
  134.   end;
  135.   writeln;
  136.   write('Installed display type = ');
  137.   writeln(display_str);
  138.   writeln;
  139. end;   {procedure type_test}
  140.  
  141. procedure select_display;
  142. var
  143.   display_indx, char_indx : byte;
  144.   ans : char;
  145.  
  146. begin
  147.   writeln;
  148.   window(1,8,80,25);  {PC-DOS}
  149.   ans := ' ';
  150.   ClrScr;             {PC-DOS}
  151.   type_test;
  152.   Writeln('Choose one of the following displays:');
  153.   Writeln;
  154.   for display_indx := 0 to 5 do
  155.   begin
  156.     write('  ',display_indx:2,'.  ');
  157.     for char_indx := 2 to 21 do
  158.       write(type_data[display_indx,char_indx]);
  159.     writeln;
  160.   end;
  161.   writeln;
  162.   Write('Which display? (Enter no. or ^Q to exit):');
  163.   while not (UpCase(ans) in ['0'..'5',^Q,'Q']) do
  164.     Read(kbd,ans);
  165.   writeln;
  166.   writeln;
  167.   if (UpCase(ans) in ['Q',^Q]) then
  168.     quit := true
  169.   else
  170.     display_type := ord(ans) - ASCII_offset;
  171. end;   {procedure select_display}
  172.  
  173. procedure write_data;
  174. var
  175.   char_indx, data_byte : byte;
  176.  
  177. begin
  178.   seek(infile,type_byte1);
  179.   for char_indx := 1 to 21 do
  180.   begin
  181.     data_byte := ord(type_data[display_type,char_indx]);
  182.     write(infile,data_byte);
  183.   end;
  184.   seek(infile,mode_byte);
  185.   write(infile,mode_data[display_type]);
  186.   flush(infile);
  187.   close(infile);
  188.   writeln('Installation completed.');
  189. end;   {procedure write_data}
  190.  
  191. procedure exit1;
  192. begin
  193.   close(infile);
  194.   writeln;
  195.   if quit then
  196.     writeln('Program aborted.'^G)
  197.   else
  198.     writeln('Bad logo - not a Turbo Pascal compiled program'^G^G^G);
  199. end;     {procedure exit1}
  200.  
  201. begin  {main module TINSTALL}
  202.   quit := false;
  203.   title;
  204.   open_file;
  205.   logo_test;
  206.   if not bad_logo then select_display;
  207.  
  208.   if (not bad_logo) and (not quit) then
  209.     write_data
  210.   else
  211.     exit1;
  212. end.   {main module TINSTALL}
  213.