/* * Dialog * ------ * This program creates several dialog boxes one after the other. * It demonstrates the use of dialog functions and their return * values. * * The dialog box functions either return a number indicating * which button the user pressed, or a string if the function * is designed to ask the user for a string or a filename. * * For those dialogs which return a number, the value can be * 1 if the user clicks the "OK" button or "Yes" button, * 0 if the user clicks on the "No" button, and -1 if the user * presses the "Cancel" button. * * For those dialogs which return a string, the return value * will be NULL if the user hits the "Cancel" button. */ #include void main(void) { char *name; int result; askok("Just testing"); name = askstring("What is your name?", "Type it here"); printf("Hello, %s\n", name); result = askokcancel("Destroy the world!"); if (result == YES) printf("Destroying the world....\n"); else if (result == CANCEL) printf("I'll destroy the world later.\n"); result = askyesno("Would you like to play a game?"); if (result == YES) printf("All right!\n"); else if (result == NO) printf("Boring person.\n"); result = askyesnocancel("Would you like to play Thermonuclear War?"); switch (result) { case YES: printf("BOOM!\n"); break; case NO: printf("How about chess?\n"); break; case CANCEL: printf("Cancelled.\n"); break; } }