Category : Pascal Source Code
Archive   : PASTUT.ZIP
Filename : PROCTYPE.PAS

 
Output of file : PROCTYPE.PAS contained in archive : PASTUT.ZIP
(* Chapter 5 - Program 9 *)
program Procedure_Type_Example;

{$F+} (* This forces far calls and is required by TURBO *)
(* Pascal to use a procedure type. *)

type Procedure_Type = procedure(In1, In2, In3 : integer;
var Result : integer);

var Number1, Number2, Number3 : integer;
Final_Result : integer;
Do_Math : Procedure_Type;


procedure Add(In1, In2, In3 : integer;
var Result : integer);
begin
Result := In1 + In2 + In3;
Writeln('The sum of the numbers is ',Result:6);
end;

procedure Mult(In1, In2, In3 : integer;
var Result : integer);
begin
Result := In1 * In2 * In3;
Writeln('The product of the numbers is',Result:6);
end;

procedure Average(In1, In2, In3 : integer;
var Result : integer);
begin
Result := (In1 * In2 * In3) div 3;
Writeln('The Average of the numbers is',Result:6);
end;

begin
Number1 := 10;
Number2 := 15;
Number3 := 20;

Do_Math := Add;
Do_Math(Number1, Number2, Number3, Final_Result);

Do_Math := Mult;
Do_Math(Number1, Number2, Number3, Final_Result);

Do_Math := Average;
Do_Math(Number1, Number2, Number3, Final_Result);
end.




{ Result of execution

The sum of the numbers is 45
The product of the numbers is 3000
The average of the numbers is 1000

}


  3 Responses to “Category : Pascal Source Code
Archive   : PASTUT.ZIP
Filename : PROCTYPE.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/