ChangeLogTag:19991026-12:49 GMT+1 Bruno Cantero <bruno@issnet.net>

This commit is contained in:
Bruno Cantero
1999-10-26 11:01:17 +00:00
parent 8f39fa1af5
commit f23d8bb71b
3 changed files with 62 additions and 7 deletions

View File

@@ -1,3 +1,8 @@
19991026-12:49 GMT+1 Bruno Cantero <bruno@issnet.net>
* source/rdd/dbf1.c
tests/testdbf.prg
* __dbZap() function finished. Test added for this function.
19991026-11:35 GMT+1 Victor Szel <info@szelvesz.hu>
* source/tget.prg
% New() will evaluate the setget only once instead of three times.

View File

@@ -1714,6 +1714,7 @@ static ERRCODE dbfZap( AREAP pArea )
{
PHB_ITEM pError;
DBOPENINFO pInfo;
ULONG ulRecCount;
if( !pArea->lpExtendInfo->fExclusive )
{
@@ -1729,10 +1730,25 @@ static ERRCODE dbfZap( AREAP pArea )
if( SELF_GOCOLD( pArea ) == FAILURE || pArea->lpExtendInfo->fReadOnly )
return FAILURE;
/*
TODO: truncate dbf and memo files.
*/
/* Test if can write into file */
SELF_RECCOUNT( pArea, &ulRecCount );
if( !hb_dbfUpdateHeader( pArea, ulRecCount ) )
return FAILURE;
hb_dbfUnLockAllRecords( pArea );
hb_fsClose( pArea->lpFileInfo->hFile );
pInfo.abName = ( BYTE * ) pArea->lpFileInfo->szFileName;
SELF_CREATE( pArea, &pInfo );
hb_fsClose( pArea->lpFileInfo->hFile );
pArea->lpFileInfo->hFile = hb_fsOpen( pInfo.abName, FO_READWRITE | FO_EXCLUSIVE );
if( pArea->lpExtendInfo->fHasMemo )
{
hb_fsClose( pArea->lpFileInfo->pNext->hFile );
pInfo.abName = ( BYTE * ) pArea->lpFileInfo->pNext->szFileName;
SELF_CREATEMEMFILE( pArea, &pInfo );
hb_fsClose( pArea->lpFileInfo->pNext->hFile );
pArea->lpFileInfo->pNext->hFile = hb_fsOpen( pInfo.abName, FO_READWRITE | FO_EXCLUSIVE );
}
return SELF_GOTOP( pArea );
}

View File

@@ -25,8 +25,8 @@ function main()
? "[" + MYALIAS->MEMO1 + "]"
? "[" + MYALIAS->MEMO2 + "]"
MYALIAS->( dbAppend() )
MYALIAS->MEMO1 := "111"
MYALIAS->MEMO2 := "222"
MYALIAS->MEMO1 := "This is a test for field MEMO1."
MYALIAS->MEMO2 := "This is a test for field MEMO2."
? "[" + MYALIAS->MEMO1 + "]"
? "[" + MYALIAS->MEMO2 + "]"
MYALIAS->NUMERIC := 90
@@ -34,12 +34,46 @@ function main()
? "[" + Str( MYALIAS->DOUBLE ) + "]"
? "[" + Str( MYALIAS->NUMERIC ) + "]"
dbCloseAll()
? ""
? "Press any key..."
InKey( 0 )
? ""
? "Append 50 records with memos..."
for nI := 1 to 50
MYALIAS->( dbAppend() )
MYALIAS->MEMO1 := "This is a very long string. " + ;
"This may seem silly however strings like this are still " + ;
"used. Not by good programmers though, but I've seen " + ;
"stuff like this used for Copyright messages and other " + ;
"long text. What is the point to all of this you'd say. " + ;
"Well I am coming to the point right now, the constant " + ;
"string is limited to 256 characters and this string is " + ;
"a lot bigger. Do you get my drift ? If there is somebody " + ;
"who has read this line upto the very end: Esto es un " + ;
"sombrero grande rid¡culo." + Chr( 13 ) + Chr( 10 ) + ;
"/" + Chr( 13 ) + Chr( 10 ) + "[;-)" + Chr( 13 ) + Chr( 10 )+ ;
"\"
next
dbCommit()
? "Records before ZAP:", MYALIAS->( LastRec() )
? "Size of files (data and memo):", Directory( "testdbf.dbf" )[1][2], ;
Directory( "testdbf.fpt" )[1][2]
MYALIAS->( __dbZap() )
dbCommit()
? "Records after ZAP:", MYALIAS->( LastRec() )
? "Size of files (data and memo):", Directory( "testdbf.dbf" )[1][2], ;
Directory( "testdbf.fpt" )[1][2]
? "Value of fields MEMO1, MEMO2, DOUBLE and NUMERIC:"
? "[" + MYALIAS->MEMO1 + "]"
? "[" + MYALIAS->MEMO2 + "]"
? "[" + Str( MYALIAS->DOUBLE ) + "]"
? "[" + Str( MYALIAS->NUMERIC ) + "]"
? "Press any key..."
InKey( 0 )
dbCloseAll()
dbCreate( "testdbf", aStruct, "DBFCDX", .t., "MYALIAS" )
for nI := 1 to 10