xsharp.eu • CoreDBF class
Page 1 of 3

CoreDBF class

Posted: Tue Feb 04, 2020 9:42 am
by wriedmann
Hi all,
if someone is interested: the attached application contains a class to permit an object oriented access to DBF files without using any VO compatible class.
There is also some code showing how to use this class.
Wolfgang
DBFServerApp.zip
(6.27 KiB) Downloaded 118 times
P.S. of course I'm open to suggestions, bug fixes, enhancements

CoreDBF class

Posted: Tue Feb 04, 2020 10:18 am
by Juraj
Hi Wolfgang,

After import DBServerApp.viaef into Xide 1.17 and compile I have tihis error message (in attachments.

Juraj

CoreDBF class

Posted: Tue Feb 04, 2020 10:25 am
by wriedmann
Hi Juraj,

strange.... you can remove this class from the application, it is not more needed. Or you can simply change the build type to "Text".

Wolfgang
P.S. I have XIDE 1.23 and X# 2.2a and there it compiles

CoreDBF class

Posted: Tue Feb 04, 2020 10:39 am
by Juraj
Hi Wolfgang,

after remove this class I have next error message (in atachments) in Form1:CreateDBFile..

oFieldList := List<RDDFieldInfo>{}
oFieldList:Add( RDDFieldInfo{ "FIELDC", "C", 10, 0, 0 } )
oFieldList:Add( RDDFieldInfo{ "FIELDD", "D", 8, 0, 0 } )
oFieldList:Add( RDDFieldInfo{ "FIELDN", "N", 10, 2, 0 } )
oFieldList:Add( RDDFieldInfo{ "FIELDL", "L", 1, 0, 0 } )
oFieldList:Add( RDDFieldInfo{ "FIELDM", "M", 10, 0, 0 } )

when I delete last "0" , copilation is OK.

Juraj

CoreDBF class

Posted: Tue Feb 04, 2020 10:44 am
by robert
Juraj,
The last X# build has added an extra parameter in the constructor: this is the Flags field for VFP which is used to indicate that a field is autonumber or binary.

Robert

CoreDBF class

Posted: Tue Feb 04, 2020 12:41 pm
by Karl-Heinz
Hi Wolfgang,

the Append() is incredible slow. Even when i change in your CreateDBFile() the loop to

FOR nI := 1 UPTO 100

it still takes 5,5 seconds to create and fill both dbfs. I couldn´t believe that, and created a test. When i run the TestAppend() with X# it takes indeed seconds ! to append 100 records. When i increase the loop upto 1000, VO appends 1000 records in less than 0,1 seconds. ...

can you confirm this behaviour ?

Code: Select all

FUNCTION TestAppend() AS  VOID
LOCAL i AS DWORD 
LOCAL aFields AS ARRAY
LOCAL cDbf AS STRING  
LOCAL f AS FLOAT 
                     
    RddSetDefault( "dbfcdx" )
    
	cDBF := "D:testXDbfTest.dbf"

	aFields := { { "LAST" , "C" , 10 , 0 } } 
    
	SetExclusive ( true )  //  X#  2,36 secs   !
	// SetExclusive ( false )  // X#  4,64 secs   !
	
	? "-------------------"
	? "Create and fill DBF"
	? "-------------------"
	? DbCreate( cDBF , AFields) 
	? DbUseArea( ,,cDBF )	

	f := Seconds()
		
	FOR i := 1 UPTO 100  
		DbAppend() 
		FieldPut ( 1 , PadL ( i , 10 , "0" ) )
						
	NEXT 
	
	
	? "Elapsed:" , Seconds() - f
	
	DbCloseArea()
	
RETURN 

regards
Karl-Heinz

CoreDBF class

Posted: Tue Feb 04, 2020 12:47 pm
by wriedmann
Hi Karl-Heinz,

this is really strange!
I have to check it out later today.
Basically the Append() method does the following:

Code: Select all

public virtual method Append( lReleaseLocks as logic ) as logic
	local lReturn		as logic
	local nSaveArea		as dword

	nSaveArea			:= RuntimeState.CurrentWorkArea
	lReturn				:= false
	try
	RuntimeState.CurrentWorkArea	:= _oRDD:Area

   	lReturn				:= CoreDB.Append( lReleaseLocks )

   	catch oEx as Exception

	self:ProcessException( oEx )
	lReturn				:= false

	finally
	RuntimeState.CurrentWorkArea	:= nSaveArea

	end try

    return lReturn
So I don't see any cause why it could be so slow....

Wolfgang

CoreDBF class

Posted: Tue Feb 04, 2020 1:00 pm
by FFF
Wolfgang,
yes, strange.
Took your code, imported Aef into Xide1.23, compiles, runs.
Click "Create DBF" - Bang, "konnte nicht auf eine Objectinstanz festgelegt werden".
looked in Code, find defaultpath for DBF is c: temp, change to zu "D:" (as i have no c:temp)
recompile, run, create dbf
swap to explorer, to look, if true -> yes, - dbf and fpt written
come back to app -> apphang.
?
EDIT: coming back after writing this, i find a "DBF written" messagebox. Hit ok. Looking NOW into explorer, i see also a cdx file written. I'm rather sure, it wasn't there, when i first looked ;)

CoreDBF class

Posted: Tue Feb 04, 2020 1:23 pm
by Karl-Heinz
Hi Karl,

the app doesn´t hang, but you have to wait ... or decrease the for loop as i did ;-)

The problem is not Wolfgang´s class, the problem is IMO the way a append currently works.

regards
Karl-Heinz

CoreDBF class

Posted: Tue Feb 11, 2020 7:57 am
by Karl-Heinz
Hi Karl,

am i correct that you´re using win8.1 64bit, and you´re still facing the mentioned append speed issues ?

regards
Karl-Heinz