home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD v1.2 / amidev_cd_12.iso / reference / amiga_mail_vol2 / i-7 / filepat.c < prev    next >
C/C++ Source or Header  |  1996-01-30  |  6KB  |  150 lines

  1. ;/* filepat.c - Execute me to compile me with SAS/C 6.56
  2. sc DATA=NEAR NMINC STRMERGE STREQ NOSTKCHK SAVEDS IGNORE=73 filepat.c
  3. slink FROM LIB:c.o,filepat.o TO filepat LIBRARY LIB:sc.lib,LIB:amiga.lib
  4. quit
  5. */
  6.  
  7. /*
  8. Copyright (c) 1991 Commodore-Amiga, Inc.
  9.  
  10. This example is provided in electronic form by Commodore-Amiga,
  11. Inc. for use with the Amiga Mail Volume II technical publication.
  12. Amiga Mail Volume II contains additional information on the correct
  13. usage of the techniques and operating system functions presented in
  14. these examples.  The source and executable code of these examples may
  15. only be distributed in free electronic form, via bulletin board or
  16. as part of a fully non-commercial and freely redistributable
  17. diskette.  Both the source and executable code (including comments)
  18. must be included, without modification, in any copy.  This example
  19. may not be published in printed form or distributed with any
  20. commercial product. However, the programming techniques and support
  21. routines set forth in these examples may be used in the development
  22. of original executable software products for Commodore Amiga
  23. computers.
  24.  
  25. All other rights reserved.
  26.  
  27. This example is provided "as-is" and is subject to change; no
  28. warranties are made.  All use is at your own risk. No liability or
  29. responsibility is assumed.
  30. */
  31.  
  32. #include <clib/asl_protos.h>
  33. #include <clib/exec_protos.h>
  34. #include <clib/intuition_protos.h>
  35. #include <clib/alib_stdio_protos.h>
  36. #include <workbench/startup.h>
  37. #include <intuition/intuition.h>
  38. #include <intuition/screens.h>
  39. #include <graphics/displayinfo.h>
  40. #include <exec/libraries.h>
  41.  
  42. #ifdef LATTICE
  43. int CXBRK(void) { return(0); }  /* Disable Lattice CTRL/C handling */
  44. int chkabort(void) { return(0); }  /* really */
  45. #endif
  46.  
  47. UBYTE *vers = "\0$VER: filepat 1.0";
  48.  
  49. void main(void);
  50.  
  51. struct Library *AslBase;
  52. struct IntuitionBase *IntuitionBase;
  53. struct Screen *screen;
  54. struct Window *window;
  55.  
  56. struct WBArg *wbargs;
  57.  
  58. LONG x;
  59.  
  60.  
  61. void main()
  62. {
  63.  
  64.     struct FileRequester *fr;
  65.  
  66.     if (AslBase = OpenLibrary("asl.library", 36L))
  67.     {
  68.         if (IntuitionBase = (struct IntuitionBase *)
  69.                 OpenLibrary("intuition.library", 36L))
  70.         {
  71.             if (screen = (struct Screen *)OpenScreenTags(NULL,
  72.                     SA_DisplayID, HIRESLACE_KEY,
  73.                     SA_Title, "ASL Test Screen",
  74.                     TAG_END))
  75.             {
  76.                 if (window = (struct Window *)OpenWindowTags(NULL,
  77.                         WA_CustomScreen, screen,
  78.                         WA_Title, "ASL Test Window",
  79.                         WA_Flags, WINDOWDEPTH | WINDOWDRAG,
  80.                         TAG_END))
  81.                 {
  82.                     if (fr = (struct FileRequester *)
  83.                         AllocAslRequestTags(ASL_FileRequest,
  84.                             ASL_Hail, (ULONG)"RKM File Requester, FilePat",
  85.                             ASL_Dir,  (ULONG)"libs:",
  86.                             ASL_File, (ULONG)"asl.library",
  87.  
  88.                             /* The initial pattern string for the
  89.                             ** pattern gadget.
  90.                             */
  91.                             ASL_Pattern, (ULONG)"~(rexx#?|math#?)",
  92.  
  93.                             /* turn on multiselection and the pattern
  94.                             ** matching gadget.
  95.                             */
  96.                             ASL_FuncFlags, FILF_MULTISELECT | FILF_PATGAD,
  97.  
  98.                             /* This requester is associated with this
  99.                             ** window (and uses its message port).
  100.                             */
  101.                             ASL_Window, window,
  102.                             TAG_DONE))
  103.                     {
  104.                         /* Application code body...*/
  105.  
  106.                         /* Put up file requester */
  107.                         if (AslRequest(fr, 0L))
  108.                         {
  109.                             /* If the file requester's rf_NumArgs field
  110.                             ** is not zero, the user multiselected. The
  111.                             ** number of files is stored in rf_NumArgs.
  112.                             */
  113.                             if (fr->rf_NumArgs)
  114.                             {
  115.                                 /* rf_ArgList is an array of WBArg structures
  116.                                 ** (defined in <workbench/startup.h>).
  117.                                 ** Each entry in the WBArg array corresponds
  118.                                 ** to one of the files the user selected
  119.                                 ** (the entries are in alphabetical order).
  120.                                 */
  121.                                 wbargs = fr->rf_ArgList;
  122.  
  123.                                 /* The user multiselected, step through
  124.                                 ** the list of selected files.
  125.                                 */
  126.                                 for ( x=0;  x < fr->rf_NumArgs;  x++ )
  127.                                     printf("Argument %d - %s%s\n", x,
  128.                                         fr->rf_Dir, wbargs[x].wa_Name);
  129.                             }
  130.                             else
  131.                                 /* The user didn't multiselect, use the
  132.                                 ** normal way to get the file name.
  133.                                 */
  134.                                 printf("%s%s\n", fr->rf_Dir, fr->rf_File);
  135.                         }
  136.                         /* More application code body... */
  137.  
  138.                         /* Done with the FileRequester, better return it */
  139.                         FreeAslRequest(fr);
  140.                     }
  141.                     CloseWindow(window);
  142.                 }
  143.                 CloseScreen(screen);
  144.             }
  145.             CloseLibrary(IntuitionBase);
  146.         }
  147.         CloseLibrary(AslBase);
  148.     }
  149. }
  150.