Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
SUMINT.PAS
◄Example► ◄Contents► ◄Index► ◄Back►
PROGRAM sumint;
{ SUMINT.PAS returns the sum of its integer parameters. It illustrates
the following routines:
ParamCount ParamStr Val
}
CONST
program_name = 'SUMINT ';
program_desc = ' prints the sum of its integer parameters.';
VAR
count : Word;
lint : LongInt;
sum : LongInt;
status : Integer;
BEGIN
Writeln( program_name, program_desc );
Writeln;
sum := 0;
FOR count := 1 TO ParamCount DO
BEGIN
Val( ParamStr( count ), lint, status );
IF (status <> 0) THEN
Writeln( 'Character ',status, ' in parameter ', count,
' invalid.' )
ELSE sum := sum + lint;
END;
Writeln( 'The sum of the valid parameters is ', sum, '.' );
END.