As example (I want to learn more about all the options from Xbrowse)
I see lots of Methods like this in the source files :
METHOD ToDbf( cFile, bProgress, aCols, lPrompt )
and a corresponding method function like below.
So, It is correct that I can use this to find ALL options that are not reported in the Wiki files ?
If I could read these functions, The use would be something like this (Not tested, just for the idea)
oBrw:ToDbf(MyDbf,???,aCols,???)
Could someone explain this way of working i little more ?
Thanks
Marc
- Code: Select all Expand view
METHOD ToDbf( cFile, bProgress, aCols, lPrompt ) CLASS TXBrowse
local aStruct := {}
local nKeyNo := ::KeyNo
local nRowPos := ::nRowSel
local n, uVal, c, oCol, nCols
local nSelect
if ::nLen < 1
return nil
endif
DEFAULT lPrompt := .f.
if aCols == nil
aCols := ::GetVisibleCols()
else
AEval( aCols, { |u,i| aCols[ i ] := ::oCol[ u ] } )
endif
::GoTop()
nCols := Len( aCols )
for each oCol in aCols
uVal := oCol:Value
AAdd( aStruct, { Upper( PadR( oCol:cHeader, 10 ) ), oCol:cDataType, oCol:nDataLen, oCol:nDataDec } )
if Empty( oCol:cHeader )
ATail( aStruct )[ 1 ] := "COL" + StrZero( oCol:nCreationOrder, 2 )
endif
if Empty( c := oCol:cDataType ) .or. !( c $ 'DLMNT' )
ATail( aStruct )[ 2 ] := c := If( uVal == nil, 'C', ValType( uVal ) )
endif
if Empty( oCol:nDataLen ) .or. c $ "DTLM"
ATail( aStruct )[ 3 ] := HB_DeCode( c, 'C', 40, 'D', 8, 'T', 8, 'L', 1, 'N', 14, 10 )
endif
if c == 'N'
if oCol:nDataDec == nil
ATail( aStruct )[ 4 ] := 0
endif
else
ATail( aStruct )[ 4 ] := 0
endif
next
if lPrompt
XBROWSER aStruct TITLE cFile + ":STRUCTURE" FASTEDIT ;
SETUP (oBrw:cEditPictures := { '@!', '!', '99','99' } )
endif
nSelect := Select()
DBCREATE( cFile, aStruct )
if bProgress == nil
if ::oWnd:oMsgBar == nil
bProgress := { || nil }
else
bProgress := { | n, t | ::oWnd:SetMsg( FWString( "To DBF" ) + " : " + ;
Ltrim( Str( n ) ) + "/" + Ltrim( Str( t ) ) ) }
endif
endif
Eval( bProgress, 0, ::nLen )
USE (cFile) NEW ALIAS XBRTODBF EXCLUSIVE
REPEAT
XBRTODBF->( DbAppend() )
for n := 1 to nCols
C := aStruct[ n ][ 2 ] // datatype
uVal := aCols[ n ]:Value
if ! Empty( uVal )
if c == 'C'
if ValType( uVal ) != 'C'
uVal := cValToChar( uVal )
endif
elseif ValType( uVal ) == 'C'
uVal := uCharToVal( uVal, c )
endif
TRY
XBRTODBF->( FieldPut( n, aCols[ n ]:Value ) )
CATCH
// datatype mismatch or data len exceeds
END
endif
next
Eval( bProgress, XBRTODBF->( RecNo() ), ::nLen )
UNTIL ::Skip( 1 ) == 0
Eval( bProgress, XBRTODBF->( LASTREC() ), XBRTODBF->( LASTREC() ) )
CLOSE XBRTODBF
::KeyNo := nKeyNo
::nRowSel := nRowPos
::Refresh()
if lPrompt .and. MsgYesNo( If( FWSetLanguage() == 2, "¿ ", "" ) + ;
FWString( "View" ) + " " + cFile + " ?",;
FWString( "Please select" ) )
XBrowse( cFile )
endif
::SetFocus()
return nil