FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

DISK I/O

Initialise disk


Can someone tell me what's wrong with this code...
I'm trying to initialize a disk from my app.

FJ II (the 'ScanVolumes' function), tells me that my mounted diskette has a Vref of -3. When i pass -3 to FN DIBADMOUNT, i always get an error -56.

Note: in InsideMac, this equivalent error is 56 (positive) and FB returns a negative error (-56).
'---------------------------------
COMPILE 0, _dimmedVarsOnly
DIM Pnt.4
DIM Err%
END GLOBALS

LOCAL FN MyDILoad
  ` MOVE.W #$0002,-(sp)
  ` DC.W $A9E9
END FN

LOCAL FN MyDIUnload
  ` MOVE.W #$0004,-(sp)
  ` DC.W $A9E9
END FN

WINDOW 1
FN MyDILoad
CALL SETPT(Pnt, 120, 120)
Err% = FN DIBADMOUNT (Pnt, -3)
IF Err% <> 0 THEN PRINT Err%
FN MyDIUnload

DO
  HANDLEEVENTS
UNTIL 0
'---------------------------------
Sylvain

You are passing a volume reference number, but DIBADMOUNT wants a drive number. They are two different things.

The volume reference number is always negative, and is assigned to the volume at the time it is mounted (essentially, at the time its icon shows up on your desktop). Theoretically, if you have a bank of floppy drives (or CD drives, etc.) you could move a single volume (disk) from one drive to another and have it recognized as the same volume (with the same vol. ref. number) regardless of which drive it's in (actually, this will only work if you eject the volume without "unmounting" it). The vol. ref. number is meant to stand for the "logical" volume of data, regardless of its physical location.

The drive number is always positive, and is assigned to the drive as soon as the system recognizes that the drive is connected to the machine (usually at startup time). The drive number is valid even when there's no volume in the drive. The drive number is meant to stand for the physical device, regardless of what volume (if any) is inside it.

Rick

Problem solved.
This function will return the drive number pointed to by a VRefNum:
'---------------------------------------
COMPILE 0, _dimmedVarsOnly

DIM DriveNum%
END GLOBALS

CLEAR LOCAL MODE
LOCAL FN GetDriveNum(VRef%)
  DIM PBlock.200
  DIM OsErr%, DriveNum%
  DriveNum% = 0
  PBlock.ioVRefNum% = VRef%
  OsErr% = FN HGETVINFO(@PBlock)
  IF OsErr% = 0 THEN DriveNum% = PBlock.ioVDrvInfo
END FN = DriveNum%

WINDOW 1
DriveNum% = FN GetDriveNum(-2)                    '-1, -2, -3, etc.
IF DriveNum% = 0 THEN PRINT "Error" ELSE PRINT DriveNum%

DO
  HANDLEEVENTS
UNTIL 0
Sylvain