repeated use of Files object

new BookmarkLockedFalling
colinmac
Junior Member
**

colinmac Avatar

Posts: 58

Post by colinmac on Oct 26, 2007 19:51:04 GMT -5

Is there any limit on the number of times a files object can be used? Alternatively, is there a way to close one prior to re-use?

The code below attempts to read details of project files, using the #rbbas files object in a loop, once for each project directory. whatever I do I cannot get beyond seven files, getting the error message

Runtime Error: print #rbbas name$(); " last used " ; #rbbas date$(); " at "; #rbbas time$()
SubscriptOutOfBoundsError


Any help would be appreciated.

' file finder
files #rbdir, "c:\rbp\*"
for x = 1 to #rbdir rowcount()
#rbdir nextfile$()
if #rbdir isdir() then
dir$ = #rbdir name$()
bas$ = left$(dir,ドル len(dir$)-8 )
basfile$ = dir$ +"\" + bas$ + ".bas"
files #rbbas, basfile$
#rbbas nextfile$()
print #rbbas name$(); " last used " ; #rbbas date$(); " at "; #rbbas time$()
end if
next x
wait


Colin
carlgundel
Administrator
*****
Creator of Run BASIC

carlgundel Avatar

Posts: 975

Post by carlgundel on Oct 26, 2007 21:38:17 GMT -5

colinmac said:
Is there any limit on the number of times a files object can be used? Alternatively, is there a way to close one prior to re-use?

The code below attempts to read details of project files, using the #rbbas files object in a loop, once for each project directory. whatever I do I cannot get beyond seven files, getting the error message

Colin,

The trouble is that not all the subdirectories have *.bas files in them. You need to test the #rbbas object to see if it has any results before you try to read the answer, like so:
files #rbbas, basfile$
if #rbbas hasanswer() then
#rbbas nextfile$()
print #rbbas name$(); " last used " ; #rbbas date$(); " at "; #rbbas time$()
end if

In addition, it looks to me like the error condition should have been indicated at #rbbas nextfile$() line instead of the one after so that's something for me to look into.

-Carl