home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / TRSICAT.LZX / CATS_CD2_TRSI / Reference_Library / lib_examples / easyrequest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-21  |  2.2 KB  |  83 lines

  1. ;/* easyrequest.c - Execute me to compile me with SAS C 5.10
  2. LC -b1 -cfistq -v -y -j73 easyrequest.c
  3. Blink FROM LIB:c.o,easyrequest.o TO easyrequest LIBRARY LIB:LC.lib,LIB:Amiga.lib
  4. quit
  5.  
  6. ** easyrequest.c - show the use of an easy requester.
  7. */
  8. #define INTUI_V36_NAMES_ONLY
  9.  
  10. #include <exec/types.h>
  11. #include <intuition/intuition.h>
  12.  
  13. #include <clib/exec_protos.h>
  14. #include <clib/intuition_protos.h>
  15.  
  16. #include <stdio.h>
  17.  
  18. #ifdef LATTICE
  19. int CXBRK(void)    { return(0); }  /* Disable Lattice CTRL/C handling */
  20. int chkabort(void) { return(0); }  /* really */
  21. #endif
  22.  
  23. /* declare the easy request structure.
  24. ** this uses many features of EasyRequest(), including:
  25. **     multiple lines of body text separated by '\n'.
  26. **     variable substitution of a string (%s) in the body text.
  27. **     multiple button gadgets separated by '|'.
  28. **     variable substitution in a gadget (long decimal '%ld').
  29. */
  30. struct EasyStruct myES =
  31.     {
  32.     sizeof(struct EasyStruct),
  33.     0,
  34.     "Request Window Name",
  35.     "Text for the request\nSecond line of %s text\nThird line of text for the request",
  36.     "Yes|%ld|No",
  37.     };
  38.  
  39. struct Library *IntuitionBase;
  40.  
  41. /*
  42. ** Main routine to show the use of EasyRequest()
  43. */
  44. VOID main (int argc, char **argv)
  45. {
  46. LONG answer;
  47. LONG number;
  48.  
  49. number = 3125794;  /* for use in the middle button */
  50.  
  51. if (IntuitionBase = OpenLibrary("intuition.library",37))
  52.     {
  53.     /* note in the variable substitution:
  54.     **     the string goes in the first open variable (in body text).
  55.     **     the number goes in the second open (gadget text).
  56.     */
  57.     answer = EasyRequest(NULL, &myES, NULL, "(Variable)", number);
  58.  
  59.     /* Process the answer.  Note that the buttons are numbered in
  60.     ** a strange order.  This is because the rightmost button is
  61.     ** always a negative reply.  The code can use this if it chooses,
  62.     ** with a construct like:
  63.     **
  64.     **     if (EasyRequest())
  65.     **          positive_response();
  66.     */
  67.     switch (answer)
  68.         {
  69.         case 1:
  70.             printf("selected 'Yes'\n");
  71.             break;
  72.         case 2:
  73.             printf("selected '%ld'\n", number);
  74.             break;
  75.         case 0:
  76.             printf("selected 'No'\n");
  77.             break;
  78.         }
  79.  
  80.     CloseLibrary(IntuitionBase);
  81.     }
  82. }
  83.