From c5e880877334ebe4bcf6ad9865a8b1c2a90296ca Mon Sep 17 00:00:00 2001 From: Luiz Rafael Culik Date: Wed, 14 Jun 2000 00:20:50 +0000 Subject: [PATCH] See changelog 20000613-21:20 GMT-3 --- harbour/doc/funclist.txt | 8 +-- harbour/source/rdd/dblist.prg | 118 ++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 4 deletions(-) create mode 100644 harbour/source/rdd/dblist.prg diff --git a/harbour/doc/funclist.txt b/harbour/doc/funclist.txt index 6d3eb069a6..66dd985f69 100644 --- a/harbour/doc/funclist.txt +++ b/harbour/doc/funclist.txt @@ -174,7 +174,7 @@ LUPDATE ;R; MAX ;R; MAXCOL ;R; MAXROW ;R; -MEMOEDIT ;N; +MEMOEDIT ;S; MEMOLINE ;R; MEMOREAD ;R; MEMORY ;S; @@ -289,13 +289,13 @@ __dbCopyXStruct ;R; __dbCreate ;R; __dbDelim ;N; __dbJoin ;N; -__dbList ;N; +__dbList ;R; __dbLocate ;N; __dbPack ;R; __dbSDF ;N; __dbSort ;N; __dbTotal ;N; -__dbUpdate ;N; +__dbUpdate ;R; __dbZap ;R; __Dir ;R; __Eject ;R; @@ -315,7 +315,7 @@ __SetFormat ;R; __SetFunction ;R; __TextRestore ;R; __TextSave ;R; -__TypeFile ;N; +__TypeFile ;R; __Wait ;R; __XRestScreen ;R; __XSaveScreen ;R; diff --git a/harbour/source/rdd/dblist.prg b/harbour/source/rdd/dblist.prg new file mode 100644 index 0000000000..22a8ccae00 --- /dev/null +++ b/harbour/source/rdd/dblist.prg @@ -0,0 +1,118 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * __DBLIST(), __DBUPDATE() functions + * + * Copyright 2000 Luiz Rafael Culik + * 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 "common.ch" +#include "set.ch" + +FUNCTION __dbList(lOff,aList,lAll,bFor,bWhile,nNext,nRec,lRest,lPrint,cFile) +Local bBlock,lPrinter,lExtra,cExtraFile,oError + +IF lOff + bBlock:={|| (Qout(iff(Deleted(), "*", " ")), aEval(aList, ; + {|cItem| qqout(eval(cItem),"")}))} +ELSE + bBlock:={|| (Qout(STR(Recno(),7), iff(Deleted(), "*", " ")), aEval(aList, ; + {|cItem| qqout(eval(cItem),"")}))} +ENDIF + +IF (!EMPTY(lPrint)) + lPrinter := SET(_SET_PRINTER,.T.) +ENDIF + +IF (!EMPTY(cFile)) + IF EMPTY(AT(".",cFile)) + cFile += ".txt" + ENDIF + lExtra := SET(_SET_EXTRA, .T.) + cExtraFile := SET(_SET_EXTRAFILE,cFile) +ENDIF +BEGIN SEQUENCE +IF (EMPTY(lAll) .and. EMPTY(bFor) .and. EMPTY(bWhile) .and. EMPTY(nNext) .and. ; + EMPTY(nRec) .and. EMPTY(lRest)) + EVAL(bBlock) +ELSE + DBEVAL(bBlock,bFor,bWhile,nNext,nRec,lRest) +ENDIF +RECOVER Using oError +END SEQUENCE +IF (!EMPTY(lPrint)) + set printer to (lPrinter) +ENDIF + +IF (!EMPTY(cFile)) + SET(_SET_EXTRA,lExtra) + SET(_SET_EXTRAFILE,cExtraFile) +ENDIF +IF oError != NIL + Break(oError) +Endif + +RETURN NIL + +FUNCTION __dbUpdate(cAlias,bKey,lRand,bFields) + + Local CurArea,oError,bBlock + Default lRand to .F. + DBGOTOP() + CurArea:=Select() + BEGIN SEQUENCE + DBSELECTAREA(cAlias) + DBGOTOP() + While !EOF() + bBlock:=EVAL(bKey) + DBSELECTAREA(CurArea) + IF lRand + dbSeek(bBlock, iff(.F. ,.T.,NIL)) + IF Found() + Eval(bFields) + Endif + ELSE + DO WHILE(Eval(bKey) < bBlock .AND. !EOF()) + dbSkip() + ENDDO + IF (Eval(bKey) == bBlock .AND. !EOF()) + Eval(bFields) + ENDIF + ENDIF + dbSelectArea(cAlias) + dbSkip() + ENDDO + RECOVER USING oError + END SEQUENCE + dbSelectArea(CurArea) + IF oError != NIL + Break(oError) + ENDIF +Return .T.