home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 122.lha / Arp_v1.1 / Demos / FileRequest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-11-21  |  1.4 KB  |  58 lines

  1. /* FileRequest.c -- Example program for using the ARP  FileRequest()
  2.  *            function call.
  3.  *           -=+SDB+=-
  4.  *
  5.  * Copyright (c) 1987, Scott Ballantyne
  6.  * Use and abuse as you please.
  7.  *
  8.  * Link with arp.lib
  9.  *
  10.  */
  11.  
  12. #include <exec/types.h>
  13. #include "libraries/arpbase.h"    /* Standard ARP header file */
  14. #include "arpfunctions.h"    /* Predeclared functions */
  15.  
  16. /* Initialize a structure for passing to the arplib's FileRequest()
  17.  * function.
  18.  *
  19.  * You need to supply a file and directory buffer to FileRequest().
  20.  *
  21.  * You can provide both default directories and filenames by initializing
  22.  * the arrays to a string before you submit the structure to FileRequest().
  23.  *
  24.  * For this example, we only initialize the directory string.
  25.  */
  26.  
  27. #define MAXPATH        ( (FCHARS * 10) + DSIZE + 1)    /* Size of a pathname */
  28.  
  29. BYTE Filename[FCHARS + 1];
  30. BYTE Directory[MAXPATH] = "DF0:";
  31.  
  32. struct FileRequester FR = {
  33.     "Greetings! Click on stuff!",    /* Hailing text */
  34.     Filename,            /* filename array */
  35.     Directory,            /* directory array */
  36.     NULL,        /* Window, NULL == workbench */
  37.     NULL,        /* Flags, not used in this release */
  38.     NULL,        /* Function pointers, not used in this release */
  39.     NULL,        /*  "" */
  40. };
  41.  
  42. VOID main()
  43. {
  44.     char *Selection;
  45.  
  46.     if ( Selection = FileRequest( &FR ) )
  47.     {
  48.         if ( *Selection )    /* Check for valid filename */
  49.             Printf("Filename = %s ", Filename);
  50.         else
  51.             Printf("No Filename selected, ");
  52.         Printf("Directory = %s\n", Directory);
  53.     }
  54.     else
  55.         Puts("User cancelled Requester!");
  56. }
  57.  
  58.