FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour tdatabase for append / copy
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
tdatabase for append / copy
Posted: Fri Sep 16, 2011 04:24 PM

I'm a fan of data objects ( tdatabase / tdata ). Credit James Bott with introducing me to them and it makes my work so much easier.

Two capabilities missing from these classes is:

oDbf:CopyTo( oDbf2 ) which would allow us to copy all, or filtered, contents of an open data object to a new data file

and

oDbf:AppendFrom( oDbf2 ) which would allow us to append all, or filtered, records from a second database

Does anyone have these two functions now ? If not, I will work on them and provide them to Antonio for inclusion in tDatabase.

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: tdatabase for append / copy
Posted: Fri Sep 16, 2011 05:02 PM
Tim,

I have not tested it myself but it seems as this may be a valid starting point:

Code (fw): Select all Collapse
METHOD CopyTo( oDbf, aFields, bFor, bWhile, nNext, nRec, cRdd, cCp ) CLASS TDataBase

   local uVal

   if ValType( oDbf ) == "O"
      uVal = ( ::cAlias )->( __dbCopy( oDbf:cAlias, aFields, bFor, bWhile, nNext, nRec, cRdd, cCp ) )
   endif

return uVal

We could copy the records through the target object, but I think that may slow down the process very much
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: tdatabase for append / copy
Posted: Sun Sep 18, 2011 05:28 PM

Not exactly working ... yet ... will work with it this week. It didn't like the object.

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: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: tdatabase for append / copy
Posted: Sun Sep 18, 2011 06:42 PM
Try this:

Code (fw): Select all Collapse
METHOD CopyTo( cFile, aFields, bFor, bWhile, nNext, nRec, cRdd, cCp ) CLASS TDataBase

   LOCAL uVal
   uVal = ( ::cAlias )->( __dbCopy( cFile, aFields, bFor, bWhile, nNext, nRec, cRdd, cCp ) )
   
return uVal

Here is a sample test program:

Code (fw): Select all Collapse
// Test for copyto() method
function main
   local oDB
   oDB:= Tdatabase():new()
   oDB:open(,"clients")
   oDB:copyto( "temp" )
   oDB:close()
   msgInfo( "done")
return nil

Regards,
James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: tdatabase for append / copy
Posted: Sun Sep 18, 2011 07:34 PM
And here is an AppendFrom() method.

Code (fw): Select all Collapse
METHOD AppendFrom( cFile, aFields, bFor, bWhile, nNext, nRec, lRest ) CLASS TDataBase

     __dbApp( cFile, aFields, bFor, bWhile, nNext, nRec, lRest )
     
return nil

Regards,
James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: tdatabase for append / copy
Posted: Sun Sep 18, 2011 07:52 PM

James,

thanks! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: tdatabase for append / copy
Posted: Sun Sep 18, 2011 11:21 PM

Thanks. Where can I find a reference listing ( document ) for xHarbour __db???????? functions. Its not in the manual.

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: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: tdatabase for append / copy
Posted: Mon Sep 19, 2011 12:12 AM
You can find a reference to it in std.ch
Keep in mind this does not cover sdf or delimited.

#command APPEND [FROM <(f)>] [FIELDS <fields,...>] ;
[FOR <for>] [WHILE <while>] [NEXT <next>] ;
[RECORD <rec>] [<rest:REST>] [ALL] [VIA <rdd>] ;
[CODEPAGE <cp>] [CONNECTION <conn>] => ;
__dbApp( <(f)>, { <(fields)> }, ;
<{for}>, <{while}>, <next>, <rec>, <.rest.>, <rdd>, <conn>, <cp> )
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: tdatabase for append / copy
Posted: Mon Sep 19, 2011 05:18 PM

Thanks Gale. Actually I'm looking for a list of all __dbxxxxx( ) functions.

I'm always appreciative when someone provides a command syntax here, but wonder where they come from because I can't find any of it in my documentation.

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: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: tdatabase for append / copy
Posted: Mon Sep 19, 2011 05:50 PM

Please read and study std.ch file in the (x)harbour\include folder.
These are the default command translates of all xbase commands into clipper/harbour functions.

Regards



G. N. Rao.

Hyderabad, India
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: tdatabase for append / copy
Posted: Mon Sep 19, 2011 11:09 PM

Here is a list of just the __db functions. There are others starting with leading double underscores. These are all in the STD.CH file.

You can find the syntax for these by Googling them.

__dbPack()
__dbZap()
__dbContinue()
__dbLocate()
__dbCreate()
__dbCopyStuct()
__dbCopyXStruct()
__dbDelim()
__dbSDF()
__dbCopy()
__dbApp()
__dbSort()
__dbTotal()
__dbUpdate()
__dbJoin()
__dbList()

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion