home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / edit / edutils / panel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-07  |  4.5 KB  |  138 lines

  1.  
  2. #include   <edutils.h>
  3. #include   <io.h>
  4. #include   <conio.h>
  5.  
  6. typedef struct CUST_INFO
  7. {
  8.     char last_name [21];
  9.     char middle_initial [2];
  10.     char first_name [21];
  11.     char address_1 [26];
  12.     char address_2 [26];
  13.     char city [21];
  14.     char state [3];
  15.     char zip_code [10];
  16. } CUST_INFO;
  17.  
  18.   /* INTERNAL Variables */
  19. ED_PARMS   parms;
  20. char       filename [100];
  21. CUST_INFO  customer;
  22.  
  23.  
  24. void main (void)
  25. {
  26.     char  CH;
  27.  
  28.     printf ("\n");
  29.     printf ("PANEL Version 1.0\n");
  30.     printf ("(c) Copyright 1994  Kenneth J. Macke\n");
  31.     printf ("\n");
  32.     printf ("Press any key to continue...\n");
  33.     CH = getch ();
  34.     if (CH == 0)
  35.         CH = getch ();
  36.  
  37.     clrscr ();
  38.     textcolor (WHITE);
  39.     textbackground (BLUE);
  40.     window (10, 5, 70, 20);
  41.     clrscr ();
  42.     window (5, 22, 75, 24);
  43.     clrscr ();
  44.     window (1, 1, 80, 25);
  45.     gotoxy (7, 23);
  46.     cprintf ("Use UP, DOWN, TAB, & ENTER to select fields. ESC when done.");
  47.  
  48.     memset (&customer, 0, sizeof (customer));
  49.  
  50.     gotoxy (12, 6);
  51.     cprintf ("Last Name");
  52.     gotoxy (34, 6);
  53.     cprintf ("MI");
  54.     gotoxy (37, 6);
  55.     cprintf ("First Name");
  56.  
  57.     gotoxy (12, 9);
  58.     cprintf ("Address:");
  59.     gotoxy (12, 11);
  60.     cprintf ("City:");
  61.     gotoxy (43, 11);
  62.     cprintf ("State:");
  63.     gotoxy (12, 12);
  64.     cprintf ("Zip:");
  65.  
  66.         /*  Example of Defaulting strings to be edited  */
  67.     strcpy (customer.state, "OH");
  68.     strcpy (customer.zip_code, "          ");
  69.  
  70.     textbackground (BROWN);
  71.     textcolor (YELLOW);
  72.  
  73.         /*  Display the field edit windows and defaults  */
  74.     ed_display_string_xy (12, 7,  customer.last_name, 21, 20);
  75.     ed_display_string_xy (34, 7,  customer.middle_initial, 2, 1);
  76.     ed_display_string_xy (37, 7,  customer.first_name, 21, 20);
  77.     ed_display_string_xy (21, 9,  customer.address_1, 26, 25);
  78.     ed_display_string_xy (21, 10, customer.address_2, 26, 25);
  79.     ed_display_string_xy (21, 11, customer.city, 21, 20);
  80.     ed_display_string_xy (50, 11, customer.state, 3, 2);
  81.     ed_display_string_xy (21, 12, customer.zip_code, 10, 9);
  82.  
  83.        /*  Perform editing on the specified fields  */
  84. edit_last_name:
  85.     ed_edit_string_xy (12, 7,  customer.last_name, 21, 20);
  86.     if (ed_results.last_char_extended == UP)   goto edit_last_name;
  87.     if (ed_results.last_char_extended == DOWN) goto edit_address_1;
  88.     if (ed_results.last_char == ESC)           goto done;
  89. edit_middle_initial:
  90.     ed_edit_string_xy (34, 7,  customer.middle_initial, 2, 1);
  91.     if (ed_results.last_char_extended == UP)   goto edit_middle_initial;
  92.     if (ed_results.last_char_extended == DOWN) goto edit_address_1;
  93.     if (ed_results.last_char == ESC)           goto done;
  94. edit_first_name:
  95.     ed_edit_string_xy (37, 7,  customer.first_name, 21, 20);
  96.     if (ed_results.last_char_extended == UP)   goto edit_first_name;
  97.     if (ed_results.last_char == ESC)           goto done;
  98.  
  99. edit_address_1:
  100.     ed_edit_string_xy (21, 9,  customer.address_1, 26, 25);
  101.     if (ed_results.last_char_extended == UP)   goto edit_last_name;
  102.     if (ed_results.last_char == ESC)           goto done;
  103.  
  104. edit_address_2:
  105.     ed_edit_string_xy (21, 10, customer.address_2, 26, 25);
  106.     if (ed_results.last_char_extended == UP)   goto edit_address_1;
  107.     if (ed_results.last_char == ESC)           goto done;
  108.  
  109. edit_city:
  110.     ed_edit_string_xy (21, 11, customer.city, 21, 20);
  111.     if (ed_results.last_char_extended == UP)   goto edit_address_2;
  112.     if (ed_results.last_char_extended == DOWN) goto edit_zip_code;
  113.     if (ed_results.last_char == ESC)           goto done;
  114.  
  115. edit_state:
  116.     ed_edit_string_xy (50, 11, customer.state, 3, 2);
  117.     if (ed_results.last_char_extended == UP)   goto edit_address_2;
  118.     if (ed_results.last_char == ESC)           goto done;
  119.  
  120. edit_zip_code:
  121.     ed_edit_string_xy (21, 12, customer.zip_code, 10, 9);
  122.     if (ed_results.last_char_extended == UP)   goto edit_city;
  123.     if (ed_results.last_char_extended == DOWN) goto edit_zip_code;
  124.     if (ed_results.last_char == TAB_KEY)       goto edit_last_name;
  125.     if (ed_results.last_char == ENTER_KEY)     goto edit_last_name;
  126.  
  127. done:
  128.     textcolor (LIGHTGRAY);
  129.     textbackground (BLACK);
  130.     clrscr ();
  131.     printf ("Name    = '%s %s %s'\n", customer.first_name, customer.middle_initial, customer.last_name);
  132.     printf ("Address = '%s'\n", customer.address_1);
  133.     printf ("          '%s'\n", customer.address_2);
  134.     printf ("          '%s, %s  %s'\n", customer.city, customer.state, customer.zip_code);
  135.  
  136.  
  137. }  /* main */
  138.