I think this is a better implementation as it writes the code that we need to create the indexes
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
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