2001-12-18 21:47 UTC+0100 Viktor Szakats <viktor.szakats@syenar.hu>

This commit is contained in:
Viktor Szakats
2001-12-18 20:51:20 +00:00
parent 5942e35e7c
commit fb076743b4
11 changed files with 296 additions and 178 deletions

View File

@@ -8,6 +8,31 @@
2002-12-01 23:12 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2001-12-18 21:47 UTC+0100 Viktor Szakats <viktor.szakats@syenar.hu>
* include/hbapi.h
* include/hbsetup.ch
+ include/hbcommon.ch
* include/Makefile
+ Added HB_FILE_VER( id ) for Harbour and C
sources. Note that in order to work in
.prg files, HB_FILE_VER() should come after
the #includes and the file should #include "hbcommon.ch"
which will automatically include "hbsetup.ch" too.
+ Added HB_FILE_VER_STATIC define which will
enable the inclusion of HB_FILE_VER info.
* source/common/hbffind.c
* source/rtl/dbdelim.prg
* source/rtl/dbsdf.prg
+ Added experimental HB_FILE_VER() lines.
* doc/genhtm.rsp
+ doc/en/dbdelim.txt
+ doc/en/dbsdf.txt
% Some small optimization for speed.
* Separated documentation from the source.
2001-12-18 20:15 UTC+0300 Alexander Kresin <alex@belacy.belgorod.su>
* tests/db_brows.prg
Some changes to eliminate using of functions from libmisc.
@@ -19,7 +44,6 @@
hb_gcReleaseAll() will increase cleanup speed (on app termination),
and will result in a more complete cleanup in certain situations.
2001-12-18 10:03 UTC+0100 Viktor Szakats <viktor.szakats@syenar.hu>
* source/common/hbffind.c

View File

@@ -0,0 +1,80 @@
/*
* $Id$
*/
/*
* The following parts are Copyright of the individual authors.
* www - http://www.harbour-project.org
*
* Copyright 2001-2002 David G. Holm <dholm@jsd-llc.com>
* Documentation for: __dbDelim()
*
* See doc/license.txt for licensing terms.
*
*/
/* $DOC$
* $FUNCNAME$
* __dbDelim()
* $CATEGORY$
* Conversion
* $ONELINER$
* Copies the contents of a database to a delimited text file or
* appends the contents of a delimited text file to a database.
* $SYNTAX$
* __dbDelim( <lExport>, <xcFile>, [<xcDelim>], [<aFields>],
* [<bFor>], [<bWhile>], [<nNext>], [<nRecord>], <lRest> ) --> NIL
* $ARGUMENTS$
* <lExport> If set to .T., copies records to a delimited file.
* If set to .F., append records from a delimited file.
* <xcFile> The name of the text file to copy to or append from.
* If a file extension is not specified, ".txt" is used by default.
* <xcDelim> Either the character to use as the character field
* delimiter (only the first character is used). or "BLANK" (not case
* sensitive), which eliminates the character field delimiters and
* sets the field separator to a single space instead of a comma.
* <aFields> An aray of field names to limit the processint to. If
* not specified, or if empty, then all fields are processed.
* <bFor> An optional code block containing a FOR expression that
* will reduce the number of records to be processed.
* <bWhile> An optional code block containing a WHILE expression
* that will reduce the number of records to be processed.
* <nNext> If present, but nRecord is not present, specifies to
* process this number of records, starting with the current record.
* A value of 0 means to process no records.
* <nRecord> If present, specifies the only record to process. A
* value of 0 means to process no records. Overrides nNext and lRest.
* <lRest> If lExport is .T., then if set to .T. and there are no
* nRecord, nNext, or bWhile arguments, processes all records from
* current to last.
* $RETURNS$
* NIL
* $DESCRIPTION$
* __dbDelim() copies all or selected contents of a database table
* to an SDF text file or appends all or selected contents of an SDF
* text file to a database table.
* $EXAMPLES$
* // Copy delinquent accounts into a delimited text file.
* USE ACCOUNTS NEW
* COPY TO overdue DELIMITED FOR !EMPTY( accounts->duedate ) ;
* .AND. DATE() - accounts->duedate > 30
* // Import new customer records.
* USE CUSTOMER NEW
* APPEND FROM customer DELIMITED
* $TESTS$
*
* $STATUS$
* S
* $COMPLIANCE$
* __dbDelim() is intended to be fully compliant with CA-Clipper's
* function of the same name and is the underlying implementation
* of the APPEND FROM DELIMITED and COPY TO DELIMITED commands.
* $PLATFORMS$
* All
* $FILES$
*
* $SEEALSO$
* __dbSDF(), APPEND FROM, COPY TO
* $END$
*/

