From 99e4b88dd5105bd863b113c8b20f79b7440b4579 Mon Sep 17 00:00:00 2001 From: "Alexander S.Kresin" Date: Sun, 3 Mar 2002 16:33:36 +0000 Subject: [PATCH] 2002-03-03 19:35 UTC+0300 Alexander Kresin --- harbour/ChangeLog | 4 ++++ harbour/source/rtl/dbsdf.prg | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index bffcd5e502..484fc67b70 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -7,6 +7,10 @@ For example: 2002-12-01 23:12 UTC+0100 Foo Bar */ + * source/rtl/persist.prg + * added 254 as linelength to MLCount call in LoadFromText so + it matches later call to MemoLine + * source\common\hbffind.c * fixed the "Directory() can't see files with cleared archive bits" problem. diff --git a/harbour/source/rtl/dbsdf.prg b/harbour/source/rtl/dbsdf.prg index 48600411ec..4c6109bbd3 100644 --- a/harbour/source/rtl/dbsdf.prg +++ b/harbour/source/rtl/dbsdf.prg @@ -59,9 +59,10 @@ HB_FILE_VER( "$Id$" ) #define AppendEOL( handle ) FWRITE( handle, CHR( 13 ) + CHR( 10 ) ) #define AppendEOF( handle ) FWRITE( handle, CHR( 26 ) ) +#define SkipEOL( handle ) FSEEK( handle, 2, FS_RELATIVE ) PROCEDURE __dbSDF( lExport, cFile, aFields, bFor, bWhile, nNext, nRecord, lRest ) - LOCAL index, handle, cFileName := cFile, nStart, nCount, oErr + LOCAL index, handle, cFileName := cFile, nStart, nCount, oErr, nFileLen, aStruct // Process the file name argument. index := RAT( ".", cFileName ) @@ -186,6 +187,24 @@ PROCEDURE __dbSDF( lExport, cFile, aFields, bFor, bWhile, nNext, nRecord, lRest // This simplifies the looping logic. bWhile := {||.T.} END IF + nFileLen := FSEEK( handle,0,FS_END ) + FSEEK( handle,0 ) + aStruct := DBSTRUCT() + WHILE FSEEK( handle,0,FS_RELATIVE ) + 1 <= nFileLen + IF EMPTY( aFields ) + // Process all fields. + FOR index := 1 TO FCOUNT() + FieldPut( index,ImportFixed( handle,index,aStruct ) + NEXT index + ELSE + // Process the specified fields. + FOR index := 1 TO LEN( aFields ) + FieldPut( FIELDPOS( aFields[ index ] ),ImportFixed( handle,FIELDPOS( aFields[ index ],aStruct ) + NEXT index + END IF + // Set up for the start of the next record. + SkipEOL( handle ) + END WHILE FCLOSE( handle ) END IF */ @@ -207,3 +226,18 @@ STATIC FUNCTION ExportFixed( handle, xField ) END CASE RETURN .T. +STATIC FUNCTION ImportFixed( handle, index, aStruct ) + LOCAL cBuffer + FREAD( handle, @cBuffer, aStruct[ index,3 ] ) + DO CASE + CASE aStruct[ index,2 ] == "C" + RETURN cBuffer + CASE aStruct[ index,2 ] == "D" + RETURN HB_STOD( cBuffer ) + CASE aStruct[ index,2 ] == "L" + RETURN iif( cBuffer == "T",.T.,.F. ) + CASE aStruct[ index,2 ] == "N" + RETURN VAL( cBuffer ) + END CASE +RETURN cBuffer +