Posted: Mon Feb 18, 2002 9:56 am
Restored from previous forum. Originally posted by Roxxler.
Hi,
here a little procedure to check if a diskdrive is present or not.
For that the procedure uses the exec/OpenDevice() function, so we
have to open the exec.library at program start. Also used is the
PureBasic function AllocateMemoryBank(0,....), so we need also
a InitMemory(min 0) at program start.
Procedure.b ExistDiskDrive(drivenumber.b) ; parameter is the number of the diskdrive (0-3)
iorequest.l=AllocateMemoryBank(0,80,#MEMF_FAST|#MEMF_CLEAR) ; we need some mem for the iorequest
res.l=OpenDevice_(@"trackdisk.device",drivenumber,iorequest,0) ; we open the device, for diskdrives it is the
; trackdisk.device, the unitnumber is also used
; and also the address of our iorequest
If res=0 ; 0 means that all went fine and the device is open
CloseDevice_(iorequest) ; close the opened device
ProcedureReturn -1 ; and we can return -1 (TRUE), the drive is present
Else
ProcedureReturn 0 ; >0 means that the drive is not present, we return a 0
EndIf
FreeMemoryBank(0) ; free our mem, we don't have to do this, PureBasic will do it at program end, but we do
EndProcedure
;example:
OpenExecLibrary_(36)
InitMemoryBank(0)
For z.b=0 To 3
ok.b=ExistDiskDrive(z)
If ok
Print("Diskdrive DF"):PrintNumber(z):PrintN(": is present!")
Else
Print("Diskdrive DF"):Printnumber(z):PrintN(": is not present!")
EndIf
Next z
End
Greetings ..
Roxxler
Hi,
here a little procedure to check if a diskdrive is present or not.
For that the procedure uses the exec/OpenDevice() function, so we
have to open the exec.library at program start. Also used is the
PureBasic function AllocateMemoryBank(0,....), so we need also
a InitMemory(min 0) at program start.
Procedure.b ExistDiskDrive(drivenumber.b) ; parameter is the number of the diskdrive (0-3)
iorequest.l=AllocateMemoryBank(0,80,#MEMF_FAST|#MEMF_CLEAR) ; we need some mem for the iorequest
res.l=OpenDevice_(@"trackdisk.device",drivenumber,iorequest,0) ; we open the device, for diskdrives it is the
; trackdisk.device, the unitnumber is also used
; and also the address of our iorequest
If res=0 ; 0 means that all went fine and the device is open
CloseDevice_(iorequest) ; close the opened device
ProcedureReturn -1 ; and we can return -1 (TRUE), the drive is present
Else
ProcedureReturn 0 ; >0 means that the drive is not present, we return a 0
EndIf
FreeMemoryBank(0) ; free our mem, we don't have to do this, PureBasic will do it at program end, but we do
EndProcedure
;example:
OpenExecLibrary_(36)
InitMemoryBank(0)
For z.b=0 To 3
ok.b=ExistDiskDrive(z)
If ok
Print("Diskdrive DF"):PrintNumber(z):PrintN(": is present!")
Else
Print("Diskdrive DF"):Printnumber(z):PrintN(": is not present!")
EndIf
Next z
End
Greetings ..
Roxxler