76
harbour/doc/en/dbsdf.txt Normal file
View File

@@ -0,0 +1,76 @@
/*
* $Id$
*/
/*
* The following parts are Copyright of the individual authors.
* www - http://www.harbour-project.org
*
* Copyright 2001-2002 David G. Holm <dholm@jsd-llc.com>
* Documentation for: __dbSDF()
*
* See doc/license.txt for licensing terms.
*
*/
/* $DOC$
* $FUNCNAME$
* __dbSDF()
* $CATEGORY$
* Conversion
* $ONELINER$
* Copies the contents of a database to an SDF text file or
* appends the contents of an SDF text file to a database.
* $SYNTAX$
* __dbSDF( <lExport>, <xcFile>, [<aFields>],
* [<bFor>], [<bWhile>], [<nNext>], [<nRecord>], <lRest> ) --> NIL
* $ARGUMENTS$
* <lExport> If set to .T., copies records to an SDF file.
* If set to .F., append records from an SDF file.
* <xcFile> The name of the text file to copy to or append from.
* If a file extension is not specified, ".txt" is used by default.
* <aFields> An aray of field names to limit the processint to. If
* not specified, or if empty, then all fields are processed.
* <bFor> An optional code block containing a FOR expression that
* will reduce the number of records to be processed.
* <bWhile> An optional code block containing a WHILE expression
* that will reduce the number of records to be processed.
* <nNext> If present, but nRecord is not present, specifies to
* process this number of records, starting with the current record.
* A value of 0 means to process no records.
* <nRecord> If present, specifies the only record to process. A
* value of 0 means to process no records. Overrides nNext and lRest.
* <lRest> If lExport is .T., then if set to .T. and there are no
* nRecord, nNext, or bWhile arguments, processes all records from
* current to last.
* $RETURNS$
* NIL
* $DESCRIPTION$
* __dbSDF() copies all or selected contents of a database table
* to an SDF text file or appends all or selected contents of an
* SDF text file to a database table.
* $EXAMPLES$
* // Copy delinquent accounts into an SDF text file.
* USE ACCOUNTS NEW
* COPY TO overdue SDF FOR !EMPTY( accounts->duedate ) ;
* .AND. DATE() - accounts->duedate > 30
* // Import new customer records.
* USE CUSTOMER NEW
* APPEND FROM customer SDF
* $TESTS$
*
* $STATUS$
* S
* $COMPLIANCE$
* __dbSDF() is intended to be fully compliant with CA-Clipper's
* function of the same name and is the underlying implementation
* of the APPEND FROM SDF and COPY TO SDF commands.
* $PLATFORMS$
* All
* $FILES$
*
* $SEEALSO$
* __dbDelim(), APPEND FROM, COPY TO
* $END$
*/

View File

@@ -3,6 +3,8 @@ en\binnum.txt
en\browse.txt
en\command.txt
en\datetime.txt
en\dbdelim.txt
en\dbsdf.txt
en\dbstrux.txt
en\diskspac.txt
en\dir.txt

View File

@@ -56,6 +56,7 @@ PRG_HEADERS=\
fileio.ch \
getexit.ch \
hbclass.ch \
hbcommon.ch \
hbextern.ch \
hbgetcmt.ch \
hbinkey.ch \

View File

