home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TP_ADV.ZIP / LIST0404.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-07-31  |  1.3 KB  |  41 lines

  1. Program CCallsPascal;
  2. { This is a sample Pascal program that demonstrates a way of  }
  3. { interfacing a Turbo Pascal procedure to be called from the  }
  4. { Turbo C module that is linked in.                           }
  5. {$A-,F-}
  6.  
  7. Uses Crt;
  8.  
  9. Var
  10.   Count : Integer;
  11.  
  12. {$L list4-3}
  13.  
  14. Procedure StartUpC; External;
  15.  
  16. Procedure PasProc;
  17. { This is the procedure that will be called from within the   }
  18. { Turbo C object module.  All this will do is output a string }
  19. { to the screen and increment a global variable.  This        }
  20. { variable will keep track of the number of times the routine }
  21. { is called.                                                  }
  22.  
  23. Begin
  24.   Inc( Count );          { Add 1 to global variable           }
  25.   Write( Count, '  ' );  { Ouput the new value                }
  26. End;
  27.  
  28. Begin
  29.   Count := 0;            { Initialize the counter.            }
  30.   ClrScr;                { Clear the user screen              }
  31.   StartUpC;              { Call the external C routine        }
  32.   Writeln;               { Output a CR/LF to screen           }
  33.   Writeln( 'The Pascal routine was called a total of ',
  34.             Count, ' times.' );
  35.                          { Report number of times called      }
  36.   Write( 'Press any key to continue...' );
  37.   While( Not Keypressed ) Do
  38.     { NOP };             { Pause the program for keypress     }
  39. End.
  40.  
  41.