home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 511.lha / kd_freq.library_v3.00 / Programming / test.c < prev   
C/C++ Source or Header  |  1991-06-07  |  2KB  |  85 lines

  1. /*
  2.  *  kd_freq.library NewFR() Test
  3.  *
  4.  *  This demonstrates the use of CreateFRequest(), DeleteFRequest() and
  5.  *  NewFReq() for a minimum of fuss in allocating stuff for the FR.
  6.  *
  7.  *  Note the use of  NextSelectEntry() to check the select list.
  8.  *
  9.  *  You need to assemble and link  glue.asm with this, or use the
  10.  *  appropriate #pragmas!
  11.  *
  12.  */
  13.  
  14.  
  15. #include "KDBase.h"
  16.  
  17. struct Library *KD_FReqBase, *OpenLibrary();
  18.  
  19. main()
  20. {
  21. struct FRequest *fr, *CreateFRequest();
  22. char *file, *NewFReq();
  23. UBYTE *entry, *NextSelectEntry();
  24.  
  25. if (KD_FReqBase = OpenLibrary(KLIBNAME,KLIBVERSION))
  26.     {
  27.     if (fr = (struct FRequest *) CreateFRequest())
  28.         {
  29.         /* Set the requester title */
  30.         fr->reqtitle = (UBYTE *) "FR Test";
  31.  
  32.         /* already set by CreateFRequest() */
  33.         fr->flags = FR_STDFLAGS | FR_SELECTLIST;
  34.  
  35.         /* Set the default show and hide wildcards */
  36.         /*    strcpy(fr->pattern,"#?.?"); */
  37.         /*    strcpy(fr->extras->Hide,"#?.o"); */
  38.  
  39.  
  40.         /* Call the file requester and get a file name */
  41.  
  42.         if (file = (char *)NewFReq(fr))    
  43.             printf("Selected: %s\n\n",file);
  44.         else
  45.             printf("Cancelled.\n\n");
  46.         
  47.         /* Show some of the stuff we got back from the call */
  48.  
  49.         printf("Path    : %s\n",fr->fullname);
  50.         printf("Title   : %s\n",fr->reqtitle);
  51.         printf("Dir     : %s\n",fr->directory);
  52.         printf("File    : %s\n",fr->filename);
  53.         printf("Show Pat: %s\n",fr->pattern);
  54.         printf("Hide Pat: %s\n",fr->extras->Hide);
  55.         printf("Position: %3d , %3d\n",fr->extras->LeftEdge,fr->extras->TopEdge);
  56.         printf("Size    : %3d x %3d\n",fr->extras->Width,fr->extras->Height);
  57.  
  58.  
  59.         /* Check if the user selected multiple files */
  60.         
  61.         if (fr->extras->SelectList)    
  62.             {
  63.             /* ok.. print them out */
  64.             printf("\nSelect List:\n\n");
  65.  
  66.             while (entry = NextSelectEntry(fr))
  67.                 {
  68.                 printf("%s\n",entry);
  69.                 }
  70.             }
  71.  
  72.  
  73.         /* Don't do this unless you're done with the FRequest struct */
  74.  
  75.         DeleteFRequest(fr);
  76.         }
  77.  
  78.     CloseLibrary(KD_FReqBase);
  79.     }
  80. else
  81.     {
  82.     printf("Can't Open 'kd_freq.library'.  Make sure it is in LIBS:\n");
  83.     }
  84. }
  85.