Page 1 of 3

fwdbu request

Posted: Sun Mar 25, 2018 1:46 pm
by Silvio.Falconi
it is possible add to the function TxtStruct( oBrw ) of fivedbu the list of index and key expression and for expression .


thanks

Re: fwdbu request

Posted: Mon Mar 26, 2018 6:44 am
by Otto
Hello Silvio,
this is a very useful practical feature. Thank you for asking.
Best regards,
Otto

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

//----------------------------------------------------------------------------//
 

Re: fwdbu request

Posted: Mon Mar 26, 2018 9:26 am
by Antonio Linares
Thanks Otto :-)

I think this is a better implementation as it writes the code that we need to create the indexes ;-) :

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
See the result for FWH\samples\aswapt.dbf:

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

Re: fwdbu request

Posted: Mon Mar 26, 2018 9:29 am
by Silvio.Falconi
Antonio,
and the tags ?

Re: fwdbu request

Posted: Mon Mar 26, 2018 9:46 am
by Otto
Dear Antonio,
thank you.

As to show source code is for me one oft he most used functions I inserted a button on the buttonbar for this.

Code: Select all

DEFINE BUTTON OF oBar PROMPT FWString( "SourceCode" ) RESOURCE "code" ACTION TxtStruct( oBrw )
Also the question “Do you want to end” I deleted.

Code: Select all

ACTIVATE WINDOW oWndMain MAXIMIZED ;
      VALID ( FWMissingStrings(), .T. ) ;
      ON PAINT DrawTiled( hDC, oWndMain, oBmpTiled )
 
Best regards,
Otto

Re: fwdbu request

Posted: Mon Mar 26, 2018 10:04 am
by Otto
In my copy I also changed AddClipboardButton:

function AddClipboardButton( oDlg, cText )

local oBtn

@ 238, 6 BUTTON oBtn PROMPT FWString( "Copy to clipboard" ) ;
OF oDlg SIZE 180, 28 PIXEL ;
ACTION ( CopyToClipboard( oDlg:aControls[ 1 ]:GetText() ), oDlg:end() )

return nil

//----------------------------------------------------------------------------//

Re: fwdbu request

Posted: Mon Mar 26, 2018 10:45 am
by Marc Venken
In FWDbu there is no option to print the structure on paper ?

Re: fwdbu request

Posted: Mon Mar 26, 2018 11:22 am
by Antonio Linares
Marc,

You copy it and paste it on notepad, email, etc

Re: fwdbu request

Posted: Mon Mar 26, 2018 11:26 am
by Silvio.Falconi
Antonio
I not understood

I need also the tag
sample :

INDEX ON upper(last) TAG LAST EVAL (oProgress:SetPos(nProgress++), Sysrefresh()) EVERY 1 FOR ! DELETED()

Re: fwdbu request

Posted: Mon Mar 26, 2018 12:41 pm
by Otto
Hello Silvio,
I added:

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
 
Best regards,
Otto

Re: fwdbu request

Posted: Mon Mar 26, 2018 2:32 pm
by Antonio Linares
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

Re: fwdbu request

Posted: Mon Mar 26, 2018 5:31 pm
by TimStone
I'm rather confused by the question ...

I modified the dBU a few years ago, added some features, and have the ability to select an index. My clients have learned to use this "File Editor" effectively.

In the users manual, I added instruction on how to use the editor, plus the structure ( fields, types, sizes, and description of each ), and specify in there the indexes and keys. This way, for someone who actually needs to know what they are looking for, they can check the document and see not only the key, but also the description of each field.

If they are not willing to read the manual, and understand what they are doing, I certainly do not want them using this utility.

I also keep a copy of those structures in One Note. This allows me an instant reference to every file.

Finally, Antonio I noted you mentioned the ASWAPT.dbf. That is the one I created for the calendar implementation using Codejock. Do we have that full implementation in the Samples ?

Tim

Re: fwdbu request

Posted: Mon Mar 26, 2018 8:16 pm
by Antonio Linares
Tim,

Today we enhanced the FiveDBU functionality to generate the code to create the index files:
Image

ASWAPT.dbf is provided in FWH\samples. It is used from FWH\samples\schedule.prg
I don't remember when it was placed there (I can check it in FWH repository) but I guess it was an example
that we tested together. If you want me to remove it please let me know it.

Re: fwdbu request

Posted: Mon Mar 26, 2018 9:13 pm
by TimStone
Antonio,

Schedule.prg is the program I worked on with two other FW developers, which we shared freely, and it is fine to be in the samples. It uses the Codejock library.

This specific version is pretty enhanced, and is used by most of my clients very heavily. It allows for very detailed appointments, repeating ones, assigning people to them, tracking clients and their service items, color coded work types, and much more. It displays like Outlook, and allows multiple appointments for the same, or overlapping, times.

Tim

Re: fwdbu request

Posted: Tue Mar 27, 2018 6:54 am
by Silvio.Falconi
Antonio 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
thanks
where is the last version of fwdbu

why not use a class to show dbf window ? type ....class odbfwnd from TXbrowse ?