// ---------------------------------------- // Program to print out random 'fortunes' // // The fortunes are stored in a simple // sequential file. A random access file // would be faster, but the record size // would have to be large enough to handle // the occasional long fortune; this would // waste a lot of disk space. // ---------------------------------------- // We want a different fortune each time, so... RANDOMISE // Open the database and count the fortunes OPEN FILE 1, "Cookie jar", READ count := 0 WHILE NOT EOF 1 DO count := count + 1 READ file 1:fortune$, source$ ENDWHILE CLOSE FILE 1 // Pick a random fortune record := RND count // Read the fortune OPEN FILE 1, "Cookie jar", READ FOR i := 1 TO record DO READ FILE 1 : fortune$, source$ CLOSE FILE 1 // Finally, print out the fortune. CLS PRINT "The Oracle says:" PRINT "----------------"' PRINT fortune$ PRINT PRINT " -- "; source$