
/*************************************************/
/*          Fortune Cookie Program V2            */
/*    by John Kennedy for Amiga Computing        */
/*       Written under Lattice C v 5.2           */
/*         Compile with lc -L option             */
/* NB this program needs to write a teensy-weeny */
/* file on your boot-up disc, so please let it.  */
/*************************************************/

#include <exec/types.h>
#include <stdlib.h>
#include <stdio.h>

void main(argc)
int argc;
{
        FILE *fp;
        int number;

        if (argc!=1) {
                /* Print a welcome message if a parameter present */
                printf("\nCookie V2.0\n");
                printf("Written by John Kennedy, March 1990.\n");
                printf("Run this program early on from your\n");
                printf("startup-sequence for a deep and meaningful\n");
                printf("piece of advice to start your day with.\n");
                printf("Try redirecting it to your Speech device.\n");
                exit(0);
        }


if ((fp=fopen("cookie.file","r+"))==NULL)
        {       /* File does not exist, so create it */
                fp=fopen("cookie.file","w+");
                number=0;
                fprintf(fp,"%d",number);
                fclose(fp);
        }
        else
        {
                /* File does exist, so get number from it */
                fscanf(fp,"%d",&number);
                number++;
                if (number==32) number=0;
                rewind(fp);
                fprintf(fp,"%d",number);
                fclose(fp);
        }



        printf("\nThought for the day:\n");

        switch (number) {
        case 0:printf("\n\nFortune Cookie\nWritten by Aj in 1990\n\n'There ain't no dark side of the moon.'\n");break;
        case 1:printf("Meanwhile in Czechoslovakia...");break;
        case 2:printf("Whoops. Sorry about that, just re-formatted your drive.");break;
        case 3:printf("Live long and prosper, Earthling.");break;
        case 4:printf("Remember - it's all just plop.");break;
        case 5:printf("Don't worry, just blame it on Jeff.");break;
        case 6:printf("Beware of the flowers.");break;
        case 7:printf("You're never alone with a stone.");break;
        case 8:printf("Aren't you glad you don't have an ST.");break;
        case 9:printf("It could be worse - you could be bald. Oops, sorry Green.");break;
        case 10:printf("Oh no - I've just put some sugar in my Bovril.");break;
        case 11:printf("I was born under a wandering star.");break;
        case 12:printf("It must be a Thursday - I never could get the hang of Thursdays...");break;
        case 13:printf("Where is the nearest bar that sells Guinness?");break;
        case 14:printf("That was some party. Now what can I do for you?");break;
        case 15:printf("Now is this Wednesday or Thursday?");break;
        case 16:printf("Do not despise the snake because he has no horns, for who may say he will not turn into a dragon?");break;
        case 17:printf("Old programmers never die, they just branch to a new address.");break;
        case 18:printf("Hiya handsome? Watcha doin' after work?");break;
        case 19:printf("Of all the keyboards in all the world, you had to use mine.");break;
        case 20:printf("Do the Shake-and-Vac and put the freshness back.");break;
        case 21:printf("Moon Cresta? Moon-cresta? MOONCRESTA?");break;
        case 22:printf("Smoking is bad for you.");break;
        case 23:printf("Amiga Computing, the only Amiga magazine worth reading.");break;
        case 24:printf("Why is Green so stupid?");break;
        case 25:printf("Is that the phone ringing?");break;
        case 26:printf("Sorry - can't boot CP/M+ on this system.");break;
        case 27:printf("Stop biting your nails.");break;
        case 28:printf("I'm bored - do something interesting.");break;
        case 29:printf("Ok, Ploppypants - what's the news?");break;
        case 30:printf("Well I never! I thought I recognised you! What a coincidence!");break;
        case 31:printf("Uh-oh. Think I have heartburn.");break;
        default:;
        }
        printf("\n\n");
}