@@ -582,6 +582,14 @@ extern void hb_verBuildInfo( void ); /* display harbour, compiler, and platfor
/* WARNING: This returned pointer must be freed using hb_xfree( ( void * ) ptr ); */
extern char * hb_getenv( const char * name );
/* Version tracking related things */
#ifdef HB_FILE_VER_STATIC
#define HB_FILE_VER( id ) static char s_hb_file_ver[] = id;
#else
#define HB_FILE_VER( id )
#endif
/* Translation related things */
/* Dummy define for start */

View File

@@ -0,0 +1,65 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Common header file for the source of Harbour itself.
*
* Copyright 2001-2002 Viktor Szakats <viktor.szakats@syenar.hu>
* www - http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#ifndef HB_HBCOMMON_CH_
#define HB_HBCOMMON_CH_
#include "hbsetup.ch"
#ifdef HB_FILE_VER_STATIC
#define HB_FILE_VER( id ) STATIC s_hb_file_ver := id
#else
#define HB_FILE_VER( id )
#endif
#endif /* HB_HBCOMMON_CH_ */

View File

@@ -79,6 +79,8 @@
#define HB_SHORTNAMES
#endif
/* #define HB_FILE_VER_STATIC */ /* Enable inclusion of file version strings */
/*#define HB_CLS_ENFORCERO */ /* Activate the RO checking on OO DATA */
/* when not called from a constructor */

View File

@@ -64,6 +64,8 @@
#include "hbdate.h"
#include "hb_io.h"
HB_FILE_VER( "$Id$" )
/* ------------------------------------------------------------- */
#include <ctype.h>
@@ -80,7 +82,6 @@
typedef struct
{
void * dta;
struct ffblk entry;
} HB_FFIND_INFO, * PHB_FFIND_INFO;

View File

