Category : HD Utilities
Archive   : UPS11.ZIP
Filename : PARAMS.PAS

 
Output of file : PARAMS.PAS contained in archive : UPS11.ZIP
UNIT params;
{
Written by: Derek Giedd
WR-ALC/MAITAD
Robins AFB, Ga. 31098

This Turbo Pascal Unit is an enhancement to the ParamCount and GetParam
functions supplied with Turbo Pascal. Both functions are combined
in the GetParams function. While GetParam requires that each parameter
be seperated by a space, GetParams does not.

GetParams requires three parameters. The first parameter is the
array where you wish to store the paramaters. This array should be
declared type ParamType. This will provide up to 40 parameters on a
single command line. The second paramater is a delimiter to seperate the
parameters. This is a single character. The third parameter is a boolean
Help. If the user enters a ? or HELP on the command line, Help is set
True. GetParams also returns as its function value the number of
parameters.

All command line parameters are converted to upper case. }

Interface

Uses DOS;

Type
ParamType = Array [1..40] Of String;

Function getparams (Var pvalue : ParamType; delim : Char;
Var help : Boolean) : Integer;

Implementation

Function getparams (Var pvalue : ParamType; delim : Char;
Var help : Boolean) : Integer;

Var
s : String;
i : Integer;
j : Integer;
s1 : String;
numparams : Integer;
delimit : Char;

BEGIN
numparams := 0;
help := False;
delimit := UpCase(delim);

{ If no parameters present, the return. }

If ParamCount <> 0 Then
Begin
For i := 1 TO ParamCount Do
Begin
s := paramstr(i);

{ Convert parameter to upper case }

For j := 1 TO Length(s) Do
s[j] := UpCase(s[j]);

{ If help requested then set help flag }

If (s = '?') OR (s = 'HELP') Then
help := True
Else If (s[1] <> delimit) Then
Begin
numparams := numparams + 1;
j := Pos(delimit, s);
If j <> 0 Then
Begin
pvalue[numparams] := Copy(s,1,j-1);
s := Copy(s,j,80);
End
Else
pvalue[numparams] := s;
End;
While (Pos(delimit, s) <> 0) Do
Begin
s := Copy(s,Pos(delimit,s)+1,80);
If Pos(delimit,s) > 0 Then
s1 := delimit+copy(s,1,Pos(delimit,s)-1)
Else
s1 := delimit+copy(s,1,80);
numparams := numparams + 1;
pvalue[numparams] := s1;
s := Copy(s,Pos(delimit,s),80);
End;
End;
End;
getparams := numparams;
End;
End.


  3 Responses to “Category : HD Utilities
Archive   : UPS11.ZIP
Filename : PARAMS.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/