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
/
TRUN2C1.PQS
/
TRUN2C1.PAS
Wrap
Pascal/Delphi Source File
|
2000-06-30
|
5KB
|
107 lines
Program TRUN2c;
{ TRUN runs a program specified on the command line.
This version works with all versions of CP/M-80 Turbo Pascal and
is designed to eliminate the 32-character limit imposed by using
the command line buffer at $80. This limit exists whether the
line is parsed by a program subroutine in earlier Turbo versions
or by ParamStr and ParamCount functions in Turbo Pascal v. 3.00.
Advantages:
(1) Can parse longer command lines (up to 128 characters).
(2) Can use the initial command in the line (ParamStr(0)).
(c) August, 1985 by Mike Dingacci, MD
Program is hereby placed in the public
domain. It may be used by anyone for
any purpose. The author will accept no
responsibility for the accuracy of the
software, nor for any problems which
may result from its use. - RMD -
Comments or
questions to: P.O. Box 1124
Fallon, Nevada 89406
}
Type
Cmdstr = String[127]; { 127 = max theoretical cmdline length }
Var
Cmdline,Cmd : Cmdstr; { Declared 1st for easy passage to .CHN file }
I,Ltr,Z,Cmdln : Integer;
Cmdfil : File;
a : String[2];
Procedure Parse;
Begin
Cmdline := ''; Cmd := ''; { zero variables for below }
I := 0; Z := 0;
Ltr := Mem[cmdln]; { Ltr = no. of characters }
While I < Ltr Do Begin { Routine builds ParamStr(1) }
I := I+1; { (could build 2, 3, etc.) }
Cmdline := Cmdline + Chr(Mem[Cmdln+I]); { variable 'Cmdline' passes }
{ command line to .CHN file }
If Z = 1 Then If Cmdline[I] <> ' ' Then Cmd := Cmd + Cmdline[I];
If Cmdline[I] = ' ' Then Z := Z + 1;
End;
End; {Parse}
Procedure Instruct; { v. number = same as v. of Turbo used to compile }
Begin
ClrScr; Gotoxy(1,4);
Write(
' TRUN v. 2.c - Compiled with CP/M Turbo Pascal v. 2.0 ' ,a,a,a,
{ ^-->use command line at ccp instead of $80 }
' This is a run-time loader, compiled with the DEFAULT START' ,a,
' ADDRESS (the end of the pascal library plus 1). For proper' ,a,
' handling of variables, CHN programs run with this loader must' ,a,
' be compiled with this same start address. To run a CHN file' ,a,
' with a DIFFERENT start address, a new version of this loader' ,a,
' may be compiled with a start address IDENTICAL to that of the' ,a,
' program to be run. ' ,a,a,
'To avoid this message, use the syntax: TRUN filename ' ,a,a,
'Filename is the name (without extension) of CHN program to run.' ,a,a,
'Name of program to run: '); Readln(Cmd);
For I := 1 to Length(Cmd) Do Cmd [I] := Upcase(Cmd[I]); { Capitalize }
End; {Instruct}
BEGIN {TRUN}
a := chr(13) + chr(10); { put CR/LF into variable a }
Cmdln := mem[2] * 256 - $1600 + 7; { find start of command line
(This algorithm will work even when pro- ) (bottom of CCP+7), where it
(grams such as XtraKey and UniForm are ) was conveniently stored for
(protected in high memory. Location from ) us, in its entirety, by
(06h and 07h won't work if this is true. ) cp/m! }
Parse; { procedure builds Parameters and }
{ returns strings Cmdline and Cmd.}
If Cmd = '' Then Instruct; { Instructions if no parameters. }
If Pos('.',Cmd) = 0 Then Cmd := Cmd+'.CHN'; { If no extent then = .CHN }
If Cmd <> '.CHN' Then Begin { Chain to CHN program named -- }
{ (unless it is a blank line). }
Write('TRUN v. 2.c (08/25/85): '); { Same v. as Turbo used to compile}
Writeln(Cmd); Writeln;
Assign(Cmdfil,Cmd);
{$I-} Chain(Cmdfil) {$I+}; { 'file not found' error-trapping }
{ starts on chain to cmdfil and }
{ error message follows: }
If Ioresult = 1 Then Write(
'- - - - - - - - - - - > ', Chr(7), Cmd, ' NOT found. ' ,a,a,
'Check disk and try again! ');
End;
END. {TRUN}