Mark Goodes wrote: > > I'm using the FILES$<root> command to find a file and return its vrn, like this: > > DO > i=i-1 > checkName$=FILES$(i,"",path$,vrn) > offset=INSTR(1,checkName$,"Closing Futures Prices for") > UNTIL offset>0 OR LEN(INKEY$) OR LEN(checkName$)=0 > > This appeared to work fine at first, until I checked the vrn like this: > > checkName$=FILES$(_fOpen,"",,checkVRN) 'select the same file > PRINT "vrn check: ";vrn,checkVRN > > Then the checkVRN is different than the original vrn. Trouble is, the > original vrn won't work in the CATMOVE routine later on, although the > checkVRN does. Does anyone know how to get the correct vrn in the first > place? TIA. There's a "quirk"--I might dare even call it a "bug"-- in this form of the FILES$ function. When you use the FILES$(_fOpen,...) form or the FILES$(_fSave,...) form, then it returns a working directory reference number for the selected file's folder, just like it's supposed to. But when you use the FILES$(-count,...) form, the volRefNum% parameter returns a _true_ volume reference number. This number stands for the _volume_ that the returned item resides on, but doesn't indicate what _folder_ it's in. It sounds like you have a file's complete pathname, and you want to use that to generate a "volRefNum" (actually a working directory ref. number) that you can use for example in an OPEN statement. You can use the FOLDER function to do this. If path$ is the folder's _complete_ pathname, then you can use this: wdRefNum = FOLDER(path$, 0) to get a working directory ref. num. for the folder (contrary to the doc's, the folder does not need to be "inside the current folder." That's only true if you use a _partial_ path.) While we're talking about the FILES$ and FOLDER functions, note this bug: the FILES$(-count,...) function _breaks_ the FOLDER("",0) function. What I mean is, after you use that form of FILES$ (i.e. with a negative parameter), thereafter FOLDER("",0) will _not_ return the correct ref. number for the current directory--instead, it returns a _volume_ number (specifically, the same volume number that was returned in the FILES$() function). Note that the current directory itself hasn't been changed--you just can't find its number via FOLDER("",0). Fortunately, you can fix this if you subsequently use the FOLDER("", wdRefNum) syntax, which is normally used to change the default directory. Once you've done that, FOLDER("",0) will once again start returning the correct number. The moral: when you use FILES$(-count,...), first save the current directory's number so you can reset it later, like so: currentFolder = FOLDER("", 0) 'Save the current dir's number i = 1 DO f$ = FILES$(-i, "", path$, v) PRINT f$ UNTIL f$ = "" dummy = FOLDER("", currentFolder) 'Fix the harm that FILES$ did. - Rick