FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour fwdbu request
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
fwdbu request
Posted: Sun Mar 25, 2018 01:46 PM

it is possible add to the function TxtStruct( oBrw ) of fivedbu the list of index and key expression and for expression .

thanks

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: fwdbu request
Posted: Mon Mar 26, 2018 06:44 AM
Hello Silvio,
this is a very useful practical feature. Thank you for asking.
Best regards,
Otto


Code (fw): Select all Collapse
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

//----------------------------------------------------------------------------//
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: fwdbu request
Posted: Mon Mar 26, 2018 09:26 AM
Thanks Otto :-)

I think this is a better implementation as it writes the code that we need to create the indexes :-) :
Code (fw): Select all Collapse
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 (fw): Select all Collapse
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 (fw): Select all Collapse
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
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: fwdbu request
Posted: Mon Mar 26, 2018 09:29 AM

Antonio,
and the tags ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: fwdbu request
Posted: Mon Mar 26, 2018 09:46 AM
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 (fw): Select all Collapse
DEFINE BUTTON OF oBar PROMPT FWString( "SourceCode" ) RESOURCE "code" ACTION TxtStruct( oBrw )

Also the question “Do you want to end” I deleted.
Code (fw): Select all Collapse
ACTIVATE WINDOW oWndMain MAXIMIZED ;
      VALID ( FWMissingStrings(), .T. ) ;
      ON PAINT DrawTiled( hDC, oWndMain, oBmpTiled )

Best regards,
Otto
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: fwdbu request
Posted: Mon Mar 26, 2018 10:04 AM

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

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

Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: fwdbu request
Posted: Mon Mar 26, 2018 10:45 AM

In FWDbu there is no option to print the structure on paper ?

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: fwdbu request
Posted: Mon Mar 26, 2018 11:22 AM

Marc,

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: fwdbu request
Posted: Mon Mar 26, 2018 11:26 AM
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()
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: fwdbu request
Posted: Mon Mar 26, 2018 12:41 PM
Hello Silvio,
I added:

Code (fw): Select all Collapse
         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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: fwdbu request
Posted: Mon Mar 26, 2018 02:32 PM
Silvio,

Code (fw): Select all Collapse
   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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: fwdbu request
Posted: Mon Mar 26, 2018 05:31 PM

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
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: fwdbu request
Posted: Mon Mar 26, 2018 08:16 PM
Tim,

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


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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: fwdbu request
Posted: Mon Mar 26, 2018 09:13 PM

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
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: fwdbu request
Posted: Tue Mar 27, 2018 06:54 AM
Antonio Linares wrote:Silvio,

Code (fw): Select all Collapse
   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 ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com