>>I was asked for help with a toy project - read in a plaintext file and return a random line from the file. I could do this easily with a table, but don't know enough about low level file functions to do that job easily. Can I get a kick in the right direction, please?
>>
>>Chris.
>
>Just a quick thought (ie not completly thought through)
>
>How about this:
>
>RAND()
>lcText = FILETOSTR("myFile.txt")
>ALINES(myText, lcText)
>?myText[RAND()*ALEN(myText)]
Almost there - except that it may hit the zero line in a one-based array, so I'd rather put the last line as
?myText[int(RAND()*ALEN(myText))+1]