home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / vrac / odoors50.zip / EX_VOTE1.C < prev    next >
C/C++ Source or Header  |  1994-09-24  |  8KB  |  139 lines

  1. /* EX_VOTE1.C - The files ex_vote1.c thru ex_vote5.c demonstrate the         */
  2. /*              possible steps in the development of a door program using    */
  3. /*              OpenDoors. The EZVote door program allows users to create    */
  4. /*              questions or surveys for other users to respond to. Users    */
  5. /*              are also able to view the results of voting on each topic    */
  6. /*              after having voted on the topic themselves.                  */
  7. /*                                                                           */
  8. /*              To recompile this program, follow the instructions in the    */
  9. /*              OpenDoors manual. Be sure to set your compiler to use the    */
  10. /*              large memory model, and add the ODOORL.LIB file to your      */
  11. /*              project/makefile.                                            */
  12. /*                                                                           */
  13. /*              Each of the ex_vote?.c files shows a further incremental     */
  14. /*              step in the construction of the EZVote door program, as      */
  15. /*              follows:                                                     */
  16. /*                                                                           */
  17. /*              EX_VOTE1.C - Demonstrates the basic elements of any door     */
  18. /*                           program. Contains the code to handle display    */
  19. /*                           of main menu, responding to the user's choice   */
  20. /*                           from the main menu, and common commands such    */
  21. /*                           as returning to the BBS and paging the system   */
  22. /*                           operator. Demonstrates basics of displaying     */
  23. /*                           text and retrieving input from user.            */
  24. /*                                                                           */
  25. /*              EX_VOTE2.C - Adds the user interface code to handle the main */
  26. /*                           menu commands specific to EZVote, such as       */
  27. /*                           answering questions, viewing the results of     */
  28. /*                           questions, and adding new questions.            */
  29. /*                           Demonstrates the use of OpenDoors functions     */
  30. /*                           such as od_input_str() for allowing the user to */
  31. /*                           input a sring of characters, and od_get_key()   */
  32. /*                           for inputting any character from the user. Also */
  33. /*                           introduces the od_control structure for         */
  34. /*                           obtaining information about the user and the    */
  35. /*                           system that the door program is running on.     */
  36. /*                                                                           */
  37. /*              EX_VOTE3.C - Adds the underlying file access functionality   */
  38. /*                           that is specific to EZVote. EZVote uses a       */
  39. /*                           relatively complex file structure in order to   */
  40. /*                           track which questions each user has voted on,   */
  41. /*                           and in order to allow a large number (200)      */
  42. /*                           question records to be stored in the file.      */
  43. /*                                                                           */
  44. /*              EX_VOTE4.C - Adds color to display and demonstrates the use  */
  45. /*                           of ANSI/AVATAR/RIP specific features.           */
  46. /*                                                                           */
  47. /*              EX_VOTE5.C - Adds support for the OpenDoors configuration    */
  48. /*                           file system, which provides automatic support   */
  49. /*                           for a wide variety of configurable options.     */
  50. /*                           EZVote adds its own configuration options to    */
  51. /*                           control program characteristics such as whether */
  52. /*                           or not the user is premitted to create their    */
  53. /*                           own questions. Also adds support for the        */
  54. /*                           OpenDoors log file system which records major   */
  55. /*                           actions taken by the user. In addition, this    */
  56. /*                           step enables the OpenDoors multiple-personality */
  57. /*                           system and adds other finishing touches.        */
  58.  
  59.  
  60. /* Include the OpenDoors header file. This line must be done in any program */
  61. /* using OpenDoors.                                                         */
  62. #include "opendoor.h"
  63.  
  64.  
  65. /* main() function - Program execution begins here. */
  66. main()
  67. {
  68.    /* Variable to store user's choice from the menu */
  69.    char chMenuChoice;
  70.    char chYesOrNo;
  71.  
  72.    /* Loop until the user choses to exit the door. For each iteration of  */
  73.    /* this loop, we display the main menu, get the user's choice from the */
  74.    /* menu, and perform the appropriate action for their choice.          */
  75.  
  76.    for(;;)
  77.    {
  78.       /* Clear the screen */
  79.       od_clr_scr();
  80.  
  81.       /* Display main menu */
  82.       od_printf("                     EZVote - OpenDoors 5.00 demonstration Door\n\r");
  83.       od_printf("-------------------------------------------------------------------------------\n\r\n\r\n\r");
  84.       od_printf("                        [V] Vote on a question\n\r\n\r");
  85.       od_printf("                        [R] View the results of question\n\r\n\r");
  86.       od_printf("                        [A] Add a new question\n\r\n\r");
  87.       od_printf("                        [P] Page system operator for chat\n\r\n\r");
  88.       od_printf("                        [E] Exit door and return to the BBS\n\r\n\r");
  89.       od_printf("                        [H] End call (hangup)\n\r\n\r\n\r");
  90.       od_printf("Press the key corresponding to the option of your choice.\n\r");
  91.  
  92.       /* Get the user's choice from the main menu. This choice may only be */
  93.       /* V, R, A, P, E or H.                                               */
  94.       chMenuChoice = od_get_answer("VRAPEH");
  95.  
  96.       /* Perform the appropriate action based on the user's choice */
  97.       switch(chMenuChoice)
  98.       {
  99.          case 'P':
  100.             /* If the user pressed P, allow them page the system operator. */
  101.             od_page();
  102.             break;
  103.  
  104.          case 'E':
  105.             /* If the user pressed E, exit door and return to BBS. */
  106.             od_exit(0, FALSE);
  107.             break;
  108.  
  109.          case 'H':
  110.             /* If the user pressed H, ask whether they wish to hangup. */
  111.             od_printf("\n\rAre you sure you wish to hangup? (Y/N) ");
  112.  
  113.             /* Get user's response */
  114.             chYesOrNo = od_get_answer("YN");
  115.  
  116.             /* If user answered yes, exit door and hangup */
  117.             if(chYesOrNo == 'Y')
  118.             {
  119.                od_exit(0, TRUE);
  120.             }
  121.             break;
  122.  
  123.          default:
  124.             /* If the user made any other choice from the menu, then it was */
  125.             /* a choice which we don't yet support. */
  126.  
  127.             /* Display a notification message. */
  128.             od_printf("This feature isn't finished in this version of EZVote.\n\r");
  129.             od_printf("(See one of the later versions included in your OpenDoors package.)\n\r\n\r");
  130.             od_printf("Press any key to continue.\n\r");
  131.  
  132.             /* Wait for the user to press a key to continue. */
  133.             od_get_key(TRUE);
  134.       }
  135.    }
  136.    
  137.    return(0);
  138. }
  139.