This is off the top of my head, but should work fine:
set dir "directory"
perform checklist for files
if checklist quantity()>=3
randomize perftimer()
filename$=checklist string$(2+int(rnd(checklist quantity()-2)))
` load media
endif
EDIT:
Probably be better I add how it works:
perform checklist for files will get a list of all files, currently in the directory specified by
set dir
checklist quantity will then return how many files there are in said directory, plus 2.
1: Current directory
2: Parent directory
3: File number 1
4: File number 2
and so on
if checklist quantity()>=3 just checks that the number DB see's is bigger than (or equal to) 3 (or 1 or more
real files exist). If it does, it executes;
randomize perftimer() sets the random seed, to make it all random.
timer() is usually used, and is fine, but
perftimer() is more accurate.
filename$ is then assigned a filename, based on checklist quantity.
2+int(rnd(checklist quantity()-2)) works, by taking checklist quantity(), and subtracting 2 (to find the number of
real files, picking a random number, making it int, and adding 2 (to put back into DB).
Then, you need to write your own code to load the filename.
You could infact tidy the code, and put it in a function:
function FindRandomFile(directory$)
filename$=""
set dir directory$
perform checklist for files
if checklist quantity()>=3
randomize perftimer()
filename$=checklist string$(2+int(rnd(checklist quantity()-2)))
endif
endfunction filename$