home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l043 / 3.ddi / PROCPTR.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-11-02  |  1.3 KB  |  48 lines

  1.  
  2. {           Copyright (c) 1985, 87 by Borland International, Inc.            }
  3.  
  4. program ProcPtr;
  5. { This example program shows how to use a pointer and an inline
  6.   directive to call 2 different procedures with the same parameters.
  7.   CallProc is an inline directive (or macro) with the same parameters
  8.   as both One and TheOther. A global pointer variable, ProcAddr,
  9.   contains the address of the procedure to call. Then a call is made
  10.   to CallProc, which in turn does a far call to the address stored
  11.   in ProcAddr.
  12.  
  13.   Warning: This technique is recommended only for those programmers with
  14.            assembly language programming experience.
  15.  
  16.   For more information about inline directives, refer to P-367 in the
  17.   Owner's Handbook.
  18. }
  19.  
  20. var
  21.   ProcAddr : pointer;
  22.  
  23. procedure CallProc(var i : integer; w : word; s : string);
  24.   Inline($FF/$1E/ProcAddr);
  25.  
  26. {$F+}
  27. procedure One(var i : integer; w : word; s : string);
  28. begin
  29.   Writeln('First One,');
  30. end;
  31. {$F-}
  32.  
  33. {$F+}
  34. procedure TheOther(var i : integer; w : word; s : string);
  35. begin
  36.   Writeln('then TheOther');
  37. end;
  38. {$F-}
  39.  
  40. var
  41.   i : integer;
  42. begin
  43.   ProcAddr := @One;
  44.   CallProc(i, 7, 'data');                  { first call one }
  45.   ProcAddr := @TheOther;
  46.   CallProc(i, 5, 'more data');             { then call the other }
  47. end.
  48.