I've heard mention of a mysterious FILES$<index> bug. Perhaps the following
will help track it down...
Alternatively, does anyone know an alternative to FILES$<index> for getting
a list of files in a folder?
The following code as an INCL file if used within a project created with
Program Generator, dies with the message "A critical error has occurred...
String Stack Underflow" when it reaches the END FN in FN FilesTester.
Oddly, it works the first time when in a non-Program Generator FB^3 project,
but the second time it is called you get the same error, this time at the
END FN of FN GetDirPath$. Spooky.
FB^3 and Program Generator are both straight off the CD (Release 1.4). It
happens on a PPC 7200 and on an iMac.
REMing out the fileName$ = FILES$(-1... statement prevents the error.
==========
defint a-z
CLEAR LOCAL MODE: DEFINT a-z
DIM pBlock.128
DIM 63 dirName$
DIM 255 pathName$
DIM osErr
LOCAL FN GetDirPath$ (filename$,volref)
pathName$ = filename$
IF volref=0 THEN EXIT FN
pBlock.ioNamePtr& = @dirName$'put pointer to dirName$
pBlock.ioVRefNum% = volref'set vRefNun
pBlock.ioDrParID& = [_curDirStore]'get currect directory ID
pBlock.ioFDirIndex% = -1'get info on folder
DO
osErr% = FN GETCATINFO (@pBlock)'get catalog info
LONG IF osErr% = _noErr'no error then...
LONG IF LEN(pathName$)+LEN(dirName$)>254
pathName$ = ""
EXIT FN
XELSE
pathName$ = dirName$ + ":" + pathName$'add dirName to path
pBlock.ioDrDirID& = pBlock.ioDrParID&'get folder's parent ID
END IF
XELSE
pathName$ = ""
EXIT FN
END IF
UNTIL pBlock.ioDirID& = _fsRtParID'volume root ID
END FN = pathName$'will end in ":" if folders only
local mode: defint a-z
dim oldDefault%,dummy%,index%
dim @ volref
dim 31 fileName$,255 path$
LOCAL FN FilesTester
fileName$ = FILES$(_fOpen,"TEXT",,volref)
if fileName$="" then exit fn
path$ = FN GetDirPath$ ("",volref)
call debugstr(path$)
fileName$ = FILES$(-1,,path$,volref)
call debugstr(fileName$)
END FN
==========
--
Robin
====================================================
Genesearch Pty Ltd
E-mail: robinc@...
WWW: http://www.genesearch.com.au
====================================================