StandardFileDialog.FileName Property (Typed) |
Namespace: XSharp.VO.SDK
1METHOD OpenDB() CLASS StandardShellWindow 2LOCAL oOpenDialog AS OpenDialog 3LOCAL uFileName AS USUAL 4LOCAL aoFileSpecs := {} AS ARRAY 5LOCAL lDone := .F. AS LOGIC 6LOCAL oDB AS Dbserver 7DO WHILE !lDone 8oOpenDialog:=OpenDialog{SELF} 9oOpenDialog:Caption:="Open DBF and Index" 10oOpenDialog:SetFilter ({"CUST*.*","ORD*.*","DET*.*"},; 11{"Customers", "Orders", "Details"}) 12oOpenDialog:SetStyle(OFN_ALLOWMULTISELECT + OFN_HIDEREADONLY) 13oOpenDialog:InitialDirectory := "C:\CAVO2x\SAMPLES\GSTUTOR" 14oOpenDialog:Show() 15uFileName := oOpenDialog:FileName 16IF IsArray(uFileName) .AND. ALen(uFileName) > 2 17(TextBox{SELF,"File Selection Error",; 18"Too many files selected"+CRLF+; 19"Please select one DBF and one index"}):Show() 20ELSE 21lDone := .T. 22ENDIF 23ENDDO 24// Open the selected DBF and index file 25uFileName := oOpenDialog:FileName 26IF IsArray(uFileName) // DBF and Index selected ? 27AEval(uFileName,{ | cFileName | AADD( ; 28aoFileSpecs, FileSpec{cFileName} ) } ) 29IF aoFileSpecs[1]:Extension != ".DBF" 30aoFileSpecs[1]:= ArraySwap(aoFileSpecs, ; 312, aoFileSpecs[1]) 32ENDIF 33RDDSetDefault("DBF"+SUBSTR(aoFileSpecs[2]:; 34Extension, 2, 3) ) 35oDB := DBServer{aoFileSpecs[1]} 36oDB:SetIndex(aoFileSpecs[2]) 37ELSEIF LOGIC(_CAST, uFileName) // Anything selected at all? 38AADD(aoFileSpecs,FileSpec{uFileName}) 39oDB := DBServer{aoFileSpecs[1]} 40ENDIF 41RETURN oDB