home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
ipo-101.zip
/
Samples.zip
/
ADD.PAS
next >
Wrap
Pascal/Delphi Source File
|
1998-03-31
|
719b
|
26 lines
program add(output);
(*
** This sample program adds up all the program arguments
** and prints out the sum
*)
var
sum, (* Stores the sum *)
i, (* Counts the program arguments *)
x, (* Stores the converted program arguments *)
err (* Indicates whether or not there was an error *)
: integer;
begin
sum := 0; (* initiaze the sum *)
for i := 1 to paramcount do
begin
val(paramstr(i), x, err); (* Convert program agument into an integer *)
if err <> 0 then
begin
writeln(paramstr(i), ' is not a valid integer');
halt
end;
sum := sum + x
end;
writeln('Sum is ', sum)
end.