SUB main()' upgraded to use fillarray 5 and 6 homedir$ = "F:\johnb\wintask" DIRECTORY homedir$ SAVE "Filer_v3" REMOVE DIALOG ALL CALL MakeFilerD() GLOBAL ct%%,answer$(1,1000)' why this way round... becasue ' you can reduce by redim and keep data only if you only change last dimension ' Answer$ (0,n) contains short names ' (1,n) contains long names ' directory entries in (0,0) and (1,0) respectively ' selected files in (0,n) and (1,n) respectively where n>=1 ' (not necessary to have selected files to get directory) dlg.SetActive() dlg.Delete() DIRECTORY homedir$ ct%% = 0 FOR i%% = 0 TO 1000 IF Answer$(0,i%%) = "" THEN ct%% = i%% - 1:i%% = 9999 END IF NEXT i%% IF ct%% > 0 THEN REDIM Answer$(1,ct%%) ? MEMORY GLOBAL END IF END SUB SUB FilerAct() dlg.Tag = DIRECTORY DIM c AS DialogControl,o AS string,d AS DiskFile SET c = dlg.FileMaskBox' FileTypes c.List.Clear() c.AddItem("(*.*) - All Files") c.AddItem("(*.sb?) - all SB Files") c.AddItem("(*.sbb) - SB Labels") c.AddItem("(*.sbd) - SB FileDefs") c.AddItem("(*.sbf) - SB Data") c.AddItem("(*.sbk) - SB Keys") c.AddItem("(*.sbp) - SB Programs") c.AddItem("(*.sbq) - SB Queries") c.AddItem("(*.sbr) - RTS Programs") c.AddItem("(*.sbt) - SB Text") c.AddItem("(*.sbu) - SB updates") c.AddItem("(*.sbv) - SB Forms") c.AddItem("(*.sb!) - SB LockFiles") c.AddItem("(*.txt) - Text Files") c.AddItem("(*.dll) - DLLs") c.AddItem("(*.Exe) - Executables") o = c.List(1) o = GetFSpec$(o) c.Text = o dlg.FileTextBox.Text = o dlg.FileTextBox.Tag = "" SET c = dlg.DriveBox FOR i%% = 3 TO 26 a$ = CHR$ (64 + i%%) + ":" IF EXISTS (a$ + "\") THEN c.Additem( LCASE$ (a$)) END IF NEXT i%% c.Additem("a:") c.Text = LCASE$ ( LEFT$ ( DIRECTORY ,2)) c.Tag = c.Text CALL GetTree() CALL GetFileList(dlg.FileTextBox.Text,0) END SUB FUNCTION GetFSpec$(o AS string) i%% = INSTR (o,"(") j%% = INSTR (i%%,o,")"):IF j%% = 0 THEN j%% = LEN (o) + 1 k%% = j%% - i%% - 1 GetFSpec$ = MID$ (o,i%% + 1,k%%) END FUNCTION SUB Sorter() DIM c AS DialogControl SET c = dlg.FileBox c.list.clear() c.Additem("{none}") REPORT AFTER SELECT c.AddItem( FN LFN(FName.Sorter)) END SELECT SELECT ; ORDER FName.Sorter TO APPEND END SELECT END SUB FOR i%% = 0 TO 8000 IF a$(i%%) <> "" THEN FOR j%% = 1 TO i%% IF a$(i%%) > a$(j%%) THEN a$ = a$(i%%):a$(i%%) = a$(j%%):a$(j%%) = a$ END IF NEXT j%% ELSE i%% = 9999 END IF NEXT i%% END SUB SUB GetFileList(o$,st%%) IF dlg.FileTextBox.Tag = dlg.FileTextBox.Text THEN END SUB DIM farry$(8000),c AS DialogControl SET c = dlg.FileBox c.List.Clear() IF OPEN ("Sorter") THEN CLOSE FILE "Sorter" END IF CREATE MEMORY "Sorter" ADD "FName;TXT IXD;12;" MAKE "Sorter" FILLARRAY farry$,5,o$ ALL c.AddItem("{none}") FOR i%% = 0 TO 8000 farry$ = farry$(i%%) IF farry$ <> "" THEN c.AddItem(farry$) BLANK FILE "Sorter":FName.Sorter = farry$:STORE FILE "Sorter" ELSE i%% = 9999 END IF NEXT i%% IF st%% THEN CALL Sorter() dlg.FileTextBox.Tag = o$ dlg.FileTextBox.Tag = o$ END SUB SUB GetTree() DIM darry$(100),da%%,c AS DialogControl SET c = dlg.DirectoryBox c.List.Clear() da%% = LEN ( FN lpath( DIRECTORY )) da%% = IF (da%% = 3,2,da%%) FILLARRAY darry$,6,"*.*" ALL FOR i%% = 0 TO 100 darry$ = darry$(i%%) IF darry$ <> "" THEN IF darry$ = "." THEN c.Additem(darry$) ELSE IF darry$ = ".." THEN c.Additem(" " + darry$) ELSE c.Additem(" " + MID$ ( FN lpath(darry$),da%% + 2)) END IF ELSE i%% = 999 END IF NEXT i%% dlg.DirectoryTextBox.Text = DIRECTORY END SUB SUB FilerDeAct() END SUB SUB DialogEvent() DIM o AS string,ok%% SELECT CASE me.name CASE "FileMaskBox"'FileSelector o = me.Text o = GetFSpec$(o) dlg.FileTextBox.Text = o CALL GetFileList(dlg.FileTextBox.Text,dlg.Sortx.value) dlg.CB1.SetFocus() ok%% = 0 CASE "DriveBox"' Drive o = me.text DIRECTORY o CALL GetTree() dlg.FileTextBox.Tag = "" CALL GetFileList(dlg.FileTextBox.Text,dlg.Sortx.value) dlg.CB1.SetFocus() ok%% = 0 CASE "DirectoryBox"' Directory o = LTRIM$ ( TRIM$ (me.text)) IF o = "." THEN o = dlg.DriveBox.Text + "\" DIRECTORY FN spath(o) dlg.FileTextBox.Tag = "" CALL GetTree() CALL GetFileList(dlg.FileTextBox.Text,dlg.Sortx.value) dlg.CB1.SetFocus() ok%% = 0 CASE "FileBox","CB1"'OK or DoubleClick on FileList DIM c AS DialogControl SET c = dlg.FileBox i%% = 1 x%% = 1 answer$(0,0) = FN spath(dlg.DirectoryTextBox.Text) answer$(1,0) = FN lpath(dlg.DirectoryTextBox.Text) WHILE x%% <> 0 x%% = c.GetSelected(x%%) IF x%% = 0 THEN END WHILE answer$(1,i%%) = c.List(x%%) answer$(0,i%%) = FN sfn(c.List(x%%)) i%% = i%% + 1 WEND ok%% = - 1 CASE "FileTextBox" IF me.Text <> me.Tag THEN CALL GetFileList(dlg.FileTextBox.Text,dlg.Sortx.value) me.Tag = me.Text END IF ok%% = 0 CASE "Sortx" IF me.Value THEN CALL Sorter()' no point in calling it otherwise CASE "CB2"'Cancel DIRECTORY dlg.Tag ok%% = - 1 END CASE IF ok%% THEN dlg.SetActive(0) END SUB SUB MakeFilerD() ERASE "dlg" GLOBAL dlg AS Dialog DIM control AS DialogControl Superbase.Dialogs.Add("Filer") SET dlg = Superbase.Dialogs.Filer dlg.Move(0,0,270,150) dlg.Caption = "File Selector" dlg.FontName = "MS Sans Serif" dlg.FontSize = 8 dlg.OnActivate = "FilerAct" dlg.OnDeActivate = "FilerDeAct" SET control = dlg.Add("L1","DialogLabel") control.Move(4,3,81,9) control.Caption = "&FileName" SET control = dlg.Add("Sortx","DialogCheckBox") control.Move(94,16,81,9) control.Caption = "Sort" control.OnClick = "DialogEvent" SET control = dlg.Add("L2","DialogLabel") control.Move(144,4,81,10) control.Caption = "&Directory" SET control = dlg.Add("DirectoryTextBox","DialogTextBox") control.Move(144,17,121,11) control.WantReturn = 1 control.ScrollEnable = 2 control.MaxLength = 64 control.ReadOnly = - 1 control.OnLostFocus = "" SET control = dlg.Add("FileTextBox","DialogTextBox") control.Move(4,16,81,11) control.WantReturn = 1 control.ScrollEnable = 2 control.MaxLength = 20 control.OnLostFocus = "DialogEvent" control.OnGotFocus = "" SET control = dlg.Add("FileBox","DialogListBox") control.Move(4,32,121,80) control.MultiSelect = 1 control.Sorted = 0 control.ScrollBars = 2 control.OnDblClick = "DialogEvent" control.OnSelChange = "" SET control = dlg.Add("DirectoryBox","DialogListBox") control.Move(144,32,121,80) control.MultiSelect = 0 control.Sorted = 0 control.ScrollBars = 2 control.OnDblClick = "DialogEvent" control.OnSelChange = "DialogEvent" SET control = dlg.Add("CB1","DialogCommandButton") control.Move(170,128,44,16) control.Caption = "OK" control.ReturnValue = 0 control.Cancel = 1 control.OnClick = "DialogEvent" SET control = dlg.Add("CB2","DialogCommandButton") control.Move(220,128,44,16) control.Default = 0 control.Caption = "Cancel" control.ReturnValue = 0 control.Cancel = 1 control.OnClick = "DialogEvent" SET control = dlg.Add("L3","DialogLabel") control.Move(5,116,81,10) control.Caption = "File&Type" SET control = dlg.Add("L4","DialogLabel") control.Move(94,116,72,10) control.Caption = "Dri&ves" SET control = dlg.Add("FileMaskBox","DialogComboBox") control.Move(4,128,74,100) control.Style = 0 control.ScrollBars = 2 control.OnLostFocus = "DialogEvent" control.OnDblClick = "DialogEvent" control.OnSelChange = "DialogEvent" SET control = dlg.Add("DriveBox","DialogComboBox") control.Move(90,128,75,80) control.Style = 0 control.Sorted = 1 control.ScrollBars = 2 control.OnChange = "" control.OnDblClick = "DialogEvent" control.OnSelChange = "DialogEvent" END SUB