The Fileselect type

Purpose

This is an object which allows you to select one or more files in a file select window. However, as there is no special method to have a window type of object, it is implemented as a keypress object. If the associated key is pressed, the window is activated, but you can also explicitly activate the window. (Note that if you don't attach a keypress to the fileselect object (which is done with the PW('KEYPRESS') tag), the window can't be activated with a keypress).

A fileselect window normally allows the user to select just one file, but it can also be created to allow the user to select multiple files (in that case there is no edline to enter the filename, and the All item appears).

A fileselect window always displays a directory (the subdirectories and files of which are also visible). The directory can be edited (with a HIT on the edline), or changed via the directory select window (a DO on the edline). The fileselect window also contains an edline in which you can set some file extensions (separated by a semicolon (;)). Only files which end in one of the extension will be displayed in the menu (or if Not is indicated, only files which do not end in any of these extensions will be displayed).

Of course the directory which has to be displayed, and the default extensions, the status of the Not item and the window name can be set explicitly. If only one file can be indicated, the default filename can also be set (note that all these values are preserved across activations of the window, provided, of course, it is the same fileselect object).

The fileselect window will by default use up the entire possible height. It contains a wake and quit item, but will also quit in case of a DO inside the window.

The fileselect object can be customized to a large extent. You can insert some extra objects in the window in a box between the title bar (the outline) and the rest of the window. You can also change the title bar itself. Thus you could add a sleep item, redefine Do etc. This way you don't have to worry about the file selection etc. features in some applications.

The Type Word

When creating this type of object, the type parameter is:

PW('TYPE_FILESELECT')

The tags

Here are the tags for this object. As usual, change tags are also used when creating the object, but query tags are only used for queries. There is one tag that can only be used when creating this object:
A creation tag
PW('FILESELECT_MULTIPLE')
Make sure that multiple files can be selected in the file select window.
The change (and creation) tags
PW('FILESELECT_TITLE_TEXT')
Set the text which has to appear in the title bar of the file select window. The parameter is a string. By default the title is "file select".
PW('FILESELECT_ACTIVATE')
Activate the file select window. This tag has no parameters. The file select object is a keypress object. A keypress can be given to it and the window is displayed when that key is pressed. However, the window can also explicitely be asked for by passing this tag to the object.
PW('FILESELECT_ACTION')
Set a function which should be called when the fileselect window is closed. This doesn't make much sense in SBasic and MUST NEVER be used with the SBasic Interface.
PW('FILESELECT_FILENAME')
Set the default filename which should be suggested. The parameter is a string. If PW('FILESELECT_MULTIPLE') was passed during creation of the fileselect object, then nothing will happen - the filename is only set if only one file can be selected.
PW('FILESELECT_DIRECTORY')
Set the directory which should be displayed in the fileselect menu. If the directory is "", then it will default to the data directory. The parameter is a string.
PW('FILESELECT_EXTENSION')
Set the extensions which should be selected upon in the display of the fileselect window. The parameter is a string in which the extensions are separated by a semicolon(';'), e.g. "_doc;_aba;_bas"
PW('FILESELECT_NOT_STATUS')
Set the status for the "not" item in the fileselect window. This tag needs one parameter, any of PW('STATUS_AVAILABLE') (default), PW('STATUS_SELECTED') or PW('STATUS_UNAVAILABLE').
PW('FILESELECT_SHOWSUB')
This tag (which has either 1 (=TRUE) or 0 (=FALSE) as parameter) determines whether subdirectories should be displayed in the fileselect window.
The query tags
PW('FILESELECT_BOX')
To allow the user to modify the behaviour and look of the fileselect window, there is always an empty box between the outline and the rest of the window. The user may put some objects in this box. The object identifier is returned by this query, i.e. the object to use as owner in the PWcreate of the object to put in the box.
PW('FILESELECT_OUTLINE')
To allow the user to modify the behaviour and look of the fileselect window, the user is allowed to change the behaviour and look of the outline object in the window. Therefore, the user can get the object identifier of the outline with this query tag. The value returned is the outline object of the fileselect window.
PW('FILESELECT_MENU')
When you have indicated that several files may be selected in the fileselect window, then these files are contained in a menu object which is built by the fileselect object. Therefore, once the activation of the fileselect window is finished (the user hit ESC), you can query the object id of the menu which contains all the files (including the selected files). You can then get the names of the files selected with the PW('MENU_SELECTED_FIRST') and PW('MENU_SELECTED_NEXT') tags. Please note that here you shouldn't use the PW('MENU_XXX_XXX_NUMBER') tags, since there is no array to which the names correspond!
PW('FILESELECT_FILENAME')
Likewise, when the fileselect object only allows one file to be selected, you can get the name of this file with this tag. This is one of the three exceptions where PWquery returns a string directly!
PW('FILESELECT_DIRECTORY')
The filename(s) returned by the above two queries only contain the filename(s) as such, without the directory name in front. With this query you then get the directory which should be added in front to make a full filename. This is one of the three exceptions where PWquery returns a string directly!
PROGS, Professional & Graphical Software
last edited 1996 June 05 (wl)