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

User DirID to get vRefNum for OPEN statement


Well, you have a couple of choices, both of which require you to know not only the directory's ID number, but also the volume reference number of the volume (not to be confused with a working dir. ref. num., of course).
The first way is to feed these two numbers into the Toolbox function OPENWD, which will then give you back a working directory reference number that you can use in the OPEN statement. We can give you sample code for that if want to use this method.
The second way I personally prefer: You can use the PARENTID statement in combination with OPEN, and forget about working directory ref. numbers. If volume% is the volume's reference number, and dirID& is the directory ID, then you can open a file in that directory as follows:

PARENTID = dirID&
OPEN "I", #1, filename$, reclen, volume%

(Note that the PARENTID value seems to reset to zero again after you do the OPEN, so if you're doing this a lot, you'll have to execute PARENTID before each OPEN).

Rick