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

List all files in a folder


The easiest way is to use the FILES$(-index...) function. The little FN below returns the name of the "nth" item.

LOCAL FN nthItem$(wdRefNum%, n)
  DIM oldDefault%, v%, item$, dummy%
'Save current default:
  oldDefault% = FOLDER("", 0)
'Temporarily change default:
  dummy% = FOLDER("", wdRefNum%)
  item$ = FILES$(-n,"",":",v%)
'Restore old default:
  dummy% = FOLDER("", oldDefault%)
END FN = item$

When the FILES$(-index...) function returns the name of a folder, it always appends a colon to the end of the name. The colon is not really part of the folder's name; it's just a device that FB uses to let you know it's a folder.

You can call FN GETCATINFO:

DIM pb.108
  pb.ioCompletion& = _nil
  pb.ioNamePtr& = @filename$
  pb.ioVRefNum% = VolRefNum%
  pb.ioDirID& = 0
  pb.ioFDirIndex% = 0
  OSErr% = FN GETCATINFO(@pb)
  LONG IF OSErr% = _noErr
    theType& = pb.ioFlFndrInfo.fdType&
    theCreator& = pb.ioFlFndrInfo.fdCreator&
END IF

And actually, there's a way you can do all 3 with a single call to FN GETCATINFO, but it's a few extra lines (but probably executes faster). I'll leave it at this, though, since I don't know the context of whatyou're trying to do.

Rick