@@ -7,7 +7,7 @@
* Copies the contents of a database to a delimited text file.
* Appends the contents of a delimited text file to a database.
*
* Copyright 2001 David G. Holm <dholm@jsd-llc.com>
* Copyright 2001-2002 David G. Holm <dholm@jsd-llc.com>
* www - http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
@@ -51,76 +51,17 @@
*
*/
#include <fileio.ch>
#include <hbclass.ch>
#include <error.ch>
#include "hbcommon.ch"
#include "fileio.ch"
#include "error.ch"
/* $DOC$
* $FUNCNAME$
* __dbDelim()
* $CATEGORY$
* Conversion
* $ONELINER$
* Copies the contents of a database to a delimited text file or
* appends the contents of a delimited text file to a database.
* $SYNTAX$
* __dbDelim( <lExport>, <xcFile>, [<xcDelim>], [<aFields>],
* [<bFor>], [<bWhile>], [<nNext>], [<nRecord>], <lRest> ) --> NIL
* $ARGUMENTS$
* <lExport> If set to .T., copies records to a delimited file.
* If set to .F., append records from a delimited file.
* <xcFile> The name of the text file to copy to or append from.
* If a file extension is not specified, ".txt" is used by default.
* <xcDelim> Either the character to use as the character field
* delimiter (only the first character is used). or "BLANK" (not case
* sensitive), which eliminates the character field delimiters and
* sets the field separator to a single space instead of a comma.
* <aFields> An aray of field names to limit the processint to. If
* not specified, or if empty, then all fields are processed.
* <bFor> An optional code block containing a FOR expression that
* will reduce the number of records to be processed.
* <bWhile> An optional code block containing a WHILE expression
* that will reduce the number of records to be processed.
* <nNext> If present, but nRecord is not present, specifies to
* process this number of records, starting with the current record.
* A value of 0 means to process no records.
* <nRecord> If present, specifies the only record to process. A
* value of 0 means to process no records. Overrides nNext and lRest.
* <lRest> If lExport is .T., then if set to .T. and there are no
* nRecord, nNext, or bWhile arguments, processes all records from
* current to last.
* $RETURNS$
* NIL
* $DESCRIPTION$
* __dbDelim() copies all or selected contents of a database table
* to an SDF text file or appends all or selected contents of an SDF
* text file to a database table.
* $EXAMPLES$
* // Copy delinquent accounts into a delimited text file.
* USE ACCOUNTS NEW
* COPY TO overdue DELIMITED FOR !EMPTY( accounts->duedate ) ;
* .AND. DATE() - accounts->duedate > 30
* // Import new customer records.
* USE CUSTOMER NEW
* APPEND FROM customer DELIMITED
* $TESTS$
*
* $STATUS$
* S
* $COMPLIANCE$
* __dbDelim() is intended to be fully compliant with CA-Clipper's
* function of the same name and is the underlying implementation
* of the APPEND FROM DELIMITED and COPY TO DELIMITED commands.
* $PLATFORMS$
* All
* $FILES$
*
* $SEEALSO$
* __dbSDF(), APPEND FROM, COPY TO
* $END$
*/
HB_FILE_VER( "$Id$" )
FUNCTION __dbDelim( lExport, cFile, cDelimArg, aFields, bFor, bWhile, nNext, nRecord, lRest )
#define AppendEOL( handle ) FWRITE( handle, CHR( 13 ) + CHR( 10 ) )
#define AppendEOF( handle ) FWRITE( handle, CHR( 26 ) )
#define AppendSep( handle, cSep ) FWRITE( handle, cSep )
PROCEDURE __dbDelim( lExport, cFile, cDelimArg, aFields, bFor, bWhile, nNext, nRecord, lRest )
LOCAL index, handle, lWriteSep, cFileName := cFile, nStart, nCount, oErr
LOCAL cSeparator := ",", cDelim := CHR( 34 )
@@ -270,34 +211,19 @@ FUNCTION __dbDelim( lExport, cFile, cDelimArg, aFields, bFor, bWhile, nNext, nRe
END IF
*/
END IF
RETURN NIL
RETURN
STATIC FUNCTION ExportVar( handle, xField, cDelim )
LOCAL cText := "", lWrite := .F.
DO CASE
CASE VALTYPE( xField ) == "C"
cText := cDelim + TRIM( xField ) + cDelim
lWrite := .T.
FWRITE( handle, cDelim + TRIM( xField ) + cDelim )
CASE VALTYPE( xField ) == "D"
cText := DTOS( xField )
lWrite := .T.
FWRITE( handle, DTOS( xField ) )
CASE VALTYPE( xField ) == "L"
cText := IF( xField, "T", "F" )
lWrite := .T.
FWRITE( handle, iif( xField, "T", "F" ) )
CASE VALTYPE( xField ) == "N"
cText := LTRIM( STR( xField ) )
lWrite := .T.
FWRITE( handle, LTRIM( STR( xField ) ) )
OTHERWISE
RETURN .F.
END CASE
FWRITE( handle, cText )
RETURN lWrite
STATIC FUNCTION AppendEOL( handle )
STATIC cEOL := CHR( 13 ) + CHR( 10 )
RETURN FWRITE( handle, cEOL )
STATIC FUNCTION AppendEOF( handle )
STATIC cEOF := CHR( 26 )
RETURN FWRITE( handle, cEOF )
STATIC FUNCTION AppendSep( handle, cSep )
RETURN FWRITE( handle, cSep )
RETURN .T.

View File

@@ -7,7 +7,7 @@
* Copies the contents of a database to an SDF text file.
* Appends the contents of an SDF text file to a database.
*
* Copyright 2001 David G. Holm <dholm@jsd-llc.com>
* Copyright 2001-2002 David G. Holm <dholm@jsd-llc.com>
* www - http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
@@ -51,72 +51,16 @@
*
*/
#include <fileio.ch>
#include <hbclass.ch>
#include <error.ch>
#include "hbcommon.ch"
#include "fileio.ch"
#include "error.ch"
/* $DOC$
* $FUNCNAME$
* __dbSDF()
* $CATEGORY$
* Conversion
* $ONELINER$
* Copies the contents of a database to an SDF text file or
* appends the contents of an SDF text file to a database.
* $SYNTAX$
* __dbSDF( <lExport>, <xcFile>, [<aFields>],
* [<bFor>], [<bWhile>], [<nNext>], [<nRecord>], <lRest> ) --> NIL
* $ARGUMENTS$
* <lExport> If set to .T., copies records to an SDF file.
* If set to .F., append records from an SDF file.
* <xcFile> The name of the text file to copy to or append from.
* If a file extension is not specified, ".txt" is used by default.
* <aFields> An aray of field names to limit the processint to. If
* not specified, or if empty, then all fields are processed.
* <bFor> An optional code block containing a FOR expression that
* will reduce the number of records to be processed.
* <bWhile> An optional code block containing a WHILE expression
* that will reduce the number of records to be processed.
* <nNext> If present, but nRecord is not present, specifies to
* process this number of records, starting with the current record.
* A value of 0 means to process no records.
* <nRecord> If present, specifies the only record to process. A
* value of 0 means to process no records. Overrides nNext and lRest.
* <lRest> If lExport is .T., then if set to .T. and there are no
* nRecord, nNext, or bWhile arguments, processes all records from
* current to last.
* $RETURNS$
* NIL
* $DESCRIPTION$
* __dbSDF() copies all or selected contents of a database table
* to an SDF text file or appends all or selected contents of an
* SDF text file to a database table.
* $EXAMPLES$
* // Copy delinquent accounts into an SDF text file.
* USE ACCOUNTS NEW
* COPY TO overdue SDF FOR !EMPTY( accounts->duedate ) ;
* .AND. DATE() - accounts->duedate > 30
* // Import new customer records.
* USE CUSTOMER NEW
* APPEND FROM customer SDF
* $TESTS$
*
* $STATUS$
* S
* $COMPLIANCE$
* __dbSDF() is intended to be fully compliant with CA-Clipper's
* function of the same name and is the underlying implementation
* of the APPEND FROM SDF and COPY TO SDF commands.
* $PLATFORMS$
* All
* $FILES$
*
* $SEEALSO$
* __dbDelim(), APPEND FROM, COPY TO
* $END$
*/
HB_FILE_VER( "$Id$" )
FUNCTION __dbSDF( lExport, cFile, aFields, bFor, bWhile, nNext, nRecord, lRest )
#define AppendEOL( handle ) FWRITE( handle, CHR( 13 ) + CHR( 10 ) )
#define AppendEOF( handle ) FWRITE( handle, CHR( 26 ) )
PROCEDURE __dbSDF( lExport, cFile, aFields, bFor, bWhile, nNext, nRecord, lRest )
LOCAL index, handle, cFileName := cFile, nStart, nCount, oErr
// Process the file name argument.
@@ -246,31 +190,20 @@ FUNCTION __dbSDF( lExport, cFile, aFields, bFor, bWhile, nNext, nRecord, lRest )
END IF
*/
END IF
RETURN NIL
RETURN
STATIC FUNCTION ExportFixed( handle, xField )
LOCAL cText := "", lWrite := .F.
DO CASE
CASE VALTYPE( xField ) == "C"
cText := xField
lWrite := .T.
FWRITE( handle, xField )
CASE VALTYPE( xField ) == "D"
cText := DTOS( xField )
lWrite := .T.
FWRITE( handle, DTOS( xField ) )
CASE VALTYPE( xField ) == "L"
cText := IF( xField, "T", "F" )
lWrite := .T.
FWRITE( handle, iif( xField, "T", "F" ) )
CASE VALTYPE( xField ) == "N"
cText := STR( xField )
lWrite := .T.
FWRITE( handle, STR( xField ) )
OTHERWISE
RETURN .F.
END CASE
FWRITE( handle, cText )
RETURN lWrite
RETURN .T.
STATIC FUNCTION AppendEOL( handle )
STATIC cEOL := CHR( 13 ) + CHR( 10 )
RETURN FWRITE( handle, cEOL )
STATIC FUNCTION AppendEOF( handle )
STATIC cEOF := CHR( 26 )
RETURN FWRITE( handle, cEOF )