fwdbu request

User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

fwdbu request

Post 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
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: fwdbu request

Post 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

//----------------------------------------------------------------------------//
 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: fwdbu request

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: fwdbu request

Post by Silvio.Falconi »

Antonio,
and the tags ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: fwdbu request

Post 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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: fwdbu request

Post 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

//----------------------------------------------------------------------------//
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Marc Venken
Posts: 727
Joined: Tue Jun 14, 2016 7:51 am

Re: fwdbu request

Post by Marc Venken »

In FWDbu there is no option to print the structure on paper ?
Marc Venken
Using: FWH 20.08 with Harbour
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: fwdbu request

Post by Antonio Linares »

Marc,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: fwdbu request

Post 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()
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: fwdbu request

Post 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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: fwdbu request

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: fwdbu request

Post 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
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: fwdbu request

Post 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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: fwdbu request

Post 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
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: fwdbu request

Post 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 ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Post Reply