| **Navigation:**  [[abc library reference.htm|ABC Library Reference]] > SelectFileClass >====== SelectFileClass Overview {{c6h0009.jpg|C6H0009.jpg}} ====== | [[selectfileclass.htm|{{btn_prev_n.gif|Previous page}}]][[abc library reference.htm|{{btn_home_n.gif|Return to chapter overview}}]][[selectfileclass properties.htm|{{btn_next_n.gif|Next page}}]] | | || **SelectFileClass Concepts** The SelectFileClass object manages the Windows File Dialog--both 16-bit (short filenames) and 32-bit versions (long filenames)--to select a single file or multiple files. **SelectFileClass Relationship to Other Application Builder Classes** The ASCIIViewerClass uses the the SelectFileClass to let the end user choose the file to view. Otherwise, the SelectFileClass is completely independent of other Application Builder Classes. **SelectFileClass ABC Template Implementation** The ABC DOSFileLookup control template generates code to declare a local SelectFileClass class //and //object for each instance of the SelectFile Control Template. The class is named SelectFile# where # is the instance number of the DOSFileLookup control template. The template provides the derived class so you can use the **Classes **tab to easily modify the select file behavior on an instance-by-instance basis. **SelectFileClass Source Files** The SelectFileClass source code is installed by default to the Clarion \LIBSRC folder. The SelectFileClass source code and its respective components are contained in: | | ABUTIL.INC | SelectFileClass declarations | | | ABUTIL.CLW | SelectFileClass method definitions | | | ABUTIL.TRN | SelectFileClass default text, mask, flags | **SelectFileClass Conceptual Example** The following example shows a typical sequence of statements to declare, instantiate, initialize, use, and terminate a SelectFileClass object. This example displays a dialog that alternatively allows single file or multi-file selection. **  PROGRAM** **  INCLUDE('ABUTIL.INC')            !declare SelectFileClass** **  MAP** **  END** **SelectFile   SelectFileClass       !declare SelectFile object** **FileQ      SelectFileQueue         !declare FileName QUEUE** **FileQCount   USHORT,AUTO           !declare Q counter** **FileNames    CSTRING(255)          !variable to hold file names** **FileMask    CSTRING('Text *.txt|*.txt|All *.*|*.*') !File dialog file masks** **MultiFiles   BYTE                  !single/multiple file switch** **GetFile WINDOW('Select File'),AT(,,173,40),SYSTEM,GRAY,RESIZE** **      ENTRY(@s254),AT(6,6,144,12),USE(FileNames)** **      BUTTON('...'),AT(156,6,12,12),USE(?SelectFiles)** **      OPTION,AT(6,20,),USE(MultiFiles)** **       RADIO('One File'),AT(5,25),USE(?1File),VALUE('0')** **       RADIO('Multiple Files'),AT(45,25),USE(?MultiFile),VALUE('1')** **      END** **      BUTTON('Close'),AT(119,24),USE(?Close)** **        END** ** CODE** ** OPEN(GetFile)** ** ACCEPT** **  IF EVENT() = EVENT:OpenWindow       !on open window** **   SelectFile.Init                    !initialize SelectFile object** **  !set default file mask:** **   SelectFile.AddMask('Clarion source|*.clw;*.inc')** **   SelectFile.AddMask(FileMask)       !set additional file masks** **  END** **  CASE FIELD()** **  OF ?SelectFiles                     !on get file button** **   IF EVENT() = EVENT:Accepted        !if user clicked it** **    IF MultiFiles                     !if multiple files requested** **     SelectFile.WindowTitle='Select multiple files'!set file dialog titlebar** **     SelectFile.Ask(FileQ,0)          !display file dialog** **     LOOP FileQCount=1 TO RECORDS(FileQ)!for each selected file** **      GET(FileQ,FileQCount)             !get the file information** **      MESSAGE(FileQ.Name)               !process the file** **     END** **    ELSE                                        !if single file requested** **     SelectFile.WindowTitle = 'Select one file' !set file dialog titlebar** **     FileNames = SelectFile.Ask(1)              !display file dialog** **     DISPLAY(?FileNames)                        !redraw Filenames field** **    END** **   END** **  OF ?Close                            !on close button** **      IF EVENT() = EVENT:Accepted      !if user clicked it** **        POST(Event:CloseWindow)        !shut down** **   END** **  END** ** END**