fwdbu request
Posted: Sun Mar 25, 2018 1:46 pm
it is possible add to the function TxtStruct( oBrw ) of fivedbu the list of index and key expression and for expression .
thanks
thanks
www.FiveTechSoft.com
https://fivetechsoft.com/forums/
Code: Select all
function TxtStruct( oBrw )
local cCode := "local aFields := { ", n, bClipboard
local cIndexCode := " Indexes in use " + Space( 23 ) + "TagName" + CRLF
local J := 0
*----------------------------------------------------------
for j = 1 to 15
if ! Empty( ( Alias( n ) )->( IndexKey( j ) ) )
cIndexCode += Space( 8 ) + ;
If( ( Alias( n ) )->( IndexOrd() ) == j, "=> ", " " ) + ;
PadR( ( Alias( n ) )->( IndexKey( j ) ), 35 ) + ;
( Alias( n ) )->( OrdName( j ) ) + ;
CRLF
endif
next
if Empty( oBrw:oRs )
for n = 1 to FCount()
if n > 1
cCode += Space( 19 )
endif
cCode += '{ "' + FieldName( n ) + '", "' + ;
FieldType( n ) + '", ' + ;
AllTrim( Str( FieldLen( n ) ) ) + ", " + ;
AllTrim( Str( FieldDec( n ) ) ) + " },;" + CRLF
next
else
for n = 1 to oBrw:oRS:Fields:Count
if n > 1
cCode += Space( 19 )
endif
cCode += '{ "' + oBrw:oRS:Fields[ n - 1 ]:Name + '", "' + ;
FWAdoFieldType( oBrw:oRs, n ) + '", ' + ;
AllTrim( Str( FWAdoFieldSize( oBrw:oRs, n ) ) ) + ", " + ;
AllTrim( Str( FWAdoFieldDec( oBrw:oRs, n ) ) ) + ;
" },;" + CRLF
next
endif
cCode = SubStr( cCode, 1, Len( cCode ) - 4 ) + " }" + CRLF + CRLF
if Empty( oBrw:oRs )
cCode += 'DbCreate( "myfile.dbf", aFields, "' + RddName() + '" )'
endif
cCode += CRLF + cIndexCode
bClipboard = { | oDlg | AddClipboardButton( oDlg ), cCode }
MemoEdit( bClipboard, FWString( "Code" ) )
return nil
//----------------------------------------------------------------------------//
Code: Select all
function TxtStruct( oBrw )
local cCode := "local aFields := { ", n, bClipboard
if Empty( oBrw:oRs )
for n = 1 to FCount()
if n > 1
cCode += Space( 19 )
endif
cCode += '{ "' + FieldName( n ) + '", "' + ;
FieldType( n ) + '", ' + ;
AllTrim( Str( FieldLen( n ) ) ) + ", " + ;
AllTrim( Str( FieldDec( n ) ) ) + " },;" + CRLF
next
else
for n = 1 to oBrw:oRS:Fields:Count
if n > 1
cCode += Space( 19 )
endif
cCode += '{ "' + oBrw:oRS:Fields[ n - 1 ]:Name + '", "' + ;
FWAdoFieldType( oBrw:oRs, n ) + '", ' + ;
AllTrim( Str( FWAdoFieldSize( oBrw:oRs, n ) ) ) + ", " + ;
AllTrim( Str( FWAdoFieldDec( oBrw:oRs, n ) ) ) + ;
" },;" + CRLF
next
endif
cCode = SubStr( cCode, 1, Len( cCode ) - 4 ) + " }" + CRLF + CRLF
if Empty( oBrw:oRs )
cCode += 'DbCreate( "myfile.dbf", aFields, "' + RddName() + '" )'
endif
for n = 1 to 15
if ! Empty( ( Alias() )->( IndexKey( n ) ) )
cCode += CRLF + CRLF + "INDEX ON " + ( Alias() )->( IndexKey( n ) ) + " TO " + ;
( Alias() )->( OrdName( n ) )
endif
next
bClipboard = { | oDlg | AddClipboardButton( oDlg ), cCode }
MemoEdit( bClipboard, FWString( "Code" ) )
return nil
Code: Select all
local aFields := { { "APTCLI", "C", 40, 0 },;
{ "APTVEH", "C", 40, 0 },;
{ "APTDAT", "D", 8, 0 },;
{ "APTBTI", "C", 5, 0 },;
{ "APTETI", "C", 5, 0 },;
{ "APTDUR", "N", 5, 0 },;
{ "APTACN", "C", 6, 0 },;
{ "APTLIC", "C", 12, 0 },;
{ "APTQUO", "C", 8, 0 },;
{ "APTASG", "C", 20, 0 },;
{ "APTUSD", "L", 1, 0 },;
{ "APTUID", "C", 12, 0 },;
{ "APTCLR", "C", 2, 0 },;
{ "APTREM", "L", 1, 0 },;
{ "APTBEG", "C", 18, 0 },;
{ "APTEND", "C", 18, 0 },;
{ "APTPHO", "C", 18, 0 },;
{ "APTNOT", "M", 10, 0 },;
{ "APTSUM", "C", 60, 0 },;
{ "APTITV", "N", 4, 0 },;
{ "APTSEQ", "N", 12, 0 },;
{ "APTRON", "L", 1, 0 },;
{ "APTALD", "L", 1, 0 },;
{ "APTMTG", "L", 1, 0 },;
{ "APTPRI", "L", 1, 0 },;
{ "APTIMP", "N", 1, 0 },;
{ "APTBSY", "N", 1, 0 } }
DbCreate( "myfile.dbf", aFields, "DBFCDX" )
INDEX ON dtos(aptdat)+aptbti TO ASWAPT
INDEX ON aptasg+dtos(aptdat)+aptbti TO ASWAPU
INDEX ON aptbeg TO ASWBEG
INDEX ON aptuid TO ASWUID
Code: Select all
INDEX ON dtos(aptdat)+aptbti TO ASWAPT
INDEX ON aptasg+dtos(aptdat)+aptbti TO ASWAPU
INDEX ON aptbeg TO ASWBEG
INDEX ON aptuid TO ASWUID
Code: Select all
DEFINE BUTTON OF oBar PROMPT FWString( "SourceCode" ) RESOURCE "code" ACTION TxtStruct( oBrw )
Code: Select all
ACTIVATE WINDOW oWndMain MAXIMIZED ;
VALID ( FWMissingStrings(), .T. ) ;
ON PAINT DrawTiled( hDC, oWndMain, oBmpTiled )
Code: Select all
if cRDD = "DBFCDX"
cCode += CRLF + CRLF + "INDEX ON " + ( Alias() )->( IndexKey( n ) ) + " TO TAG " + ;
( Alias() )->( OrdName( n ) )
else
cCode += CRLF + CRLF + "INDEX ON " + ( Alias() )->( IndexKey( n ) ) + " TO " + ;
( Alias() )->( OrdName( n ) )
endif
Code: Select all
for n = 1 to 15
if ! Empty( ( Alias() )->( IndexKey( n ) ) )
cCode += CRLF + CRLF + "INDEX ON " + ( Alias() )->( IndexKey( n ) ) + ;
If( ( Alias() )->( RddName() ) == "DBFNTX", " TO ", " TAG " ) + ;
( Alias() )->( OrdName( n ) )
endif
next
thanksAntonio Linares wrote:Silvio,
Code: Select all
for n = 1 to 15 if ! Empty( ( Alias() )->( IndexKey( n ) ) ) cCode += CRLF + CRLF + "INDEX ON " + ( Alias() )->( IndexKey( n ) ) + ; If( ( Alias() )->( RddName() ) == "DBFNTX", " TO ", " TAG " ) + ; ( Alias() )->( OrdName( n ) ) endif next