BBjFileChooser SelectionMode Example

sysgui=unt
open(sysgui)"X0"

api!=BBjAPI()
sysgui!=api!.getSysGui()
window!=sysgui!.addWindow(100,100,500,350,"FileChooser",$00010083$,$$)
pwd$=DIR("")
fc!=window!.addFileChooser(101,0,0,500,300,pwd$,$0004$)
selectButton!=window!.addButton(102,200,310,100,30,"Selectfiles")
parentButton!=window!.addButton(103,310,310,100,30,"ParentDirectory")
fc!.setMultiSelectionEnabled(1)
IFfc!.getFileSelectionMode()<>fc!.FILES_AND_DIRECTORIES
fc!.setFileSelectionMode(fc!.FILES_AND_DIRECTORIES)
ENDIF

selectButton!.setCallback(api!.ON_BUTTON_PUSH,"SELECT_FILES")
parentButton!.setCallback(api!.ON_BUTTON_PUSH,"PARENT_DIR")
fc!.setCallback(api!.ON_FILECHOOSER_APPROVE,"DO_APPROVE")
fc!.setCallback(api!.ON_FILECHOOSER_CANCEL,"DO_CANCEL")

window!.setCallback(api!.ON_CLOSE,"DO_CLOSE")

PROCESS_EVENTS

DO_CLOSE:
RELEASE

SELECT_FILES:
    dirCh = UNT
    pwd$ = fc!.getCurrentDirectory()
    open(dirCh)pwd$
    readrecord(dirCh)dummy$
    readrecord(dirCh)dummy$
    readrecord(dirCh)file1$
    readrecord(dirCh)file2$
    vec! = api!.makeVector()
    vec!.addItem(pwd$ + "/" + file1$)
    vec!.addItem(pwd$ + "/" + file2$)
    fc!.setSelectedFiles(vec!)
    RETURN

PARENT_DIR:
    fc!.changeToParentDirectory()
    RETURN

DO_APPROVE:
    ev! = BBjAPI().getLastEvent()
    vec! = ev!.getSelectedFiles()
    for idx = 0 to vec!.size() - 1
        if (vec!.size() > 0)
            file$ = vec!.get(idx)
            PRINT file$
        endif
    next idx
    window!.destroy()
    END

DO_DIALOG_CANCEL:
    fc!.cancelSelection()
    RETURN

DO_CANCEL:
    PRINT "File selection canceled"
    END