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

  1. Program LastSampleProgram;
  2. { This sample program interfaces one of the variables defined }
  3. { in Turbo Pascal's CRT unit.  This variable is then modified }
  4. { within the C module.  We also have a Pascal procedure that  }
  5. { is called from the C routine.                               }
  6. {$A-,F-}
  7.  
  8. Uses Crt;            { Link in the CRT unit                   }
  9.  
  10. Var
  11.   _rsp : Pointer;    { Memory for the SI and DI registers     }
  12.   SiDiStack : Array[0..10] of Word;
  13.   OldI, I : Integer; { Variable that will be modified in C    }
  14.   TPTextAttr : Word Absolute TextAttr;
  15.                      { Declared ABSOLUTE so C can see it      }
  16.  
  17. {$L List4-11}        { Link the C Module                      }
  18.  
  19. Procedure StartUpC; External;
  20. { This procedure is the main routine contained within the C   }
  21. { external routines.                                          }
  22.  
  23. Procedure CallFromC( I : Integer );
  24. { This is a procedure that will be called from the external   }
  25. { module created with Turbo C.                                }
  26.  
  27. Begin
  28.   Writeln( 'Old Value of I was ', OldI );
  29.   Writeln( 'New value of I is ', I );
  30.   OldI := I;
  31. End;
  32.  
  33. Begin
  34.   _rsp := @SiDiStack;   { Point to memory for SI and DI       }
  35.   I := 1;               { Initialize value of I to 1.         }
  36.   OldI := 0;            { Set old value of I for later use    }
  37.   StartUpC;             { Call the C module                   }
  38.   Writeln( 'Press any key to continue....' );
  39.   While( Not Keypressed ) Do
  40.     { NOP };            { Pause for viewing of screen         }
  41. End.
  42.