bingaman@dcc1.UUCP (George C. Bingaman) (02/26/86)
Can anyone tell me how I can get version 2.0 of Turbo Pascal running under MS/PC-DOS to check the status of a device? I would like to verify that the printer is online, and that the drive is ready before doing I/O. I would also like to have the program check to see what drive it is being run from. I have looked thru Borland's reference manual, but if the info is there I'm missing it. Any help would be greatly appreciated. Thanks in advance, George =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= | / akgua \ George C. Bingaman | / cbosgd \ DeKalb Community College | ...!/ hplabs \!gatech!dcc1!bingaman 2101 Womack Rd. | \ ihnp4 / Dunwoody (Atlanta) Ga. 30338 | \ seismo / | \ ulysses/ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= | / akgua \ George C. Bingaman | / cbosgd \ DeKalb Community College | ...!/ hplabs \!gatech!dcc1!bingaman 2101 Womack Rd. | \ ihnp4 / Dunwoody (Atlanta) Ga. 30338 | \ seismo / | \ ulysses/ =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
cc100jr@gitpyr.UUCP (Joel M. Rives) (02/26/86)
In article <198@dcc1.UUCP> bingaman@dcc1.UUCP (George C. Bingaman) writes: > > Can anyone tell me how I can get version 2.0 of Turbo Pascal running under >MS/PC-DOS to check the status of a device? I would like to verify that the >printer is online, and that the drive is ready before doing I/O. I would also >like to have the program check to see what drive it is being run from. > I have looked thru Borland's reference manual, but if the info is there I'm >missing it. Any help would be greatly appreciated. > -------------------------------------------------------------------------------- I recommend that you re-read section 14.8 in the Version 2.0 Reference Manual. This section deals with the function IOresult. By setting {$I-} as a compiler directive, you can do your own I/O error trapping. Experiment a little. It can't hurt and you may learn a lot. One suggestion for checking which drive the program is running from is as follows: Assume that the name of the program you are running is called "myprog.com". const MaxDrive = { the greatest reference letter for a disk drive for your system } type drives = '@'..MaxDrive; { @ = no drive or nil drive } {$I-} function disk_drive: drives; var exists : boolean; drive : drives; test : text; path : string[20]; begin assign(test,'dummy.tst'); rewrite(test); writeln(test,'This is a test file'); close(test); exists := false; drive := '@'; while (not exists) and (drive < MaxDrive) do begin drive := drives(ord(drive) + 1); path := drive + ':' + 'dummy.tst'; assign(test,path); exists := IOresult = 0; close(test); end; erase(test); if exists then disk_drive := drive else disk_drive := '@'; end; { disk_drive } {$I+} This function could be called (in this example) as follows: var current : drives; begin . . . current := disk_drive; . . . end. The variable "current" should then contain the letter of the drive which the program is currently working from. -Joel Rives Joel Rives Georgia Insitute of Technology, Atlanta Georgia, 30332 ...!{akgua,allegra,amd,hplabs,ihnp4,seismo,ut-ngp}!gatech!gitpyr!cc100jr "Remember, no matter where you go, there you are!" << Buckaroo Banzai >>
bert@ucla-cs.UUCP (02/28/86)
> > Can anyone tell me how I can get version 2.0 of Turbo Pascal running under > MS/PC-DOS to check the status of a device? I would like to verify that the > printer is online, and that the drive is ready before doing I/O. I would also > like to have the program check to see what drive it is being run from. > I have looked thru Borland's reference manual, but if the info is there I'm > missing it. Any help would be greatly appreciated. > > Thanks in advance, > George > what you should be looking at is an MS-DOS reference manual. There are MS-DOS interrupts which return device status information, and you can perform any interrupt you want by setting up request parameters in a Turbo 'regpack' and calling the Turbo routine Intr. Results are passed back through the regpack.