home *** CD-ROM | disk | FTP | other *** search
- Program LastSampleProgram;
- { This sample program interfaces one of the variables defined }
- { in Turbo Pascal's CRT unit. This variable is then modified }
- { within the C module. We also have a Pascal procedure that }
- { is called from the C routine. }
- {$A-,F-}
-
- Uses Crt; { Link in the CRT unit }
-
- Var
- _rsp : Pointer; { Memory for the SI and DI registers }
- SiDiStack : Array[0..10] of Word;
- OldI, I : Integer; { Variable that will be modified in C }
- TPTextAttr : Word Absolute TextAttr;
- { Declared ABSOLUTE so C can see it }
-
- {$L List4-11} { Link the C Module }
-
- Procedure StartUpC; External;
- { This procedure is the main routine contained within the C }
- { external routines. }
-
- Procedure CallFromC( I : Integer );
- { This is a procedure that will be called from the external }
- { module created with Turbo C. }
-
- Begin
- Writeln( 'Old Value of I was ', OldI );
- Writeln( 'New value of I is ', I );
- OldI := I;
- End;
-
- Begin
- _rsp := @SiDiStack; { Point to memory for SI and DI }
- I := 1; { Initialize value of I to 1. }
- OldI := 0; { Set old value of I for later use }
- StartUpC; { Call the C module }
- Writeln( 'Press any key to continue....' );
- While( Not Keypressed ) Do
- { NOP }; { Pause for viewing of screen }
- End.