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

  1. Program AnotherCExample;
  2. { This next example will interface several routines from Turbo }
  3. { Pascal's DOS unit so they are able to be called from the     }
  4. { external C module.  This routine also defines the necessary  }
  5. { memory locations to store the SI and DI registers, as Turbo  }
  6. { Pascal trashes these values when C uses them as general      }
  7. { purpose registers.                                           }
  8. {$A-,F-}
  9.  
  10. Uses Crt, Dos;    { Link in these two standard units           }
  11.  
  12. Var
  13.   Ver : Word;     { Location for result of DosVersion call     }
  14.   Size : LongInt; { Location for result of DiskSize call       }
  15.   Free : LongInt; { Location for result of DiskFree call       }
  16.   _rsp : Pointer; { Memory to store the SI and DI registers    }
  17.   SiDiStack : Array[0..10] of Word;
  18.  
  19. {$L List4-8}      { Link in required C module                  }
  20.  
  21. Procedure StartupC( Var Free, Size : LongInt; Var Ver : Word );
  22. External;
  23. { This is the header for the external C module that will be    }
  24. { called by this Turbo Pasaal program.                         }
  25.  
  26. Function PasDosVersion : Word;
  27. { Local Function that will make the actual call to the routine }
  28. { in the DOS unit.                                             }
  29.  
  30. Begin
  31.   PasDosVersion := DosVersion;
  32. End;
  33.  
  34. Function PasDiskFree( Drive : Byte ) : LongInt;
  35. { Local Function that will make the actual call to the routine }
  36. { in the DOS unit.                                             }
  37. Begin
  38.   PasDiskFree := DiskFree( Drive );
  39. End;
  40.  
  41. Function PasDiskSize( Drive : Byte ) : LongInt;
  42. { Local Function that will make the actual call to the routine }
  43. { in the DOS unit.                                             }
  44. Begin
  45.   PasDiskSize := DiskSize( Drive );
  46. End;
  47.  
  48. Begin
  49.   _rsp := @SiDiStack;       { Point to storage for SI and DI   }
  50.   StartupC( Free, Size, Ver ); { Call the C module             }
  51.   ClrScr;                   { Clear the User Screen            }
  52.   GotoXY( 1,5 );            { Reposition the Cursor            }
  53.   Writeln( 'Current DOS version is ', Lo( Ver ), '.', Hi( Ver ) );
  54.   Writeln( 'Total disk capacity is  ', Size );
  55.   Writeln( 'Total bytes free is     ', Free );
  56.   Writeln;
  57.   Writeln( 'Press any key to continue...' );
  58.                             { Output the results and pause     }
  59.   While( Not Keypressed ) Do
  60.     { NOP };
  61. End.
  62.