home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pcmagazi / 1988 / 15 / procparm.pas < prev    next >
Pascal/Delphi Source File  |  1988-07-25  |  1KB  |  44 lines

  1. PROGRAM ProcParmDemo;
  2. TYPE
  3.   BArray = ARRAY[0..1] OF Byte;
  4. VAR
  5.   Offsets : ARRAY[1..4] OF Integer;
  6.   N : Integer;
  7.  
  8.   PROCEDURE first(X : Integer);
  9.   BEGIN WriteLn(X, ' The first!'); END;
  10.  
  11.   PROCEDURE second(X : Integer);
  12.   BEGIN WriteLn(X, ' The second!'); END;
  13.  
  14.   PROCEDURE third(B : Barray);
  15.   BEGIN WriteLn(B[1]:3, B[0]:3, ' The third!'); END;
  16.  
  17.   PROCEDURE fourth(X : Integer);
  18.   BEGIN WriteLn(X, ' The fourth!'); END;
  19.  
  20.   PROCEDURE dummy(X : Integer);
  21.     { Procedure DoCall modifies the machine level code
  22.     of this procedure. }
  23.   BEGIN
  24.   END;
  25.  
  26.   PROCEDURE Init;             { Initialize the Offset array }
  27.   BEGIN
  28.     Offsets[1] := Ofs(first) -  Ofs(dummy);
  29.     Offsets[2] := Ofs(second) - Ofs(dummy);
  30.     Offsets[3] := Ofs(third) -  Ofs(dummy);
  31.     Offsets[4] := Ofs(fourth) - Ofs(dummy);
  32.   END;
  33.  
  34.   PROCEDURE docall(I : Integer);
  35.     { Transfer control to subroutine number I }
  36.   BEGIN
  37.     MemW[CSeg:Ofs(Dummy)+5] := Offsets[I];
  38.     dummy(I*100);
  39.   END;
  40.  
  41. BEGIN                         { main }
  42.   Init;
  43.   FOR N := 1 TO 4 DO docall(N);
  44. END.