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

  1. ;/* filepat.c - Execute me to compile me with SASC 5.10
  2. LC -b1 -cfistq -v -y -j73 filepat.c
  3. Blink FROM LIB:c.o,filepat.o TO filepat LIBRARY LIB:LC.lib,LIB:Amiga.lib
  4. quit
  5. */
  6. #include <exec/types.h>
  7. #include <intuition/intuition.h>
  8. #include <intuition/screens.h>
  9. #include <graphics/displayinfo.h>
  10. #include <libraries/asl.h>
  11. #include <workbench/startup.h>
  12.  
  13. #include <clib/asl_protos.h>
  14. #include <clib/exec_protos.h>
  15. #include <clib/intuition_protos.h>
  16. #include <stdio.h>
  17.  
  18. #ifdef LATTICE
  19. int CXBRK(void)     { return(0); }  /* Disable Lattice CTRL/C handling */
  20. void chkabort(void) { return; }     /* really */
  21. #endif
  22.  
  23. UBYTE *vers = "$VER: filepat 37.0";
  24.  
  25. struct Library *AslBase = NULL;
  26. struct Library *IntuitionBase = NULL;
  27. struct Screen *screen = NULL;
  28. struct Window *window = NULL;
  29.  
  30. void main(int argc, char **argv)
  31. {
  32.     struct FileRequester *fr;
  33.     struct WBArg *frargs;
  34.     int x;
  35.  
  36.     if (AslBase = OpenLibrary("asl.library", 37L))
  37.     {
  38.         if (IntuitionBase = (struct IntuitionBase *)
  39.                 OpenLibrary("intuition.library", 37L))
  40.         {
  41.             if (screen = (struct Screen *)OpenScreenTags(NULL,
  42.                     SA_DisplayID, HIRESLACE_KEY,
  43.                     SA_Title, "ASL Test Screen",
  44.                     TAG_END))
  45.             {
  46.                 if (window = (struct Window *)OpenWindowTags(NULL,
  47.                         WA_CustomScreen, screen,
  48.                         WA_Title, "Demo Customscreen, File Pattern, Multi-select",
  49.                         WA_Flags, WINDOWDEPTH | WINDOWDRAG,
  50.                         TAG_END))
  51.                 {
  52.                     if (fr = (struct FileRequester *)
  53.                         AllocAslRequestTags(ASL_FileRequest,
  54.                             ASL_Hail, (ULONG)"FilePat/MultiSelect Demo",
  55.                             ASL_Dir,  (ULONG)"libs:",
  56.                             ASL_File, (ULONG)"asl.library",
  57.  
  58.                             /* Initial pattern string for pattern matching */
  59.                             ASL_Pattern, (ULONG)"~(rexx#?|math#?)",
  60.  
  61.                             /* Enable multiselection and pattern match gadget */
  62.                             ASL_FuncFlags, FILF_MULTISELECT | FILF_PATGAD,
  63.  
  64.                             /* This requester comes up on the screen of this
  65.                             ** window (and uses window's message port, if any).
  66.                             */
  67.                             ASL_Window, window,
  68.                             TAG_DONE))
  69.                     {
  70.                         /* Put up file requester */
  71.                         if (AslRequest(fr, 0L))
  72.                         {
  73.                             /* If the file requester's rf_NumArgs field
  74.                             ** is not zero, the user multiselected. The
  75.                             ** number of files is stored in rf_NumArgs.
  76.                             */
  77.                             if (fr->rf_NumArgs)
  78.                             {
  79.                                 /* rf_ArgList is an array of WBArg structures
  80.                                 ** (see <workbench/startup.h>). Each entry in
  81.                                 ** this array corresponds to one of the files
  82.                                 ** the user selected (in alphabetical order).
  83.                                 */
  84.                                 frargs = fr->rf_ArgList;
  85.  
  86.                                 /* The user multiselected, step through
  87.                                 ** the list of selected files.
  88.                                 */
  89.                                 for ( x=0;  x < fr->rf_NumArgs;  x++ )
  90.                                     printf("Argument %d: PATH=%s FILE=%s\n",
  91.                                         x, fr->rf_Dir, frargs[x].wa_Name);
  92.                             }
  93.                             else
  94.                                 /* The user didn't multiselect, use the
  95.                                 ** normal way to get the file name.
  96.                                 */
  97.                                 printf("PATH=%s FILE=%s\n", fr->rf_Dir, fr->rf_File);
  98.                         }
  99.                         /* Done with the FileRequester, better return it */
  100.                         FreeAslRequest(fr);
  101.                     }
  102.                     CloseWindow(window);
  103.                 }
  104.                 CloseScreen(screen);
  105.             }
  106.             CloseLibrary(IntuitionBase);
  107.         }
  108.         CloseLibrary(AslBase);
  109.     }
  110. }
  111.