home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / misc~1 / 199 / src / gemdemo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-03-14  |  2.5 KB  |  65 lines

  1. /*  The basic outline for Mark Johnson's C GEM programs
  2.  *
  3.  * A Program showing use of the file selector box
  4.  *    and alert boxes.
  5.  *      adapted from ST-Log March 1987 by Mark Kelling
  6.  */
  7.  
  8. #include        <gem.h>         /* The GEM library hook*/
  9. /* no <osbin.h> or <stdio.h> required or allowed                */
  10.  
  11. /* Your basic required GEM globals */
  12. int     work_in[11],
  13.         work_out[57],
  14.         pxyarray[10],
  15.         contrl[12],
  16.         intin[128],
  17.         ptsin[128],
  18.         intout[128],
  19.         ptsout[128];
  20.  
  21. /* Globals for the program */
  22. int     handle, dum, i;
  23.  
  24. /* Main program */
  25. main()                  /* Notice no argv, argc */
  26. {
  27. /* Initialization section                                               */
  28.         appl_init ();             /* Tell GEM to initialize our program */
  29.         handle = graf_handle(&dum,&dum,&dum,&dum);      /* Get a handle */
  30.         for (i=0;i<10; work_in[i++] = 1 );             /* Set up arrays */
  31.         work_in[10] = 2;
  32.         v_opnvwk (work_in, &handle, work_out);            /* Open it up */
  33. /*The 'good stuff'                                                      */
  34.         sel_file ();                                 /* Get a file name */
  35.         v_clsvwk (handle);                     /* Close our workstation */
  36.                 /* Back to desk;  MUST NOT put appl_exit here!!     */
  37. } /* End of main */
  38.  
  39. sel_file ()   /* Use the file selector box and show the results         */
  40. {
  41.         int button ;                                    /* Button value */
  42.         char path[80],                              /* Filename strings */
  43.              file[13];
  44.  
  45.         for (i=0; i<40; path[i++]='\0');      /* Pad filename with nulls*/
  46.         for (i=0; i<13; file[i++]='\0');
  47.         path[0] = Dgetdrv() + 65;                 /* Find current drive */
  48.         path[1] = ":\*.*" ;                          /* Set default path*/
  49.         fsel_input(path, file, &button);
  50.         show_info (button) ;                /*Use alert to show results */
  51.  }
  52.  
  53. show_info (button)                  /* Make an alert box to show choice */
  54.    int  button ;                            /* Which button was pressed */
  55. {
  56.     if (button == 0)
  57.      form_alert( 1,"[3][You did not |choose a file!][ok]");
  58.     else
  59.      form_alert(1,"[2][You chose one|of the files.][got it]");
  60. /*  Currently, form_alert will only accept a string constant as shown here */
  61. }
  62.  
  63. int
  64. Dgetdrv () { return trap(1,0x19); }              /* Finds the active drive */
  65.