home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 402.lha / kd_freq.library_v2.00 / Programming / manx.ext.test.c < prev    next >
C/C++ Source or Header  |  1990-07-26  |  3KB  |  96 lines

  1.  
  2. /*
  3.  *  kd_freq.library Extended Select Test
  4.  *
  5.  *  Tested on Manx 3.60a.
  6.  */
  7.  
  8. #include "KDBase.h"
  9.  
  10. UBYTE directory[128];
  11. UBYTE filename[32];
  12. UBYTE pattern[32];
  13.  
  14. /* for Manx.. we don't need any parsing */
  15. void  _wb_parse() {}
  16. void _cli_parse() {}
  17.  
  18. struct Library *KD_FReqBase, *OpenLibrary();
  19.  
  20. struct ExtraData extras;
  21.  
  22. main()
  23.     {
  24.     register struct FileList *ext;
  25.  
  26.     KD_FReqBase = OpenLibrary(KLIBNAME,KLIBVERSION);
  27.  
  28.     if (KD_FReqBase) 
  29.         {
  30.         /* Make sure that all default strings are zero'd out. */
  31.         directory[0] = filename[0] = pattern[0] = 0;
  32.  
  33.         /* Set default wildcard pattern */
  34.         /* strcpy(pattern,"#?.?"); */
  35.  
  36.         /* Call file requester */
  37.  
  38.         extras.oktext     = (UBYTE *) "Load";
  39.         extras.canceltext = (UBYTE *) "No Way!";
  40.  
  41.         if (FReq(NULL,
  42.             "Extended Select Test",
  43.             filename,directory,pattern, FR_CANCELTEXT | FR_EXTENDEDSELECT |
  44.             FR_OKTEXT | FR_AUTOPOSITION | FR_AUTOSIZE | FR_NOINFO | FR_SCREENFONT
  45.             ,&extras))
  46.             {    
  47.             /* You can immediately strcat(directory,filename); since
  48.                 directory will contain the valid file seperator (either
  49.                 / or : at the end of the directory name
  50.             */
  51.  
  52.             printf("Directory: %s\nFile     : %s\n",directory,filename);
  53.  
  54.             if (extras.ExtendedList)    /* Check if the user selected a */
  55.                 {                        /* list of files. */
  56.                 ext = extras.ExtendedList;
  57.  
  58.                 printf("\nExtended Select List:  (%ld bytes)\n\n",ext->private);
  59.                 printf("    Size  File Name\n");
  60.                 printf(" -------  -----------------------------------------\n");
  61.  
  62.                 /* This just prints out the selected files and their size. */
  63.                 for (; ext; ext = ext->next)
  64.                     {
  65.                     printf("%8ld  %s%s\n",ext->FileSize,directory,ext->FileName);
  66.                     } 
  67.  
  68.                 /* VERY IMPORTANT!!  YOU MUST HAVE THIS IN! */
  69.                 /* If the call returned a pointer to an ExtendedList */
  70.                 /* then you must free it before you exit with the following */
  71.                 /* FreeMem() call. */
  72.                 /* You can also just leave the extras.ExtendedList pointer */
  73.                 /* in the extras struct when you call FReq() again.  Freq() */
  74.                 /* In this case will FreeMem() the list for you and give you */
  75.                 /* a new one if need be. */
  76.                 FreeMem(extras.ExtendedList,extras.ExtendedList->private);
  77.  
  78.                 /* Clear out list pointer so that a subsequent call to FReq() */
  79.                 /* doesn't try to FreeMem() it. */
  80.                 extras.ExtendedList = NULL;
  81.  
  82.                 }    
  83.             }
  84.         else
  85.             {
  86.             printf("Requester Cancelled!\n");
  87.             }
  88.  
  89.         CloseLibrary(KD_FReqBase);
  90.             }
  91.      else 
  92.         {
  93.         printf("Can't Open 'kd_freq.library'.  Make sure it is in LIBS:\n");
  94.         }
  95.     }
  96.