home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / TURBOPAS / TRUN.LBR / TRUN281.PQS / TRUN281.PAS
Pascal/Delphi Source File  |  2000-06-30  |  5KB  |  102 lines

  1. Program TRUN;
  2.  
  3. {          TRUN runs a program specified on the command line.
  4.  
  5.     This version works with earlier versions of CP/M-80 Turbo Pascal.
  6.     Change the variable "Cmdbuffer" as shown in order to convert this
  7.     version of TRUN for use with MS-DOS or CP/M-86 Turbo  (v. 1 & 2).
  8.  
  9.                 (c) August, 1985 by: Mike Dingacci, MD
  10.  
  11.                 Program is hereby placed in the public
  12.                 domain.  It may be used by  anyone for
  13.                 any purpose. The author will accept no
  14.                 responsibility for the accuracy of the
  15.                 software,  nor for any problems  which
  16.                 may result from its use.       - RMD -
  17.  
  18.                 Comments or
  19.                 questions to:    P.O. Box 1124
  20.                                  Fallon, Nevada  89406
  21. }
  22.  
  23. Type
  24.      Cmdstr    = String[127]; { Max = 32 char in CP/M-80 because the TPA    }
  25.                               { starts at $100, overwriting everything      }
  26.                               { beyond 32 characters in the command buffer. }
  27.                               { Theoretical max = 127, if your DOS allows.  }
  28. Var
  29.      Cmdline,Cmd   : Cmdstr;  { Declared 1st for easy passage to .CHN file  }
  30.  
  31.      Cmdbuffer     : Cmdstr Absolute      $80; {--> for CP/M-80    }
  32. {*** Cmdbuffer     : Cmdstr Absolute Dseg:$80;  --> for CP/M-86 ***}
  33. {*** Cmdbuffer     : Cmdstr Absolute Cseg:$80;  --> for MS-DOS  ***}
  34.      I,Ltr,Z       : Integer;
  35.      Cmdfil        : File;
  36.      a             : String[2];
  37.  
  38. Procedure Instruct;       { v. number = same as v. of Turbo used to compile }
  39.    Begin
  40.      ClrScr; for I := 1 to 3 Do Writeln;
  41.      Write(
  42.      '        TRUN v. 2.8  -  Compiled with Turbo Pascal v. 2.0      ' ,a,a,
  43.  
  44.      '  This is a run-time loader,  compiled with the  DEFAULT  START' ,a,
  45.      '  ADDRESS  (the end of the pascal library plus 1).   For proper' ,a,
  46.      '  handling of variables, CHN programs run with this loader must' ,a,
  47.      '  be compiled with this same start address.   To run a CHN file' ,a,
  48.      '  with a  DIFFERENT start address, a new version of this loader' ,a,
  49.      '  may be compiled with a start address IDENTICAL to that of the' ,a,
  50.      '  program to be run.                                           ' ,a,a);
  51.  
  52.      {  Above message for CP/M-80.  Use the following for CP/M-86 and
  53.         MS-DOS versions of TRUN:
  54.  
  55.      '  This is a run-time loader compiled with  DEFAULT MEMORY SIZE.' ,a,
  56.      '  For proper handling of variables with MS-DOS and CP/M-86, the' ,a,
  57.      '  loader and the  CHN programs to be run must all have the same' ,a,
  58.      '  respective CODE SEGMENT, DATA SEGMENT, and FREE MEMORY sizes.' ,a,
  59.      '  In order to run  CHN  programs with  DIFFERENT memory values,' ,a,
  60.      '  compile a new  version of this loader whose memory values are' ,a,
  61.      '  IDENTICAL to those of the files to be run.                   ' ,a,a,}
  62.  
  63.      Write(
  64.      'To avoid this message, use the syntax:  TRUN filename          ' ,a,a,
  65.      'Filename is the name (without extension) of CHN program to run.' ,a,a,
  66.  
  67.      'Name of program to run: '); Readln(Cmd);
  68.      For I := 1 to Length(Cmd) Do Cmd [I] := Upcase(Cmd[I]); { Capitalize    }
  69.    End; {Instruct}
  70.  
  71. BEGIN {TRUN}
  72.  
  73.    a := Chr(13) + Chr(10);                 { CR/LF placed in variable a      }
  74.    Cmd   := ''; I := 0; Z := 0;            { variables zeroed for below      }
  75.    Cmdline := Cmdbuffer;                   { put buffer into string to parse }
  76.    Ltr   := Length(Cmdline);               { Ltr = no. of characters         }
  77.  
  78.    While I < Ltr Do Begin                  { Routine builds ParamStr(1)      }
  79.       I := I+1;                            { (could build 2, 3, etc.)        }
  80.       If Z = 1 Then If Cmdline[I] <> ' ' Then Cmd := Cmd + Cmdline[I];
  81.       If Cmdline[I] = ' ' Then Z := Z + 1;
  82.    End;
  83.    If Cmd  = '' Then Instruct;             { Instructions if no parameters.  }
  84.  
  85.    If Pos('.',Cmd) = 0 Then Cmd := Cmd+'.CHN'; { If no extent then = '.CHN'  }
  86.  
  87.    If Cmd <> '.CHN' Then Begin             { Chain to CHN program named --   }
  88.                                            { (unless it is a blank line).    }
  89.       Write('TRUN v. 2.8 (08/25/85): ');   { Same v. as Turbo used to compile}
  90.       Writeln(Cmd); Writeln;
  91.       Assign(Cmdfil,Cmd);
  92.       {$I-} Chain(Cmdfil) {$I+};           { 'file not found' error-trapping }
  93.                                            { starts on chain to cmdfil and   }
  94.                                            { error message follows:          }
  95.       If Ioresult <> 0 Then Write(
  96.  
  97.       '- - - - - - - - - - - > ', Chr(7), Cmd, ' NOT found.        ' ,a,a,
  98.       'Check disk and try again!                                   ');
  99.    End;
  100.  
  101. END. {TRUN}
  102.