Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbosgd!gatech!gitpyr!cc100jr From: cc100jr@gitpyr.UUCP (Joel M. Rives) Newsgroups: net.micro.pc,net.lang.pascal,net.wanted.sources Subject: Re: Device checking in Turbo Message-ID: <1474@gitpyr.UUCP> Date: Wed, 26-Feb-86 12:40:01 EST Article-I.D.: gitpyr.1474 Posted: Wed Feb 26 12:40:01 1986 Date-Received: Fri, 28-Feb-86 06:58:52 EST References: <198@dcc1.UUCP> Reply-To: cc100jr@gitpyr.UUCP (Joel M. Rives) Distribution: net Organization: Office of Computing Services, Georgia Tech Lines: 82 Xref: watmath net.micro.pc:7159 net.lang.pascal:481 net.wanted.sources:1944 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 >>