home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / HISPEED2.LZH / GEMDEMO / FSEL.PAS < prev    next >
Pascal/Delphi Source File  |  1991-07-02  |  3KB  |  78 lines

  1. {-------------------------------------------------------------------------
  2.                 HighSpeed Pascal GEM-interface demo program
  3.  
  4.                         FILE SELECTOR LIBRARY DEMO
  5.  
  6.                       Copyright (c) 1990 by D-House I
  7.                             All rights reserved
  8.  
  9.                       Programmed by Martin Eskildsen
  10. -------------------------------------------------------------------------}
  11. {$R-,S-,D+}
  12.  
  13. program FSEL;
  14.  
  15. uses GemAES, GemVDI, GemDecl, GemInterface;
  16.  
  17. var
  18.   path          : string;       { the path and file mask        }
  19.   name          : string;       { the name                      }
  20.   title         : string;       { title for fsel_exinput        }
  21.   result        : string;       { resulting file name           }
  22.   ExitValue     : integer;      { fsel_ exit value (OK/CANCEL)  }
  23.  
  24. procedure Decompose;
  25. begin
  26.   path[0] := #255;  path[0] := chr(pos(#0, path));
  27.   name[0] := #255;  name[0] := chr(pos(#0, name));
  28.   { turn the "C" strings into Pascal strings  ^^^              }
  29.   { the strings above, however, still holds the #0 in the end  }
  30.   { so before you use them, you have to strip the last char,   }
  31.   { i.e. #0, off. This isn't done here, as we intend to use    }
  32.   { both path and name "as is" later on.                       }
  33.   result := path;
  34.   while result[length(result)] <> '\'           { remove file  }
  35.     do result[0] := chr(length(result)-1);      { spec.        }
  36.   result := result + copy(name, 1, pos(#0, name) - 1);
  37.   if ExitValue = 0 then result := result + ' "cancel"';
  38.   Inform('');                           { clear message box    }
  39.   Message(result)
  40. end;
  41.  
  42. begin { main }
  43.   if Init_Gem then begin
  44.     Message('Welcome to the File Selector library demo!');
  45.  
  46.     Inform('First, the simple one: Set your own path and name');
  47.     path := '\*.*'#0;           { default path }
  48.     name := #0;                 { no name      }
  49.     graf_mouse(M_ON, NIL);
  50.     fsel_input(path[1], name[1], ExitValue);  { do fsel }
  51.     graf_mouse(M_OFF, NIL);
  52.     Decompose;                  { write result of fsel    }
  53.  
  54.     Inform('Now reusing your definitions of path and name...');
  55.     graf_mouse(M_ON, NIL);
  56.     fsel_input(path[1], name[1], ExitValue);
  57.     graf_mouse(M_OFF, NIL);
  58.     Decompose;
  59.  
  60.     if GemDecl.global[0] >= $140 then begin  { TOS 1.4 or higher }
  61.       Inform('We can set our own header, like this :');
  62.       title := 'HighSpeed Pascal!'#0;
  63.       graf_mouse(M_ON, NIL);
  64.       fsel_exinput(path[1], name[1], ExitValue, title[1]);
  65.       graf_mouse(M_OFF, NIL);
  66.       Decompose
  67.     end
  68.     else begin
  69.       Inform('');               { clear message box }
  70.       Message('Can''t show fsel_exinput with this TOS version!')
  71.     end;
  72.  
  73.     Inform('');
  74.     Message('That''s all folks!');
  75.     Exit_Gem
  76.   end
  77. end.
  78.