Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - fileselect() display file selection dialog box http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 fileselect()        Display file selection dialog box
------------------------------------------------------------------------------
 Declaration
   file.hdr

 Syntax
   func char fileselect extern
   param const char              cFileSpec, ;
         value logical           lDetails, ;
         value logical           lDrives, ;
         value logical           lRestorePath, ;
         value ptr(_FILESELFUNC) pFSFunc

 Arguments
   cFileSpec is a file specification to select from. Can include
   wildcards.

   lDetails indicates if file size, date, and time data are to
   be displayed.

   lDrives indicates if drive change is allowed.

   lRestorePath indicates if the original path is to be restored.

   pFSFunc is a pointer to a call back function.

 Return
   The name of the selected file, or an empty string if no selection was
   made.

 Description
   The fileselect() function is a high level facility for selecting
   files.

   The function displays a centered listing of file names that match the
   specification given in the cFileSpec argument. In addition to file
   names, other file characteristics can be presented, depending on the
   setting of the lDetails parameter.

   Directory names, and (depending on the lDrives parameter) drive letters
   are displayed for changing the current path, by pressing the Enter key.

   The pFSFunc argument must be set to the address of a function whose
   prototype matches the _FILESELFUNC type, or to zero. The function is
   called back from fileselect() before displaying the file list, provided
   that a nonzero value was passed in the pFSFunc parameter. The callback
   function receives the coordinates of the list, and the current directory
   name. The function can display a box around the file listing, and/or
   show the current directory.

   The fileselect() function returns when the user presses the Enter key
   on a file name (indicating selection), or the Escape key (indicating
   the cancellation of the file selection). The screen background of the
   file list is restored upon return. The original path is restored if
   selection was cancelled, or the lRestorePath parameter is set to .t.;
   otherwise the current path becomes the path last entered by the user.

 Example
   #define EXAMPLE_FILE
   #include example.hdr

   proc FSBoxFunc static
   param value uint nTop, ;
         value uint nLeft, ;
         value uint nBottom, ;
         value uint nRight, ;
         const char cDir
   box3d( nTop - 4, nLeft - 3, nBottom + 2, nRight + 3, ;
      B3D_SINGLE + B3D_FRAME + B3D_SHADOW + B3D_HEADER, ;
      1, WHITE_WHITE )
   dispcolor( nTop - 4, nLeft - 2, "| Select a file |", WHITE_WHITE )
   dispcolor( nTop - 2, nLeft, cDir, WHITE_RED )
   endproc
   
   proc FileList static
   param value logical lDetails
   vardef
      char cFile
   enddef
   __syscolor[ CLR_STD ] := BLUE_WHITE
   __syscolor[ CLR_ENHCD ] := iifb( lDetails, BLACK_YELLOW, RED_WHITE )
   cFile := fileselect( "*.*", lDetails, lDetails, .t., ;
      iifg( lDetails, &FSBoxFunc, 0 ) )
   __syscolor[ CLR_STD ] := BLACK_LIGHT_GREY
   if isempty( cFile )
      ? "File selection cancelled"
   else
      ? "File selected was", cFile
   endif
   wait
   endproc
   
   proc Test_fileselect
   FileList( .f. ) // simple file selection
   FileList( .t. ) // file selection with frame, details, and drive change
   endproc

   proc main
   Test_fileselect()
   endproc

See Also: _FILESELFUNC

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson