From 3e914f0d6e55a9de2e14fbc8de0f815909f98ca9 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 18 Oct 1999 05:51:30 +0000 Subject: [PATCH] 19991018-07:36 GMT+1 --- harbour/ChangeLog | 6 +++ harbour/source/rtl/Makefile | 1 + harbour/source/rtl/afields.prg | 79 ++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 harbour/source/rtl/afields.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6417b90dba..d7f7fd6267 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,9 @@ +19991018-07:36 GMT+1 Victor Szel + + source/rtl/afields.prg + source/rtl/Makefile + + AFIELDS() function added (by Jose Lalin) + WARNING ! Please add new file to non-GNU make systems. + 19991018-00:03 GMT+1 Victor Szel * source/vm/hvm.c + Support for overloading the following operators: diff --git a/harbour/source/rtl/Makefile b/harbour/source/rtl/Makefile index 914824a353..503bef5095 100644 --- a/harbour/source/rtl/Makefile +++ b/harbour/source/rtl/Makefile @@ -47,6 +47,7 @@ C_SOURCES=\ PRG_SOURCES=\ achoice.prg \ adir.prg \ + afields.prg \ alert.prg \ asort.prg \ browdb.prg \ diff --git a/harbour/source/rtl/afields.prg b/harbour/source/rtl/afields.prg new file mode 100644 index 0000000000..5a4dcd21ec --- /dev/null +++ b/harbour/source/rtl/afields.prg @@ -0,0 +1,79 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * AFIELDS() function + * + * Copyright 1999 Jose Lalin + * 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 of the License, or + * (at your option) any later version, with one exception: + * + * The exception is that if you link the Harbour Runtime Library (HRL) + * and/or the Harbour Virtual Machine (HVM) 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 HRL + * and/or HVM code into it. + * + * 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 program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit + * their web site at http://www.gnu.org/). + * + */ + +#include "dbstruct.ch" + +FUNCTION AFields( aFieldNames, aTypes, aWidths, aDecimals ) + + LOCAL aStruct := dbStruct() + LOCAL nLen := Len( aStruct ) + + IF nLen > 0 + + IF ISARRAY( aFieldNames ) + nLen := Min( nLen, Len( aFieldNames ) ) + ENDIF + + IF ISARRAY( aTypes ) + nLen := Min( nLen, Len( aTypes ) ) + ENDIF + + IF ISARRAY( aWidths ) + nLen := Min( nLen, Len( aWidths ) ) + ENDIF + + IF ISARRAY( aDecimals ) + nLen := Min( nLen, Len( aDecimals ) ) + ENDIF + + IF ISARRAY( aFieldNames ) + aEval( aStruct, {| aField, nIndex | aFieldNames[ nIndex ] := aField[ DBS_NAME ] }, 1, nLen ) + ENDIF + + IF ISARRAY( aTypes ) + aEval( aStruct, {| aField, nIndex | aTypes[ nIndex ] := aField[ DBS_TYPE ] }, 1, nLen ) + ENDIF + + IF ISARRAY( aWidths ) + aEval( aStruct, {| aField, nIndex | aWidths[ nIndex ] := aField[ DBS_LEN ] }, 1, nLen ) + ENDIF + + IF ISARRAY( aDecimals ) + aEval( aStruct, {| aField, nIndex | aDecimals[ nIndex ] := aField[ DBS_DEC ] }, 1, nLen ) + ENDIF + + ENDIF + + RETURN nLen