1997.03.17 COOKIE 2.43 Default file: c:\toolbox\cookies\cookie.jar Selected file: c:\toolbox\cookies\cookie.jar Usage: cookie [options] (not case sensitive) ? -? or -h help -d show debugging info -ffilename select cookiejar -q quick cookie -c create index file -i use index file n show cookie #n; one only! Example, assuming that all files are in the current directory: cookie -fcookie.jar -i Traditionally, this is how a cookie is selected: First, cookie #1 is named The Cookie. Then, using a random number generator, cookie #2 is given a 1/2 chance of replacing The Cookie. And so on, with cookie #n having a 1/n chance of becoming The Cookie. If you do the math, you find that all cookies have an equal chance to be The Cookie! After all cookies have been read, The Cookie is printed. The problem with the traditional method is that the entire file must be read, which could take a long time if the file is large or the system is slow. A quick cookie is quicker because the program simply jumps to a random offset in the cookiejar to select a cookie, rather than examining all of them in the traditional fashion. Unfortunately, longer cookies then have a higher probability of being selected. The quickest method is to use the -c switch to create an index file for your cookie file whenever you add cookies; then use -i when fetching a cookie. This tells the program to jump to a random offset in the index file, in which each cookie is represented by a 32 bit address, so their probabilities are once again equal. Instead of specifying an alternate file using -f, you can simply stuff the full filename into the environment variable COOKIEJAR. You may still override this environment variable by using the -f. The CookieJar is a simple ASCII textfile. Each line is a fortune cookie, but if a cookie requires more than one line, put a '+' in column one of each continuation line. Any lines with a '#' in column one are comments. The following special codes may also be embedded in the fortunes: $$ = dollar sign $B = beep $D = current date $M = current month $T = current time $W = current day of the week $Y = current year