From f44b40c3efffd08c6dc4482ecc2b7f0eb6bdfff2 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Fri, 24 Aug 2012 13:03:57 +0000 Subject: [PATCH] 2012-08-24 15:01 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * harbour/doc/locks.txt * harbour/extras/hbapollo/ttable.prg * harbour/extras/hbapollo/use.c * harbour/extras/hbapollo/tindex.prg * harbour/extras/hbapollo/tools.c * harbour/extras/hbapollo/ttag.prg * harbour/extras/hbapollo/unsix.ch * harbour/extras/hbxlsxml/hbxlsxml.hbp * harbour/extras/hbxlsxml/xlsxml.prg * harbour/extras/hbxlsxml/xlsxml_s.prg * harbour/extras/hbxlsxml/tests/example.prg * harbour/extras/hbxlsxml/tests/example2.prg * harbour/extras/hbxlsxml/tests/example3.prg * harbour/extras/hbxlsxml/tests/hbmk.hbm * harbour/extras/hbxlsxml/xlsxml_y.prg * harbour/bin/3rdpatch.hb * harbour/contrib/hbxbp/tests/xbpqtc.prg * harbour/contrib/hbxbp/crt.prg * harbour/contrib/make.hb * harbour/contrib/gtwvg/genrc.prg * harbour/contrib/hbqt/tests/cls_dbstruct.prg * harbour/contrib/hbqt/tests/browarray.prg * harbour/contrib/hbqt/tests/ideui.hbp * harbour/contrib/hbqt/tests/dbfbrowserclass.prg * harbour/contrib/hbqt/tests/dbstruct.prg * harbour/contrib/hbqt/tests/dbfbrowser.prg * harbour/contrib/hbqt/qtsvg/hbqt_init.cpp * harbour/contrib/hbqt/qtsvg/hbqtsvg.hbm * harbour/contrib/hbqt/qtsvg/hbqtsvg.hbp * harbour/contrib/hbqt/qtsvg/hbqtsvg.ch * harbour/contrib/hbqt/qtsvg/hbqtsvg.hbc * harbour/contrib/hbqt/qtsvg/hbqtsvgs.hbp * harbour/contrib/hbqt/qtsvg/qth/filelist.hbm * harbour/contrib/hbqt/qtsvg/hbqtsvg.hbx * harbour/contrib/hbqt/gtqtc.hbc * harbour/contrib/hbqt/gtqtc/gtqtc.hbm * harbour/contrib/hbqt/gtqtc/gtqtc.h * harbour/contrib/hbqt/gtqtc/gtqtc.hbp * harbour/contrib/hbqt/gtqtc/gtqtc.hbc * harbour/contrib/hbqt/gtqtc/gtqtcs.hbp * harbour/contrib/hbqt/gtqtc/gtqtc.cpp * harbour/contrib/hbide/console.prg * harbour/contrib/hbide/uisrcmanager.prg * harbour/contrib/hbide/changelog.prg ! fixed hardcoded CRLF EOLs ! set svn:eol-style to native ! set svn:keywords to Author Date Id Revision --- harbour/ChangeLog | 49 ++ harbour/contrib/hbqt/tests/browarray.prg | 532 ++++++++++---------- harbour/extras/hbapollo/tindex.prg | 116 ++--- harbour/extras/hbapollo/tools.c | 208 ++++---- harbour/extras/hbapollo/ttable.prg | 392 +++++++-------- harbour/extras/hbapollo/ttag.prg | 210 ++++---- harbour/extras/hbapollo/unsix.ch | 166 +++--- harbour/extras/hbapollo/use.c | 610 +++++++++++------------ 8 files changed, 1166 insertions(+), 1117 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 7c7723d3fa..e4b36e95d7 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,55 @@ The license applies to all entries newer than 2009-04-28. */ +2012-08-24 15:01 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * harbour/doc/locks.txt + * harbour/extras/hbapollo/ttable.prg + * harbour/extras/hbapollo/use.c + * harbour/extras/hbapollo/tindex.prg + * harbour/extras/hbapollo/tools.c + * harbour/extras/hbapollo/ttag.prg + * harbour/extras/hbapollo/unsix.ch + * harbour/extras/hbxlsxml/hbxlsxml.hbp + * harbour/extras/hbxlsxml/xlsxml.prg + * harbour/extras/hbxlsxml/xlsxml_s.prg + * harbour/extras/hbxlsxml/tests/example.prg + * harbour/extras/hbxlsxml/tests/example2.prg + * harbour/extras/hbxlsxml/tests/example3.prg + * harbour/extras/hbxlsxml/tests/hbmk.hbm + * harbour/extras/hbxlsxml/xlsxml_y.prg + * harbour/bin/3rdpatch.hb + * harbour/contrib/hbxbp/tests/xbpqtc.prg + * harbour/contrib/hbxbp/crt.prg + * harbour/contrib/make.hb + * harbour/contrib/gtwvg/genrc.prg + * harbour/contrib/hbqt/tests/cls_dbstruct.prg + * harbour/contrib/hbqt/tests/browarray.prg + * harbour/contrib/hbqt/tests/ideui.hbp + * harbour/contrib/hbqt/tests/dbfbrowserclass.prg + * harbour/contrib/hbqt/tests/dbstruct.prg + * harbour/contrib/hbqt/tests/dbfbrowser.prg + * harbour/contrib/hbqt/qtsvg/hbqt_init.cpp + * harbour/contrib/hbqt/qtsvg/hbqtsvg.hbm + * harbour/contrib/hbqt/qtsvg/hbqtsvg.hbp + * harbour/contrib/hbqt/qtsvg/hbqtsvg.ch + * harbour/contrib/hbqt/qtsvg/hbqtsvg.hbc + * harbour/contrib/hbqt/qtsvg/hbqtsvgs.hbp + * harbour/contrib/hbqt/qtsvg/qth/filelist.hbm + * harbour/contrib/hbqt/qtsvg/hbqtsvg.hbx + * harbour/contrib/hbqt/gtqtc.hbc + * harbour/contrib/hbqt/gtqtc/gtqtc.hbm + * harbour/contrib/hbqt/gtqtc/gtqtc.h + * harbour/contrib/hbqt/gtqtc/gtqtc.hbp + * harbour/contrib/hbqt/gtqtc/gtqtc.hbc + * harbour/contrib/hbqt/gtqtc/gtqtcs.hbp + * harbour/contrib/hbqt/gtqtc/gtqtc.cpp + * harbour/contrib/hbide/console.prg + * harbour/contrib/hbide/uisrcmanager.prg + * harbour/contrib/hbide/changelog.prg + ! fixed hardcoded CRLF EOLs + ! set svn:eol-style to native + ! set svn:keywords to Author Date Id Revision + 2012-08-24 14:25 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * harbour/src/3rd/tiff/LICENSE ! fixed EOLs and set svn:eol-style to native diff --git a/harbour/contrib/hbqt/tests/browarray.prg b/harbour/contrib/hbqt/tests/browarray.prg index a0dc168bcc..22e040032b 100644 --- a/harbour/contrib/hbqt/tests/browarray.prg +++ b/harbour/contrib/hbqt/tests/browarray.prg @@ -1,266 +1,266 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * - * Copyright 2010 Carlos Bacco - * www - http://harbour-project.org - * - */ - -#include "hbqtgui.ch" -#include "hbtrace.ch" -#include "common.ch" - -STATIC oSize -STATIC nCX -STATIC nCY -STATIC aData -STATIC oColorC -STATIC oColorN -STATIC oColorD -STATIC oColorLY -STATIC oColorLN - -PROCEDURE Main() - LOCAL tb1, mo1, lay1, lay2, bt1, bt2, bt3, hd1, i - LOCAL oWnd, oDA, aStruct - LOCAL oID, oSM - - hbqt_errorsys() - - SET DATE ANSI - SET CENTURY ON - - oColorN := QColor( 100, 0,100 ) - oColorD := QColor( 150, 100, 0 ) - oColorLY:= QColor( 0, 150, 0 ) - oColorLN:= QColor( 200, 0, 0 ) - - aStruct := {} - AAdd( aStruct, { "Name" , "C", 8, 0 } ) - AAdd( aStruct, { "DOB" , "D", 8, 0 } ) - AAdd( aStruct, { "PAY" , "N", 5, 0 } ) - AAdd( aStruct, { "MARRIED", "L", 1, 0 } ) - - aData := {} - AAdd( aData, { "Andy" , SToD( "20120525" ), 200, .T. } ) - AAdd( aData, { "Tomy" , SToD( "20120617" ), 300, .F. } ) - AAdd( aData, { "Zindal", SToD( "20121213" ), 100, .F. } ) - - oWnd := QMainWindow() - oWnd:resize(640,460 ) - - oDA := QWidget() - oWnd:setCentralWidget( oDA ) - lay1 := QVBoxLayout( oDA ) - - nCX := 0 - nCY := 0 - tb1 := QTableView() - - mo1 := HBQAbstractItemModel( {| t, r, x, y| my_browse( aStruct, t, r, x, y ) } ) - tb1:setModel( mo1 ) - - oID := tb1:itemDelegate() - oID:connect( "commitData(QWidget*)", {| w | my_save( w, aStruct, @nCX, @nCY ) } ) - - oSM := tb1:selectionModel() - oSM:connect( "currentChanged(QModelIndex,QModelIndex)", {| n | my_select( n, @nCX, @nCY ) } ) - - hd1 := tb1:horizontalHeader() - FOR i := 1 To Len( aStruct ) - hd1:resizeSection( i - 1, aStruct[ i, 3 ] * 6 + 60 ) - NEXT - tb1:verticalHeader():setDefaultSectionSize( 24 ) - - oSize := QSize(50,24) - - lay1:addWidget( tb1 ) - - lay2 := QHBoxLayout() - lay1:addlayout( lay2 ) - - ( bt1 := QPushButton() ):SetText( "Add Row" ) - bt1:connect( "clicked()", {|| my_addRow( mo1, tb1 ) } ) - ( bt2 := QPushButton() ):SetText( "Ins Row" ) - bt2:connect( "clicked()", {|| my_insRow( mo1, tb1 ) } ) - ( bt3 := QPushButton() ):SetText( "Del Row" ) - bt3:connect( "clicked()", {|| my_delRow( mo1, tb1 ) } ) - - lay2:addWidget( bt1 ) - lay2:addWidget( bt2 ) - lay2:addStretch() - lay2:addWidget( bt3 ) - - oWnd:Show() - QApplication():exec() - - RETURN - -STATIC PROCEDURE my_save( qWidget, aStru, nCX, nCY ) - LOCAL cData := qWidget:property( "text" ):toString() - LOCAL nRow := nCY + 1 - LOCAL nCol := nCX + 1 - - SWITCH aStru[ nCol, 2 ] - CASE "C" - aData[ nRow, nCol ] := AllTrim( cData ) - EXIT - CASE "N" - aData[ nRow, nCol ] := Val( cData ) - EXIT - CASE "L" - aData[ nRow, nCol ] := Left( cData, 1 ) $ "YyTt" - EXIT - CASE "D" - aData[ nRow, nCol ] := CToD( cData ) - EXIT - ENDSWITCH - RETURN - -STATIC PROCEDURE my_select( qModelIndex, nCX, nCY ) - - nCX := qModelIndex:column() - nCY := qModelIndex:row() - - RETURN - -STATIC FUNCTION my_browse( aStru, t, role, nX, nY ) - LOCAL nRow := nY + 1 /* Harbour array is 1 based */ - LOCAL nCol := nX + 1 - - SWITCH t - CASE HBQT_QAIM_flags - RETURN Qt_ItemIsEnabled + Qt_ItemIsSelectable + Qt_ItemIsEditable; - - CASE HBQT_QAIM_data - - SWITCH role - CASE Qt_DisplayRole - SWITCH aStru[ nCol, 2 ] - CASE "C" - RETURN AllTrim( aData[ nRow, nCol ] ) - CASE "N" - RETURN hb_ntos( aData[ nRow, nCol ] ) - CASE "L" - RETURN iif( aData[ nRow, nCol ], "Yes", "No" ) - CASE "D" - RETURN DToC( aData[ nRow, nCol ] ) - ENDSWITCH - RETURN "?" - - CASE Qt_EditRole /* Here we can specify different formats for editing*/ - SWITCH aStru[ nCol, 2 ] - CASE "C" - RETURN AllTrim( aData[ nRow, nCol ] ) - CASE "N" - RETURN hb_ntos( aData[ nRow, nCol ] ) - CASE "L" - RETURN iif( aData[ nRow, nCol ], "Y", "N" ) - CASE "D" - RETURN DToC( aData[ nRow, nCol ] ) - ENDSWITCH - RETURN "?" - - CASE Qt_ForegroundRole - SWITCH aStru[ nCol, 2 ] - CASE "N" - RETURN oColorN - CASE "L" - RETURN iif( aData[ nRow, nCol ], oColorLY, oColorLN ) - CASE "D" - RETURN oColorD - ENDSWITCH - RETURN NIL - - CASE Qt_BackgroundRole - RETURN NIL - - CASE Qt_TextAlignmentRole - SWITCH aStru[ nCol, 2 ] - CASE "C" - RETURN Qt_AlignVCenter + Qt_AlignLeft - CASE "N" - RETURN Qt_AlignVCenter + Qt_AlignRight - ENDSWITCH - RETURN Qt_AlignCenter - ENDSWITCH - RETURN NIL - - CASE HBQT_QAIM_headerData - SWITCH role - CASE Qt_DisplayRole - IF nX == Qt_Horizontal - RETURN aStru[ nRow, 1 ] - ELSE - RETURN hb_NToS( nRow ) - ENDIF - - CASE Qt_TextAlignmentRole - IF nX == Qt_Horizontal - RETURN Qt_AlignCenter - ELSE - RETURN Qt_AlignVCenter + Qt_AlignRight - ENDIF - - CASE Qt_SizeHintRole - RETURN oSize - ENDSWITCH - RETURN NIL - - CASE HBQT_QAIM_rowCount - RETURN Len( aData ) - - CASE HBQT_QAIM_columnCount - RETURN Len( aStru ) - ENDSWITCH - - RETURN NIL - -STATIC FUNCTION connect( tb1, aStruct, nCX1, nCY1 ) - LOCAL oID, oSM - - oID := tb1:itemDelegate() - oID:connect( "commitData(QWidget*)", {| w | my_save( w, aStruct, @nCX1, @nCY1 ) } ) - - oSM := tb1:selectionModel() - oSM:connect( "currentChanged(QModelIndex,QModelIndex)", {| n | my_select( n, @nCX1, @nCY1 ) } ) - - RETURN NIL - -STATIC FUNCTION my_addRow( oHBQAbsModel, oTableView ) - STATIC nPay := 400 - - nPay += 30 - - AAdd( aData, { "Kitty", SToD( "20120625" ), nPay, .T. } ) - - oHBQAbsModel:reset() /* Re-populate the model */ - oTableView:selectRow( nCY ) - - RETURN .T. - -STATIC FUNCTION my_insRow( oHBQAbsModel, oTableView ) - STATIC nPay := 500 - - nPay += 150 - aData := hb_AIns( aData, nCY + 1, { "Lovely", SToD( "20010513" ), nPay, .T. }, .T. ) - - oHBQAbsModel:reset() - oTableView:selectRow( nCY ) - - RETURN .T. - -STATIC FUNCTION my_delRow( oHBQAbsModel, oTableView ) - - IF Len( aData ) > 1 - aData := hb_ADel( aData, nCY + 1, .T. ) - - oHBQAbsModel:reset() - oTableView:selectRow( Min( nCY, Len( aData ) - 1 ) ) - ENDIF - - RETURN .T. +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * + * Copyright 2010 Carlos Bacco + * www - http://harbour-project.org + * + */ + +#include "hbqtgui.ch" +#include "hbtrace.ch" +#include "common.ch" + +STATIC oSize +STATIC nCX +STATIC nCY +STATIC aData +STATIC oColorC +STATIC oColorN +STATIC oColorD +STATIC oColorLY +STATIC oColorLN + +PROCEDURE Main() + LOCAL tb1, mo1, lay1, lay2, bt1, bt2, bt3, hd1, i + LOCAL oWnd, oDA, aStruct + LOCAL oID, oSM + + hbqt_errorsys() + + SET DATE ANSI + SET CENTURY ON + + oColorN := QColor( 100, 0,100 ) + oColorD := QColor( 150, 100, 0 ) + oColorLY:= QColor( 0, 150, 0 ) + oColorLN:= QColor( 200, 0, 0 ) + + aStruct := {} + AAdd( aStruct, { "Name" , "C", 8, 0 } ) + AAdd( aStruct, { "DOB" , "D", 8, 0 } ) + AAdd( aStruct, { "PAY" , "N", 5, 0 } ) + AAdd( aStruct, { "MARRIED", "L", 1, 0 } ) + + aData := {} + AAdd( aData, { "Andy" , SToD( "20120525" ), 200, .T. } ) + AAdd( aData, { "Tomy" , SToD( "20120617" ), 300, .F. } ) + AAdd( aData, { "Zindal", SToD( "20121213" ), 100, .F. } ) + + oWnd := QMainWindow() + oWnd:resize(640,460 ) + + oDA := QWidget() + oWnd:setCentralWidget( oDA ) + lay1 := QVBoxLayout( oDA ) + + nCX := 0 + nCY := 0 + tb1 := QTableView() + + mo1 := HBQAbstractItemModel( {| t, r, x, y| my_browse( aStruct, t, r, x, y ) } ) + tb1:setModel( mo1 ) + + oID := tb1:itemDelegate() + oID:connect( "commitData(QWidget*)", {| w | my_save( w, aStruct, @nCX, @nCY ) } ) + + oSM := tb1:selectionModel() + oSM:connect( "currentChanged(QModelIndex,QModelIndex)", {| n | my_select( n, @nCX, @nCY ) } ) + + hd1 := tb1:horizontalHeader() + FOR i := 1 To Len( aStruct ) + hd1:resizeSection( i - 1, aStruct[ i, 3 ] * 6 + 60 ) + NEXT + tb1:verticalHeader():setDefaultSectionSize( 24 ) + + oSize := QSize(50,24) + + lay1:addWidget( tb1 ) + + lay2 := QHBoxLayout() + lay1:addlayout( lay2 ) + + ( bt1 := QPushButton() ):SetText( "Add Row" ) + bt1:connect( "clicked()", {|| my_addRow( mo1, tb1 ) } ) + ( bt2 := QPushButton() ):SetText( "Ins Row" ) + bt2:connect( "clicked()", {|| my_insRow( mo1, tb1 ) } ) + ( bt3 := QPushButton() ):SetText( "Del Row" ) + bt3:connect( "clicked()", {|| my_delRow( mo1, tb1 ) } ) + + lay2:addWidget( bt1 ) + lay2:addWidget( bt2 ) + lay2:addStretch() + lay2:addWidget( bt3 ) + + oWnd:Show() + QApplication():exec() + + RETURN + +STATIC PROCEDURE my_save( qWidget, aStru, nCX, nCY ) + LOCAL cData := qWidget:property( "text" ):toString() + LOCAL nRow := nCY + 1 + LOCAL nCol := nCX + 1 + + SWITCH aStru[ nCol, 2 ] + CASE "C" + aData[ nRow, nCol ] := AllTrim( cData ) + EXIT + CASE "N" + aData[ nRow, nCol ] := Val( cData ) + EXIT + CASE "L" + aData[ nRow, nCol ] := Left( cData, 1 ) $ "YyTt" + EXIT + CASE "D" + aData[ nRow, nCol ] := CToD( cData ) + EXIT + ENDSWITCH + RETURN + +STATIC PROCEDURE my_select( qModelIndex, nCX, nCY ) + + nCX := qModelIndex:column() + nCY := qModelIndex:row() + + RETURN + +STATIC FUNCTION my_browse( aStru, t, role, nX, nY ) + LOCAL nRow := nY + 1 /* Harbour array is 1 based */ + LOCAL nCol := nX + 1 + + SWITCH t + CASE HBQT_QAIM_flags + RETURN Qt_ItemIsEnabled + Qt_ItemIsSelectable + Qt_ItemIsEditable; + + CASE HBQT_QAIM_data + + SWITCH role + CASE Qt_DisplayRole + SWITCH aStru[ nCol, 2 ] + CASE "C" + RETURN AllTrim( aData[ nRow, nCol ] ) + CASE "N" + RETURN hb_ntos( aData[ nRow, nCol ] ) + CASE "L" + RETURN iif( aData[ nRow, nCol ], "Yes", "No" ) + CASE "D" + RETURN DToC( aData[ nRow, nCol ] ) + ENDSWITCH + RETURN "?" + + CASE Qt_EditRole /* Here we can specify different formats for editing*/ + SWITCH aStru[ nCol, 2 ] + CASE "C" + RETURN AllTrim( aData[ nRow, nCol ] ) + CASE "N" + RETURN hb_ntos( aData[ nRow, nCol ] ) + CASE "L" + RETURN iif( aData[ nRow, nCol ], "Y", "N" ) + CASE "D" + RETURN DToC( aData[ nRow, nCol ] ) + ENDSWITCH + RETURN "?" + + CASE Qt_ForegroundRole + SWITCH aStru[ nCol, 2 ] + CASE "N" + RETURN oColorN + CASE "L" + RETURN iif( aData[ nRow, nCol ], oColorLY, oColorLN ) + CASE "D" + RETURN oColorD + ENDSWITCH + RETURN NIL + + CASE Qt_BackgroundRole + RETURN NIL + + CASE Qt_TextAlignmentRole + SWITCH aStru[ nCol, 2 ] + CASE "C" + RETURN Qt_AlignVCenter + Qt_AlignLeft + CASE "N" + RETURN Qt_AlignVCenter + Qt_AlignRight + ENDSWITCH + RETURN Qt_AlignCenter + ENDSWITCH + RETURN NIL + + CASE HBQT_QAIM_headerData + SWITCH role + CASE Qt_DisplayRole + IF nX == Qt_Horizontal + RETURN aStru[ nRow, 1 ] + ELSE + RETURN hb_NToS( nRow ) + ENDIF + + CASE Qt_TextAlignmentRole + IF nX == Qt_Horizontal + RETURN Qt_AlignCenter + ELSE + RETURN Qt_AlignVCenter + Qt_AlignRight + ENDIF + + CASE Qt_SizeHintRole + RETURN oSize + ENDSWITCH + RETURN NIL + + CASE HBQT_QAIM_rowCount + RETURN Len( aData ) + + CASE HBQT_QAIM_columnCount + RETURN Len( aStru ) + ENDSWITCH + + RETURN NIL + +STATIC FUNCTION connect( tb1, aStruct, nCX1, nCY1 ) + LOCAL oID, oSM + + oID := tb1:itemDelegate() + oID:connect( "commitData(QWidget*)", {| w | my_save( w, aStruct, @nCX1, @nCY1 ) } ) + + oSM := tb1:selectionModel() + oSM:connect( "currentChanged(QModelIndex,QModelIndex)", {| n | my_select( n, @nCX1, @nCY1 ) } ) + + RETURN NIL + +STATIC FUNCTION my_addRow( oHBQAbsModel, oTableView ) + STATIC nPay := 400 + + nPay += 30 + + AAdd( aData, { "Kitty", SToD( "20120625" ), nPay, .T. } ) + + oHBQAbsModel:reset() /* Re-populate the model */ + oTableView:selectRow( nCY ) + + RETURN .T. + +STATIC FUNCTION my_insRow( oHBQAbsModel, oTableView ) + STATIC nPay := 500 + + nPay += 150 + aData := hb_AIns( aData, nCY + 1, { "Lovely", SToD( "20010513" ), nPay, .T. }, .T. ) + + oHBQAbsModel:reset() + oTableView:selectRow( nCY ) + + RETURN .T. + +STATIC FUNCTION my_delRow( oHBQAbsModel, oTableView ) + + IF Len( aData ) > 1 + aData := hb_ADel( aData, nCY + 1, .T. ) + + oHBQAbsModel:reset() + oTableView:selectRow( Min( nCY, Len( aData ) - 1 ) ) + ENDIF + + RETURN .T. diff --git a/harbour/extras/hbapollo/tindex.prg b/harbour/extras/hbapollo/tindex.prg index cb0b3ced08..a83714ecaf 100644 --- a/harbour/extras/hbapollo/tindex.prg +++ b/harbour/extras/hbapollo/tindex.prg @@ -1,58 +1,58 @@ -/* - * $Id: tindex.prg 9576 2012-07-17 16:41:57Z andijahja $ - */ - -/* - * SixAPI Project source code: - * - * Copyright 2010 Andi Jahja - * - * 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/). - */ - -#include "hbclass.ch" - -CLASS TIndex - - VAR cIndexFile /* Index File Name */ - VAR cExpression /* Index Expression */ - VAR iMode /* iOption: IDX_NONE=0 IDX_UNIQUE=1 IDX_EMPTY=2 */ - VAR lDescending /* BOOL lDescending */ - VAR cCondition /* FOR Condition */ - VAR cAlias - - METHOD New( cIndexFile, cExpression, iMode, lDescending, cCondition, cAlias ) - METHOD CREATE() - -ENDCLASS - -METHOD New( cIndexFile, cExpression, iMode, lDescending, cCondition, cAlias ) CLASS TIndex - - ::cIndexFile := cIndexFile /* Index File Name */ - ::cExpression := cExpression /* Index Expression */ - ::iMode := iMode /* iOption: IDX_NONE=0 IDX_UNIQUE=1 IDX_EMPTY=2 */ - ::lDescending := lDescending /* BOOL lDescending */ - ::cCondition := cCondition /* FOR Condition */ - ::cAlias := cAlias /* Alias */ - - RETURN Self - -METHOD CREATE() CLASS TIndex - - // This is For Single TAG Index File : DBFNTX - // DBFCDX and DBFNSX Should Use TAG - - RETURN sx_Index( ::cIndexFile, ::cExpression, ::iMode, ::lDescending, ::cCondition, ::cAlias ) +/* + * $Id$ + */ + +/* + * SixAPI Project source code: + * + * Copyright 2010 Andi Jahja + * + * 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/). + */ + +#include "hbclass.ch" + +CLASS TIndex + + VAR cIndexFile /* Index File Name */ + VAR cExpression /* Index Expression */ + VAR iMode /* iOption: IDX_NONE=0 IDX_UNIQUE=1 IDX_EMPTY=2 */ + VAR lDescending /* BOOL lDescending */ + VAR cCondition /* FOR Condition */ + VAR cAlias + + METHOD New( cIndexFile, cExpression, iMode, lDescending, cCondition, cAlias ) + METHOD CREATE() + +ENDCLASS + +METHOD New( cIndexFile, cExpression, iMode, lDescending, cCondition, cAlias ) CLASS TIndex + + ::cIndexFile := cIndexFile /* Index File Name */ + ::cExpression := cExpression /* Index Expression */ + ::iMode := iMode /* iOption: IDX_NONE=0 IDX_UNIQUE=1 IDX_EMPTY=2 */ + ::lDescending := lDescending /* BOOL lDescending */ + ::cCondition := cCondition /* FOR Condition */ + ::cAlias := cAlias /* Alias */ + + RETURN Self + +METHOD CREATE() CLASS TIndex + + // This is For Single TAG Index File : DBFNTX + // DBFCDX and DBFNSX Should Use TAG + + RETURN sx_Index( ::cIndexFile, ::cExpression, ::iMode, ::lDescending, ::cCondition, ::cAlias ) diff --git a/harbour/extras/hbapollo/tools.c b/harbour/extras/hbapollo/tools.c index 104ddd7fe5..014cccf0c4 100644 --- a/harbour/extras/hbapollo/tools.c +++ b/harbour/extras/hbapollo/tools.c @@ -1,104 +1,104 @@ -/* - * $Id: tools.c 9576 2012-07-17 16:41:57Z andijahja $ - */ - -/* - * SixAPI Project source code: - * - * Copyright 2010 Andi Jahja - * - * 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/). - */ - -#include "sxapi.h" - -const char * _sx_CheckFileExt( const char * szFileName ) -{ - static char s_szFileName[ HB_PATH_MAX ]; /* TOFIX */ - - PHB_FNAME pFileName = hb_fsFNameSplit( szFileName ); - - memset( s_szFileName, 0, HB_PATH_MAX ); - - if( ! pFileName->szExtension ) - { - pFileName->szExtension = ".dbf"; - hb_fsFNameMerge( s_szFileName, pFileName ); - } - else - hb_xstrcpy( s_szFileName, szFileName, 0 ); - - hb_xfree( pFileName ); - - return s_szFileName; -} - -double sx_GetPrivateProfileDouble( LPSTR lpSectionName, LPSTR lpEntryName, - LPSTR lpDefault, LPSTR lpIniFileName ) -{ - BYTE bBuffer[ 1024 ]; - - GetPrivateProfileString( lpSectionName, /* Section */ - lpEntryName, /* Entry */ - lpDefault, /* Default */ - ( char * ) bBuffer, /* Destination Buffer */ - sizeof( bBuffer ) - 1, lpIniFileName ); /* Inifile Name */ - if( ! ( *bBuffer ) ) - { - return atof( ( char * ) lpDefault ); - } - - return atof( ( char * ) bBuffer ); -} - -static void hb_objProcessMessage( PHB_ITEM pObj, PHB_DYNS pDyns, ULONG ulArg, ... ) -{ - hb_vmPushSymbol( hb_dynsymSymbol( pDyns ) ); - hb_vmPush( pObj ); - - if( ulArg ) - { - ULONG i; - - va_list ap; - - va_start( ap, ulArg ); - - for( i = 0; i < ulArg; i++ ) - { - hb_vmPush( va_arg( ap, PHB_ITEM ) ); - } - - va_end( ap ); - } - - hb_vmSend( ( HB_USHORT ) ulArg ); -} - -PHB_ITEM _sx_GetAlias( void ) -{ - PHB_ITEM pResult; - - static PHB_DYNS s_pFunc = NULL; - - if( ! s_pFunc ) - s_pFunc = hb_dynsymFind( "CALIAS" ); - - hb_objProcessMessage( hb_stackSelfItem(), s_pFunc, 0 ); - pResult = hb_itemNew( NULL ); - hb_itemCopy( pResult, hb_stackReturnItem() ); - return pResult; -} +/* + * $Id$ + */ + +/* + * SixAPI Project source code: + * + * Copyright 2010 Andi Jahja + * + * 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/). + */ + +#include "sxapi.h" + +const char * _sx_CheckFileExt( const char * szFileName ) +{ + static char s_szFileName[ HB_PATH_MAX ]; /* TOFIX */ + + PHB_FNAME pFileName = hb_fsFNameSplit( szFileName ); + + memset( s_szFileName, 0, HB_PATH_MAX ); + + if( ! pFileName->szExtension ) + { + pFileName->szExtension = ".dbf"; + hb_fsFNameMerge( s_szFileName, pFileName ); + } + else + hb_xstrcpy( s_szFileName, szFileName, 0 ); + + hb_xfree( pFileName ); + + return s_szFileName; +} + +double sx_GetPrivateProfileDouble( LPSTR lpSectionName, LPSTR lpEntryName, + LPSTR lpDefault, LPSTR lpIniFileName ) +{ + BYTE bBuffer[ 1024 ]; + + GetPrivateProfileString( lpSectionName, /* Section */ + lpEntryName, /* Entry */ + lpDefault, /* Default */ + ( char * ) bBuffer, /* Destination Buffer */ + sizeof( bBuffer ) - 1, lpIniFileName ); /* Inifile Name */ + if( ! ( *bBuffer ) ) + { + return atof( ( char * ) lpDefault ); + } + + return atof( ( char * ) bBuffer ); +} + +static void hb_objProcessMessage( PHB_ITEM pObj, PHB_DYNS pDyns, ULONG ulArg, ... ) +{ + hb_vmPushSymbol( hb_dynsymSymbol( pDyns ) ); + hb_vmPush( pObj ); + + if( ulArg ) + { + ULONG i; + + va_list ap; + + va_start( ap, ulArg ); + + for( i = 0; i < ulArg; i++ ) + { + hb_vmPush( va_arg( ap, PHB_ITEM ) ); + } + + va_end( ap ); + } + + hb_vmSend( ( HB_USHORT ) ulArg ); +} + +PHB_ITEM _sx_GetAlias( void ) +{ + PHB_ITEM pResult; + + static PHB_DYNS s_pFunc = NULL; + + if( ! s_pFunc ) + s_pFunc = hb_dynsymFind( "CALIAS" ); + + hb_objProcessMessage( hb_stackSelfItem(), s_pFunc, 0 ); + pResult = hb_itemNew( NULL ); + hb_itemCopy( pResult, hb_stackReturnItem() ); + return pResult; +} diff --git a/harbour/extras/hbapollo/ttable.prg b/harbour/extras/hbapollo/ttable.prg index 990d5dfb6b..8a529183e6 100644 --- a/harbour/extras/hbapollo/ttable.prg +++ b/harbour/extras/hbapollo/ttable.prg @@ -1,196 +1,196 @@ -/* - * $Id: ttable.prg 9576 2012-07-17 16:41:57Z andijahja $ - */ - -/* - * SixAPI Project source code: - * - * Copyright 2010 Andi Jahja - * - * 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/). - */ - -#include "hbclass.ch" - -#define SX_READWRITE 1 -#define SX_READONLY 2 -#define SX_EXCLUSIVE 3 - - // SX_DBINFO( CALIAS ) => ARRAY -#define SXINFO_AREA 1 // INTEGER -#define SXINFO_FILENAME 2 // STRING -#define SXINFO_ALIAS 3 // STRING -#define SXINFO_SHARED 4 // LOGICAL -#define SXINFO_READONLY 5 // LOGICAL -#define SXINFO_RDETYPE 6 // INTEGER -#define SXINFO_MODE 7 // INTEGER -#define SXINFO_RDD 8 // STRING -#define SXINFO_COMMITLEVEL 9 // INTEGER -#define SXINFO_RECSIZE 10 // INTEGER -#define SXINFO_FIELDCOUNT 11 // INTEGER -#define SXINFO_FIELDINFO 12 // ARRAY - -CLASS TApollo - - VAR cDBFFile - VAR cIndexFile - VAR cAlias - VAR nWorkArea - VAR nOpenMode INIT SX_READWRITE // { "READWRITE","READONLY","EXCLUSIVE" }; - VAR nCommitLevel INIT 1 // 1 or 2 - VAR cRDD // "SDENTX","SDEFOX","SDENSX","SDENSX_DBT" - VAR aFieldName INIT {} - - METHOD New( cDBFFile, nOpenMode ) - METHOD Open( nOpenMode ) - METHOD CLOSE() - METHOD RecCount() - METHOD LastRec() - METHOD RecNo() - METHOD COMMIT() - METHOD dbGoTop() - METHOD dbGoto( nRecNo ) - METHOD dbGoBottom() - METHOD dbSkip( nSkip ) - METHOD FCount() - METHOD FieldName( iFieldNum ) - METHOD FieldGet( cFieldName ) - METHOD BOF() - METHOD EOF() - METHOD REPLACE( cpFieldName, xData ) - METHOD dbSeek( cSeek ) - METHOD Found() - METHOD DBLocate( cpExpression, iDirection, bContinue ) - -ENDCLASS - -METHOD New( cDBFFile, nOpenMode ) CLASS TApollo - - ::cDBFFile := cDBFFile - ::nOpenMode := nOpenMode - - RETURN Self - -METHOD Open( nOpenMode ) CLASS TApollo - - LOCAL i, j, cField - LOCAL hClass := self:ClassH - - IF ValType( nOpenMode ) == "N" - ::nOpenMode := nOpenMode - ENDIF - - ::nWorkArea := sx_Use( ; - ::cDBFFile, ; - ::cAlias, ; - ::nOpenMode, ; - ::cRDD, ; - ::nCommitLevel ) - - j := sx_FieldCount( ::cAlias ) - - FOR i := 1 TO j - cField := sx_FieldName( i, ::cAlias ) - AAdd( ::aFieldName, cField ) - __clsAddMsg( hClass, cField, __blockGet( cField ), HB_OO_MSG_INLINE ) - __clsAddMsg( hClass, "_" + cField, __blockPut( cField ), HB_OO_MSG_INLINE ) - NEXT - - RETURN Self - -METHOD RecCount() CLASS TApollo - - RETURN sx_RecCount( ::cAlias ) - -METHOD LastRec() CLASS TApollo - - RETURN sx_RecCount( ::cAlias ) - -METHOD CLOSE() CLASS TApollo - - RETURN sx_Close( ::cAlias ) - -METHOD RecNo() CLASS TApollo - - RETURN sx_RecNo( ::cAlias ) - -METHOD dbGoto( nRecNo ) CLASS TApollo - - RETURN sx_Go( nRecNo, ::cAlias ) - -METHOD dbGoTop() CLASS TApollo - - RETURN sx_GoTop( ::cAlias ) - -METHOD dbGoBottom() CLASS TApollo - - RETURN sx_GoBottom( ::cAlias ) - -METHOD FCount() CLASS TApollo - - RETURN sx_FieldCount( ::cAlias ) - -METHOD FieldName( iFieldNum ) CLASS TApollo - - RETURN sx_FieldName( iFieldNum, ::cAlias ) - -METHOD FieldGet( cFieldName ) CLASS TApollo - - RETURN sx_FieldGet( cFieldName, ::cAlias ) - -METHOD BOF() CLASS TApollo - - RETURN sx_Bof( ::cAlias ) - -METHOD EOF() CLASS TApollo - - RETURN sx_Eof( ::cAlias ) - -METHOD COMMIT() CLASS TApollo - - RETURN sx_Commit( ::cAlias ) - -METHOD dbSkip( nSkip ) CLASS TApollo - - IF nSkip == NIL - nSkip := 1 - ENDIF - - RETURN sx_Skip( nSkip, ::cAlias ) - -METHOD REPLACE( cpFieldName, xData ) CLASS TAPOLLO - - RETURN sx_Replace( cpFieldName, xData, ::cAlias ) - -METHOD dbSeek( cSeek ) CLASS TAPOLLO - - RETURN sx_Seek( cSeek, ::cAlias ) - -METHOD Found() CLASS TAPOLLO - - RETURN sx_Found( ::cAlias ) - -METHOD DBLocate( cpExpression, iDirection, bContinue ) CLASS TAPOLLO - - RETURN sx_Locate( cpExpression, iDirection, bContinue, ::cAlias ) - -STATIC FUNCTION __blockGet( cField ) - - RETURN {| self | sx_FieldGet( cField, ::cAlias ) } - -STATIC FUNCTION __blockPut( cField ) - - RETURN {| self, xval | iif( xval == nil, , sx_Replace( cField, xval, ::cAlias ) ) } +/* + * $Id$ + */ + +/* + * SixAPI Project source code: + * + * Copyright 2010 Andi Jahja + * + * 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/). + */ + +#include "hbclass.ch" + +#define SX_READWRITE 1 +#define SX_READONLY 2 +#define SX_EXCLUSIVE 3 + + // SX_DBINFO( CALIAS ) => ARRAY +#define SXINFO_AREA 1 // INTEGER +#define SXINFO_FILENAME 2 // STRING +#define SXINFO_ALIAS 3 // STRING +#define SXINFO_SHARED 4 // LOGICAL +#define SXINFO_READONLY 5 // LOGICAL +#define SXINFO_RDETYPE 6 // INTEGER +#define SXINFO_MODE 7 // INTEGER +#define SXINFO_RDD 8 // STRING +#define SXINFO_COMMITLEVEL 9 // INTEGER +#define SXINFO_RECSIZE 10 // INTEGER +#define SXINFO_FIELDCOUNT 11 // INTEGER +#define SXINFO_FIELDINFO 12 // ARRAY + +CLASS TApollo + + VAR cDBFFile + VAR cIndexFile + VAR cAlias + VAR nWorkArea + VAR nOpenMode INIT SX_READWRITE // { "READWRITE","READONLY","EXCLUSIVE" }; + VAR nCommitLevel INIT 1 // 1 or 2 + VAR cRDD // "SDENTX","SDEFOX","SDENSX","SDENSX_DBT" + VAR aFieldName INIT {} + + METHOD New( cDBFFile, nOpenMode ) + METHOD Open( nOpenMode ) + METHOD CLOSE() + METHOD RecCount() + METHOD LastRec() + METHOD RecNo() + METHOD COMMIT() + METHOD dbGoTop() + METHOD dbGoto( nRecNo ) + METHOD dbGoBottom() + METHOD dbSkip( nSkip ) + METHOD FCount() + METHOD FieldName( iFieldNum ) + METHOD FieldGet( cFieldName ) + METHOD BOF() + METHOD EOF() + METHOD REPLACE( cpFieldName, xData ) + METHOD dbSeek( cSeek ) + METHOD Found() + METHOD DBLocate( cpExpression, iDirection, bContinue ) + +ENDCLASS + +METHOD New( cDBFFile, nOpenMode ) CLASS TApollo + + ::cDBFFile := cDBFFile + ::nOpenMode := nOpenMode + + RETURN Self + +METHOD Open( nOpenMode ) CLASS TApollo + + LOCAL i, j, cField + LOCAL hClass := self:ClassH + + IF ValType( nOpenMode ) == "N" + ::nOpenMode := nOpenMode + ENDIF + + ::nWorkArea := sx_Use( ; + ::cDBFFile, ; + ::cAlias, ; + ::nOpenMode, ; + ::cRDD, ; + ::nCommitLevel ) + + j := sx_FieldCount( ::cAlias ) + + FOR i := 1 TO j + cField := sx_FieldName( i, ::cAlias ) + AAdd( ::aFieldName, cField ) + __clsAddMsg( hClass, cField, __blockGet( cField ), HB_OO_MSG_INLINE ) + __clsAddMsg( hClass, "_" + cField, __blockPut( cField ), HB_OO_MSG_INLINE ) + NEXT + + RETURN Self + +METHOD RecCount() CLASS TApollo + + RETURN sx_RecCount( ::cAlias ) + +METHOD LastRec() CLASS TApollo + + RETURN sx_RecCount( ::cAlias ) + +METHOD CLOSE() CLASS TApollo + + RETURN sx_Close( ::cAlias ) + +METHOD RecNo() CLASS TApollo + + RETURN sx_RecNo( ::cAlias ) + +METHOD dbGoto( nRecNo ) CLASS TApollo + + RETURN sx_Go( nRecNo, ::cAlias ) + +METHOD dbGoTop() CLASS TApollo + + RETURN sx_GoTop( ::cAlias ) + +METHOD dbGoBottom() CLASS TApollo + + RETURN sx_GoBottom( ::cAlias ) + +METHOD FCount() CLASS TApollo + + RETURN sx_FieldCount( ::cAlias ) + +METHOD FieldName( iFieldNum ) CLASS TApollo + + RETURN sx_FieldName( iFieldNum, ::cAlias ) + +METHOD FieldGet( cFieldName ) CLASS TApollo + + RETURN sx_FieldGet( cFieldName, ::cAlias ) + +METHOD BOF() CLASS TApollo + + RETURN sx_Bof( ::cAlias ) + +METHOD EOF() CLASS TApollo + + RETURN sx_Eof( ::cAlias ) + +METHOD COMMIT() CLASS TApollo + + RETURN sx_Commit( ::cAlias ) + +METHOD dbSkip( nSkip ) CLASS TApollo + + IF nSkip == NIL + nSkip := 1 + ENDIF + + RETURN sx_Skip( nSkip, ::cAlias ) + +METHOD REPLACE( cpFieldName, xData ) CLASS TAPOLLO + + RETURN sx_Replace( cpFieldName, xData, ::cAlias ) + +METHOD dbSeek( cSeek ) CLASS TAPOLLO + + RETURN sx_Seek( cSeek, ::cAlias ) + +METHOD Found() CLASS TAPOLLO + + RETURN sx_Found( ::cAlias ) + +METHOD DBLocate( cpExpression, iDirection, bContinue ) CLASS TAPOLLO + + RETURN sx_Locate( cpExpression, iDirection, bContinue, ::cAlias ) + +STATIC FUNCTION __blockGet( cField ) + + RETURN {| self | sx_FieldGet( cField, ::cAlias ) } + +STATIC FUNCTION __blockPut( cField ) + + RETURN {| self, xval | iif( xval == nil, , sx_Replace( cField, xval, ::cAlias ) ) } diff --git a/harbour/extras/hbapollo/ttag.prg b/harbour/extras/hbapollo/ttag.prg index 3cbaef2019..5b88f4095e 100644 --- a/harbour/extras/hbapollo/ttag.prg +++ b/harbour/extras/hbapollo/ttag.prg @@ -1,105 +1,105 @@ -/* - * $Id: ttag.prg 9576 2012-07-17 16:41:57Z andijahja $ - */ - -/* - * SixAPI Project source code: - * - * Copyright 2010 Andi Jahja - * - * 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/). - */ - -#include "hbclass.ch" - -CLASS TTag - - VAR cIndexFile /* Index File Name */ - VAR aTagName INIT {} /* Index Tag Name */ - VAR aExpression INIT {} /* Index Expression */ - VAR iMode /* iOption: IDX_NONE=0 IDX_UNIQUE=1 IDX_EMPTY=2 */ - VAR lDescending /* BOOL lDescending */ - VAR cCondition /* FOR Condition */ - VAR cAlias - - METHOD New( cIndexFile, atagName, aExpression, iMode, lDescending, cCondition, cAlias ) - METHOD CREATE( lEraseOld ) - METHOD Open() - METHOD CLOSE() - METHOD SetOrder( xOrder ) /* nOrder OR cOrder */ - METHOD TagCount() - METHOD IndexOrd() - -ENDCLASS - -METHOD CLOSE() CLASS TTag - - RETURN sx_indexClose( ::cAlias ) - -METHOD IndexOrd() CLASS TTag - - RETURN SX_INDEXORD( ::cAlias ) - -METHOD SetOrder( xOrder ) CLASS TTag - - RETURN sx_setOrder( xOrder, ::cAlias ) - -METHOD Open() CLASS TTag - - RETURN Sx_IndexOpen( ::cIndexFile, ::cAlias ) - -METHOD TagCount() CLASS TTag - - RETURN sx_TagCount( ::cAlias ) - -METHOD New( cIndexFile, atagName, aExpression, iMode, lDescending, cCondition, cAlias ) CLASS TTag - - ::cIndexFile := cIndexFile /* Index File Name */ - ::aTagName := aTagName /* Index TagName */ - ::aExpression := aExpression /* Index Expression */ - ::iMode := iMode /* iOption: IDX_NONE=0 IDX_UNIQUE=1 IDX_EMPTY=2 */ - ::lDescending := lDescending /* BOOL lDescending */ - ::cCondition := cCondition /* FOR Condition */ - ::cAlias := cAlias /* Alias */ - - RETURN Self - -METHOD CREATE( lEraseOld ) CLASS TTag - - // This is For MULTI TAG Index File : DBFNSX and DBFCDX - // DBFNTX Should Use TIndex - LOCAL i, ul, nResult - - IF lEraseOld == NIL - lEraseOld := .T. - ENDIF - - IF lEraseOld .AND. File( ::cIndexFile ) - FErase( ::cIndexFile ) - ENDIF - - IF ! Empty( ::aTagName ) .AND. ! Empty( ::aExpression ) .AND. ; - ( ul := Len( ::aTagName ) ) == Len( ::aExpression ) - - FOR i := 1 TO ul - nResult := sx_IndexTag( ::cIndexFile, ::aTagName[ i ], ::aExpression[ i ], ::iMode, ::lDescending, ::cCondition, ::cAlias ) - NEXT - - RETURN nResult - - ENDIF - - RETURN 0 +/* + * $Id$ + */ + +/* + * SixAPI Project source code: + * + * Copyright 2010 Andi Jahja + * + * 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/). + */ + +#include "hbclass.ch" + +CLASS TTag + + VAR cIndexFile /* Index File Name */ + VAR aTagName INIT {} /* Index Tag Name */ + VAR aExpression INIT {} /* Index Expression */ + VAR iMode /* iOption: IDX_NONE=0 IDX_UNIQUE=1 IDX_EMPTY=2 */ + VAR lDescending /* BOOL lDescending */ + VAR cCondition /* FOR Condition */ + VAR cAlias + + METHOD New( cIndexFile, atagName, aExpression, iMode, lDescending, cCondition, cAlias ) + METHOD CREATE( lEraseOld ) + METHOD Open() + METHOD CLOSE() + METHOD SetOrder( xOrder ) /* nOrder OR cOrder */ + METHOD TagCount() + METHOD IndexOrd() + +ENDCLASS + +METHOD CLOSE() CLASS TTag + + RETURN sx_indexClose( ::cAlias ) + +METHOD IndexOrd() CLASS TTag + + RETURN SX_INDEXORD( ::cAlias ) + +METHOD SetOrder( xOrder ) CLASS TTag + + RETURN sx_setOrder( xOrder, ::cAlias ) + +METHOD Open() CLASS TTag + + RETURN Sx_IndexOpen( ::cIndexFile, ::cAlias ) + +METHOD TagCount() CLASS TTag + + RETURN sx_TagCount( ::cAlias ) + +METHOD New( cIndexFile, atagName, aExpression, iMode, lDescending, cCondition, cAlias ) CLASS TTag + + ::cIndexFile := cIndexFile /* Index File Name */ + ::aTagName := aTagName /* Index TagName */ + ::aExpression := aExpression /* Index Expression */ + ::iMode := iMode /* iOption: IDX_NONE=0 IDX_UNIQUE=1 IDX_EMPTY=2 */ + ::lDescending := lDescending /* BOOL lDescending */ + ::cCondition := cCondition /* FOR Condition */ + ::cAlias := cAlias /* Alias */ + + RETURN Self + +METHOD CREATE( lEraseOld ) CLASS TTag + + // This is For MULTI TAG Index File : DBFNSX and DBFCDX + // DBFNTX Should Use TIndex + LOCAL i, ul, nResult + + IF lEraseOld == NIL + lEraseOld := .T. + ENDIF + + IF lEraseOld .AND. File( ::cIndexFile ) + FErase( ::cIndexFile ) + ENDIF + + IF ! Empty( ::aTagName ) .AND. ! Empty( ::aExpression ) .AND. ; + ( ul := Len( ::aTagName ) ) == Len( ::aExpression ) + + FOR i := 1 TO ul + nResult := sx_IndexTag( ::cIndexFile, ::aTagName[ i ], ::aExpression[ i ], ::iMode, ::lDescending, ::cCondition, ::cAlias ) + NEXT + + RETURN nResult + + ENDIF + + RETURN 0 diff --git a/harbour/extras/hbapollo/unsix.ch b/harbour/extras/hbapollo/unsix.ch index a12cec332e..e6bd66532d 100644 --- a/harbour/extras/hbapollo/unsix.ch +++ b/harbour/extras/hbapollo/unsix.ch @@ -1,83 +1,83 @@ -/* - * $Id: unsix.ch 9576 2012-07-17 16:41:57Z andijahja $ - */ - -/* - * SixAPI Project source code: - * - * Copyright 2010 Andi Jahja - * - * 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/). - */ - -#ifndef __UNSIX__ -#define __UNSIX__ - -#xuntranslate USE [ALIAS <(cAlias)>] [ <(cRDD)>] [VAR ] [<(cOpenMode)>] -#xuntranslate CREATE [VAR ] [ ] [ALIAS ] -#xuntranslate SET DATE -#xuntranslate REPLACE WITH -#xuntranslate INDEX ON TO [ FOR ] [] [] -#xuntranslate Seek() -#xuntranslate Found() - -#xuntranslate SET TRIM -#xuntranslate SET SOFTSEEK -#xuntranslate SET CENTURY -#xuntranslate SET EXACT -#xuntranslate SET DELETED -#xuntranslate SET EPOCH [TO] -#xuntranslate SET LOCK TIMEOUT -#xuntranslate SET [FILE] HANDLE [TO] - -#xuntranslate SKIP [] -#xuntranslate Bof() -#xuntranslate Eof() -#xuntranslate RecCount() -#xuntranslate SetSoftSeek([]) -#xuntranslate RecNo() -#xuntranslate SetDateFormat( ) - -#xuntranslate Alias() -#xuntranslate FCount() -#xuntranslate FieldPut(,) -#xuntranslate FieldGet() -#xuntranslate FieldGetStr() -#xuntranslate FieldGetDtos() -#xuntranslate FieldGetJulian() -#xuntranslate FieldPos() -#xuntranslate FieldName() -#xuntranslate FieldType() -#xuntranslate FieldWidth() -#xuntranslate FieldOffset() -#xuntranslate FieldDecimals() - -#xuncommand APPEND BLANK -#xuncommand GO [TO] -#xuncommand GO TOP -#xuncommand GO TO TOP -#xuncommand GOTOP -#xuncommand GO BOTTOM -#xuncommand GO TO BOTTOM -#xuncommand GOBOTTOM -#xuncommand ZAP -#xuncommand COMMIT -#xuncommand CLOSE ALL -#xuncommand CLOSE DATABASE -#xuncommand CLOSE DATA -#xuncommand PACK - -#endif // end __UNSIX__ +/* + * $Id$ + */ + +/* + * SixAPI Project source code: + * + * Copyright 2010 Andi Jahja + * + * 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/). + */ + +#ifndef __UNSIX__ +#define __UNSIX__ + +#xuntranslate USE [ALIAS <(cAlias)>] [ <(cRDD)>] [VAR ] [<(cOpenMode)>] +#xuntranslate CREATE [VAR ] [ ] [ALIAS ] +#xuntranslate SET DATE +#xuntranslate REPLACE WITH +#xuntranslate INDEX ON TO [ FOR ] [] [] +#xuntranslate Seek() +#xuntranslate Found() + +#xuntranslate SET TRIM +#xuntranslate SET SOFTSEEK +#xuntranslate SET CENTURY +#xuntranslate SET EXACT +#xuntranslate SET DELETED +#xuntranslate SET EPOCH [TO] +#xuntranslate SET LOCK TIMEOUT +#xuntranslate SET [FILE] HANDLE [TO] + +#xuntranslate SKIP [] +#xuntranslate Bof() +#xuntranslate Eof() +#xuntranslate RecCount() +#xuntranslate SetSoftSeek([]) +#xuntranslate RecNo() +#xuntranslate SetDateFormat( ) + +#xuntranslate Alias() +#xuntranslate FCount() +#xuntranslate FieldPut(,) +#xuntranslate FieldGet() +#xuntranslate FieldGetStr() +#xuntranslate FieldGetDtos() +#xuntranslate FieldGetJulian() +#xuntranslate FieldPos() +#xuntranslate FieldName() +#xuntranslate FieldType() +#xuntranslate FieldWidth() +#xuntranslate FieldOffset() +#xuntranslate FieldDecimals() + +#xuncommand APPEND BLANK +#xuncommand GO [TO] +#xuncommand GO TOP +#xuncommand GO TO TOP +#xuncommand GOTOP +#xuncommand GO BOTTOM +#xuncommand GO TO BOTTOM +#xuncommand GOBOTTOM +#xuncommand ZAP +#xuncommand COMMIT +#xuncommand CLOSE ALL +#xuncommand CLOSE DATABASE +#xuncommand CLOSE DATA +#xuncommand PACK + +#endif // end __UNSIX__ diff --git a/harbour/extras/hbapollo/use.c b/harbour/extras/hbapollo/use.c index ad11be9e38..3781f95b71 100644 --- a/harbour/extras/hbapollo/use.c +++ b/harbour/extras/hbapollo/use.c @@ -1,305 +1,305 @@ -/* - * $Id: use.c 9576 2012-07-17 16:41:57Z andijahja $ - */ - -/* - * SixAPI Project source code: - * - * Copyright 2010 Andi Jahja - * - * 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/). - */ -#include "sxapi.h" - -static const char * s_cRDD[] = { "SDENTX", "SDEFOX", "SDENSX", "SDENSX_DBT" }; -static const char * s_aDescription[] = -{ - "WORKAREA (INTEGER)", "FILENAME (STRING)", "ALIAS (STRING)", - "SHARED (BOOL)", "READONLY (BOOL)", "RDE TYTE (INTEGER)", - "OPEN MODE (INTEGER)", "RDE TYPE (STRING)", "COMMIT LEVEL (INTEGER)", - "RECSIZE (INTEGER)", "FIELD COUNT (INTEGER)", "DBF STRUCTURE (ARRAY)" -}; - -static void _sx_UseGlobalInfo( SX_DBOPENINFO OpenInfo ) -{ - PHB_ITEM pData = hb_itemNew( NULL ); - PHB_ITEM pItem = hb_itemNew( NULL ); - - hb_arrayNew( pItem, 12 ); /* Elements of SX_DBOPENINFO */ - hb_arraySet( pItem, 1, hb_itemPutNI( pData, OpenInfo.uiArea ) ); - hb_arraySet( pItem, 2, hb_itemPutC( pData, OpenInfo.cFilename ) ); - hb_arraySet( pItem, 3, hb_itemPutC( pData, OpenInfo.cAlias ) ); - hb_arraySet( pItem, 4, hb_itemPutL( pData, OpenInfo.fShared ) ); - hb_arraySet( pItem, 5, hb_itemPutL( pData, OpenInfo.fReadonly ) ); - hb_arraySet( pItem, 6, hb_itemPutNI( pData, OpenInfo.iRDEType ) ); - hb_arraySet( pItem, 7, hb_itemPutNI( pData, OpenInfo.iMode ) ); - hb_arraySet( pItem, 8, hb_itemPutC( pData, OpenInfo.cRDD ) ); - hb_arraySet( pItem, 9, hb_itemPutNI( pData, OpenInfo.iCommitLevel ) ); - hb_arraySet( pItem, 10, hb_itemPutNI( pData, OpenInfo.iRecSize ) ); - hb_arraySet( pItem, 11, hb_itemPutNI( pData, OpenInfo.iFieldCount ) ); - hb_arraySet( pItem, 12, OpenInfo.aFieldInfo ); - hb_arrayAdd( Opened_DBF_Property, pItem ); - - hb_itemRelease( pData ); - hb_itemRelease( pItem ); -} - -void _sx_SetDBFInfo( int iOpenedArea, const char * szAlias, int iOpenMode, - int iRDEType ) -{ - SX_DBOPENINFO OpenInfo; - PHB_ITEM pStruct = _sx_DbStruct(); - - OpenInfo.uiArea = ( HB_USHORT ) iOpenedArea; - OpenInfo.cFilename = ( char * ) sx_BaseName(); - OpenInfo.cAlias = szAlias; - OpenInfo.fShared = ( ( iOpenMode == 0 ) ? TRUE : FALSE ); - OpenInfo.fReadonly = ( ( iOpenMode == READONLY ) ? TRUE : FALSE ); - OpenInfo.iRDEType = ( HB_USHORT ) iRDEType; - OpenInfo.iMode = ( HB_USHORT ) iOpenMode; - OpenInfo.cRDD = s_cRDD[ iRDEType - 1 ]; - OpenInfo.iCommitLevel = ( HB_USHORT ) sx_GetCommitLevel( ( WORD ) iOpenedArea ); - OpenInfo.iRecSize = ( HB_USHORT ) sx_RecSize(); - OpenInfo.iFieldCount = sx_FieldCount(); - OpenInfo.aFieldInfo = hb_itemNew( NULL ); - hb_itemCopy( OpenInfo.aFieldInfo, pStruct /* _sx_DbStruct() */ ); - _sx_UseGlobalInfo( OpenInfo ); - hb_itemRelease( OpenInfo.aFieldInfo ); - hb_itemRelease( pStruct ); -} - -HB_FUNC( SX_USE ) -{ - if( HB_ISCHAR( 1 ) ) - { - PBYTE szDBFFileName = ( PBYTE ) _sx_CheckFileExt( hb_parc( 1 ) ); - - if( hb_fsFileExists( ( const char * ) szDBFFileName ) ) - { - char * szAlias = NULL; - HB_BOOL bIsAlloc; - int iRDEType; - int iOpenMode; - int iOpenedArea; - - /* Alias Passed? */ - if( HB_ISCHAR( 2 ) ) - { - szAlias = ( char * ) hb_parc( 2 ); - bIsAlloc = ( strlen( szAlias ) == 0 ); - } - else - bIsAlloc = HB_TRUE; - - if( bIsAlloc ) - { - szAlias = _sx_AutoAlias( hb_parc( 1 ) ); - hb_storc( szAlias, 2 ); - } - - /* Open Mode Passed? */ - if( HB_ISCHAR( 3 ) ) - iOpenMode = _sx_CheckOpenMode( hb_parc( 3 ) ); - else if( HB_ISNUM( 3 ) ) - iOpenMode = hb_parni( 3 ); - else - iOpenMode = READWRITE; - - /* RDE Type Passed? */ - iRDEType = HB_ISCHAR( 4 ) ? _sx_CheckRDD( hb_parc( 4 ) ) : i_sxApi_RDD_Default; - - if( HB_ISNUM( 5 ) ) - { - UINT iCommitLevel = hb_parni( 5 ); - - if( iCommitLevel > 2 ) - iCommitLevel = 2; - - iOpenedArea = sx_UseEx( szDBFFileName, ( PBYTE ) szAlias, ( WORD ) iOpenMode, - ( WORD ) iRDEType, ( WORD ) iCommitLevel ); - } - else - { - iOpenedArea = sx_Use( szDBFFileName, ( PBYTE ) szAlias, ( WORD ) iOpenMode, - ( WORD ) iRDEType ); - } - - hb_retni( iOpenedArea ); - - if( iOpenedArea > 0 ) - _sx_SetDBFInfo( iOpenedArea, szAlias, iOpenMode, iRDEType ); - - if( bIsAlloc ) - hb_xfree( szAlias ); - } - else - hb_errRT_BASE( EG_OPEN, 2020, NULL, "SX_USE", 1, hb_paramError( 1 ) ); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, "SX_USE", 1, hb_paramError( 1 ) ); -} - -HB_FUNC( SX_DBINFO ) -{ - if( Opened_DBF_Property ) - { - if( HB_ISCHAR( 1 ) || HB_ISNUM( 1 ) ) - { - PHB_ITEM aSingleInfo = hb_itemNew( NULL ); - char * szAlias = HB_ISCHAR( 1 ) ? ( char * ) hb_parc( 1 ) : ( char * ) sx_Alias( ( WORD ) hb_parni( 1 ) ); - HB_ISIZ iLen = strlen( szAlias ) + 1; - - hb_arrayNew( aSingleInfo, 0 ); - - /* printf("Here....?\n"); */ - if( iLen > 1 ) - { - HB_USHORT ui; - char * szTmp = ( char * ) hb_xgrab( iLen ); - - hb_snprintf( szTmp, iLen, "%s", szAlias ); - szTmp = _sx_upper( szTmp ); - - for( ui = 0; ui < (HB_USHORT) hb_arrayLen( Opened_DBF_Property ); - ui++ ) - { - HB_BOOL bFound = HB_FALSE; - PHB_ITEM pInfo = hb_arrayGetItemPtr( Opened_DBF_Property, ui + 1 ); - const char * cAliasInfo = hb_arrayGetCPtr( pInfo, 3 ); - - if( cAliasInfo ) - { - if( strcmp( szTmp, cAliasInfo ) == 0 ) - { - hb_arrayAdd( aSingleInfo, pInfo ); - bFound = HB_TRUE; - } - - if( bFound ) - break; - } - } - - hb_xfree( szTmp ); - } - - hb_itemReturnRelease( aSingleInfo ); - } - else - { - if( HB_ISLOG( 2 ) && hb_parl( 2 ) ) - { - /* Complete Info With Description */ - ULONG i; - PHB_ITEM pInfo = NULL; - - hb_arrayCloneTo( pInfo, Opened_DBF_Property ); - - for( i = 0; i < hb_arrayLen( pInfo ); i++ ) - { - PHB_ITEM aDesc = hb_arrayGetItemPtr( pInfo, i + 1 ); - ULONG j; - HB_BOOL bNotArray = HB_FALSE; - - for( j = 0; j < hb_arrayLen( aDesc ); j++ ) - { - PHB_ITEM pData = hb_itemNew( NULL ); - char * szDesc = ( char * ) hb_xgrab( 256 ); - - if( hb_arrayGetType( aDesc, j + 1 ) & HB_IT_STRING ) - { - char * szStr = hb_arrayGetC( aDesc, j + 1 ); - hb_snprintf( szDesc, 255, "%s=%s", s_aDescription[ j ], szStr ); - hb_xfree( szStr ); - } - else if( hb_arrayGetType( aDesc, j + 1 ) & HB_IT_NUMERIC ) - hb_snprintf( szDesc, 255, "%s=%i", s_aDescription[ j ], - hb_arrayGetNI( aDesc, j + 1 ) ); - else if( hb_arrayGetType( aDesc, j + 1 ) & HB_IT_LOGICAL ) - hb_snprintf( szDesc, 255, "%s=%s", s_aDescription[ j ], - hb_arrayGetL( aDesc, j + 1 ) ? ".T." : ".F." ); - else if( hb_arrayGetType( aDesc, j + 1 ) & HB_IT_ARRAY ) - { - PHB_ITEM aField = hb_arrayGetItemPtr( aDesc, j + 1 ); - ULONG u; - - bNotArray = HB_TRUE; - - for( u = 0; u < hb_arrayLen( aField ); u++ ) - { - PHB_ITEM _pF = hb_arrayGetItemPtr( aField, u + 1 ); - char * szField = ( char * ) hb_xgrab( 256 ); - char * FName = hb_arrayGetC( _pF, 1 ); - char * FType = hb_arrayGetC( _pF, 2 ); - int FSize = ( int ) hb_arrayGetNI( _pF, 3 ); - int FDec = ( int ) hb_arrayGetNI( _pF, 4 ); - PHB_ITEM pField = hb_itemNew( NULL ); - - hb_snprintf( szField, 255, "{\"%s\", \"%s\", %i, %i}", - FName, FType, FSize, FDec ); - hb_arraySet( aField, u + 1, hb_itemPutC( pField, szField ) ); - hb_xfree( szField ); - hb_xfree( FName ); - hb_xfree( FType ); - hb_itemRelease( pField ); - } - } /* hb_arrayGetType( aDesc, j + 1 ) & HB_IT_ARRAY */ - - if( ! bNotArray ) - hb_arraySet( aDesc, j + 1, hb_itemPutC( pData, szDesc ) ); - - hb_xfree( szDesc ); - hb_itemRelease( pData ); - } /* for( j = 0; j < hb_arrayLen( aDesc ); j++ ) */ - } /* for( i = 0; i< hb_arrayLen( pInfo ); i++ ) */ - - hb_itemReturnRelease( pInfo ); - } /* ( HB_ISLOG( 2 ) && hb_parl( 2 ) ) */ - else - { - hb_itemReturn( Opened_DBF_Property ); - } - } - } -} - -HB_BOOL _sx_Used( void ) -{ - return Opened_DBF_Property ? hb_arrayLen( Opened_DBF_Property ) > 0 : HB_FALSE; -} - -HB_FUNC( SX_USED ) -{ - hb_retl( Opened_DBF_Property ? hb_arrayLen( Opened_DBF_Property ) > 0 : HB_FALSE ); -} - -int _sx_CheckOpenMode( const char * sSetDefault ) -{ - const char * sxOpenMode[] = { "READWRITE", "READONLY", "EXCLUSIVE" }; - int ui; - int iOpenMode = READWRITE; - - for( ui = 0; ui < 3; ui++ ) - { - if( strcmp( sxOpenMode[ ui ], sSetDefault ) == 0 ) - { - iOpenMode = ui; - break; - } - } - - return iOpenMode; -} +/* + * $Id$ + */ + +/* + * SixAPI Project source code: + * + * Copyright 2010 Andi Jahja + * + * 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/). + */ +#include "sxapi.h" + +static const char * s_cRDD[] = { "SDENTX", "SDEFOX", "SDENSX", "SDENSX_DBT" }; +static const char * s_aDescription[] = +{ + "WORKAREA (INTEGER)", "FILENAME (STRING)", "ALIAS (STRING)", + "SHARED (BOOL)", "READONLY (BOOL)", "RDE TYTE (INTEGER)", + "OPEN MODE (INTEGER)", "RDE TYPE (STRING)", "COMMIT LEVEL (INTEGER)", + "RECSIZE (INTEGER)", "FIELD COUNT (INTEGER)", "DBF STRUCTURE (ARRAY)" +}; + +static void _sx_UseGlobalInfo( SX_DBOPENINFO OpenInfo ) +{ + PHB_ITEM pData = hb_itemNew( NULL ); + PHB_ITEM pItem = hb_itemNew( NULL ); + + hb_arrayNew( pItem, 12 ); /* Elements of SX_DBOPENINFO */ + hb_arraySet( pItem, 1, hb_itemPutNI( pData, OpenInfo.uiArea ) ); + hb_arraySet( pItem, 2, hb_itemPutC( pData, OpenInfo.cFilename ) ); + hb_arraySet( pItem, 3, hb_itemPutC( pData, OpenInfo.cAlias ) ); + hb_arraySet( pItem, 4, hb_itemPutL( pData, OpenInfo.fShared ) ); + hb_arraySet( pItem, 5, hb_itemPutL( pData, OpenInfo.fReadonly ) ); + hb_arraySet( pItem, 6, hb_itemPutNI( pData, OpenInfo.iRDEType ) ); + hb_arraySet( pItem, 7, hb_itemPutNI( pData, OpenInfo.iMode ) ); + hb_arraySet( pItem, 8, hb_itemPutC( pData, OpenInfo.cRDD ) ); + hb_arraySet( pItem, 9, hb_itemPutNI( pData, OpenInfo.iCommitLevel ) ); + hb_arraySet( pItem, 10, hb_itemPutNI( pData, OpenInfo.iRecSize ) ); + hb_arraySet( pItem, 11, hb_itemPutNI( pData, OpenInfo.iFieldCount ) ); + hb_arraySet( pItem, 12, OpenInfo.aFieldInfo ); + hb_arrayAdd( Opened_DBF_Property, pItem ); + + hb_itemRelease( pData ); + hb_itemRelease( pItem ); +} + +void _sx_SetDBFInfo( int iOpenedArea, const char * szAlias, int iOpenMode, + int iRDEType ) +{ + SX_DBOPENINFO OpenInfo; + PHB_ITEM pStruct = _sx_DbStruct(); + + OpenInfo.uiArea = ( HB_USHORT ) iOpenedArea; + OpenInfo.cFilename = ( char * ) sx_BaseName(); + OpenInfo.cAlias = szAlias; + OpenInfo.fShared = ( ( iOpenMode == 0 ) ? TRUE : FALSE ); + OpenInfo.fReadonly = ( ( iOpenMode == READONLY ) ? TRUE : FALSE ); + OpenInfo.iRDEType = ( HB_USHORT ) iRDEType; + OpenInfo.iMode = ( HB_USHORT ) iOpenMode; + OpenInfo.cRDD = s_cRDD[ iRDEType - 1 ]; + OpenInfo.iCommitLevel = ( HB_USHORT ) sx_GetCommitLevel( ( WORD ) iOpenedArea ); + OpenInfo.iRecSize = ( HB_USHORT ) sx_RecSize(); + OpenInfo.iFieldCount = sx_FieldCount(); + OpenInfo.aFieldInfo = hb_itemNew( NULL ); + hb_itemCopy( OpenInfo.aFieldInfo, pStruct /* _sx_DbStruct() */ ); + _sx_UseGlobalInfo( OpenInfo ); + hb_itemRelease( OpenInfo.aFieldInfo ); + hb_itemRelease( pStruct ); +} + +HB_FUNC( SX_USE ) +{ + if( HB_ISCHAR( 1 ) ) + { + PBYTE szDBFFileName = ( PBYTE ) _sx_CheckFileExt( hb_parc( 1 ) ); + + if( hb_fsFileExists( ( const char * ) szDBFFileName ) ) + { + char * szAlias = NULL; + HB_BOOL bIsAlloc; + int iRDEType; + int iOpenMode; + int iOpenedArea; + + /* Alias Passed? */ + if( HB_ISCHAR( 2 ) ) + { + szAlias = ( char * ) hb_parc( 2 ); + bIsAlloc = ( strlen( szAlias ) == 0 ); + } + else + bIsAlloc = HB_TRUE; + + if( bIsAlloc ) + { + szAlias = _sx_AutoAlias( hb_parc( 1 ) ); + hb_storc( szAlias, 2 ); + } + + /* Open Mode Passed? */ + if( HB_ISCHAR( 3 ) ) + iOpenMode = _sx_CheckOpenMode( hb_parc( 3 ) ); + else if( HB_ISNUM( 3 ) ) + iOpenMode = hb_parni( 3 ); + else + iOpenMode = READWRITE; + + /* RDE Type Passed? */ + iRDEType = HB_ISCHAR( 4 ) ? _sx_CheckRDD( hb_parc( 4 ) ) : i_sxApi_RDD_Default; + + if( HB_ISNUM( 5 ) ) + { + UINT iCommitLevel = hb_parni( 5 ); + + if( iCommitLevel > 2 ) + iCommitLevel = 2; + + iOpenedArea = sx_UseEx( szDBFFileName, ( PBYTE ) szAlias, ( WORD ) iOpenMode, + ( WORD ) iRDEType, ( WORD ) iCommitLevel ); + } + else + { + iOpenedArea = sx_Use( szDBFFileName, ( PBYTE ) szAlias, ( WORD ) iOpenMode, + ( WORD ) iRDEType ); + } + + hb_retni( iOpenedArea ); + + if( iOpenedArea > 0 ) + _sx_SetDBFInfo( iOpenedArea, szAlias, iOpenMode, iRDEType ); + + if( bIsAlloc ) + hb_xfree( szAlias ); + } + else + hb_errRT_BASE( EG_OPEN, 2020, NULL, "SX_USE", 1, hb_paramError( 1 ) ); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, "SX_USE", 1, hb_paramError( 1 ) ); +} + +HB_FUNC( SX_DBINFO ) +{ + if( Opened_DBF_Property ) + { + if( HB_ISCHAR( 1 ) || HB_ISNUM( 1 ) ) + { + PHB_ITEM aSingleInfo = hb_itemNew( NULL ); + char * szAlias = HB_ISCHAR( 1 ) ? ( char * ) hb_parc( 1 ) : ( char * ) sx_Alias( ( WORD ) hb_parni( 1 ) ); + HB_ISIZ iLen = strlen( szAlias ) + 1; + + hb_arrayNew( aSingleInfo, 0 ); + + /* printf("Here....?\n"); */ + if( iLen > 1 ) + { + HB_USHORT ui; + char * szTmp = ( char * ) hb_xgrab( iLen ); + + hb_snprintf( szTmp, iLen, "%s", szAlias ); + szTmp = _sx_upper( szTmp ); + + for( ui = 0; ui < (HB_USHORT) hb_arrayLen( Opened_DBF_Property ); + ui++ ) + { + HB_BOOL bFound = HB_FALSE; + PHB_ITEM pInfo = hb_arrayGetItemPtr( Opened_DBF_Property, ui + 1 ); + const char * cAliasInfo = hb_arrayGetCPtr( pInfo, 3 ); + + if( cAliasInfo ) + { + if( strcmp( szTmp, cAliasInfo ) == 0 ) + { + hb_arrayAdd( aSingleInfo, pInfo ); + bFound = HB_TRUE; + } + + if( bFound ) + break; + } + } + + hb_xfree( szTmp ); + } + + hb_itemReturnRelease( aSingleInfo ); + } + else + { + if( HB_ISLOG( 2 ) && hb_parl( 2 ) ) + { + /* Complete Info With Description */ + ULONG i; + PHB_ITEM pInfo = NULL; + + hb_arrayCloneTo( pInfo, Opened_DBF_Property ); + + for( i = 0; i < hb_arrayLen( pInfo ); i++ ) + { + PHB_ITEM aDesc = hb_arrayGetItemPtr( pInfo, i + 1 ); + ULONG j; + HB_BOOL bNotArray = HB_FALSE; + + for( j = 0; j < hb_arrayLen( aDesc ); j++ ) + { + PHB_ITEM pData = hb_itemNew( NULL ); + char * szDesc = ( char * ) hb_xgrab( 256 ); + + if( hb_arrayGetType( aDesc, j + 1 ) & HB_IT_STRING ) + { + char * szStr = hb_arrayGetC( aDesc, j + 1 ); + hb_snprintf( szDesc, 255, "%s=%s", s_aDescription[ j ], szStr ); + hb_xfree( szStr ); + } + else if( hb_arrayGetType( aDesc, j + 1 ) & HB_IT_NUMERIC ) + hb_snprintf( szDesc, 255, "%s=%i", s_aDescription[ j ], + hb_arrayGetNI( aDesc, j + 1 ) ); + else if( hb_arrayGetType( aDesc, j + 1 ) & HB_IT_LOGICAL ) + hb_snprintf( szDesc, 255, "%s=%s", s_aDescription[ j ], + hb_arrayGetL( aDesc, j + 1 ) ? ".T." : ".F." ); + else if( hb_arrayGetType( aDesc, j + 1 ) & HB_IT_ARRAY ) + { + PHB_ITEM aField = hb_arrayGetItemPtr( aDesc, j + 1 ); + ULONG u; + + bNotArray = HB_TRUE; + + for( u = 0; u < hb_arrayLen( aField ); u++ ) + { + PHB_ITEM _pF = hb_arrayGetItemPtr( aField, u + 1 ); + char * szField = ( char * ) hb_xgrab( 256 ); + char * FName = hb_arrayGetC( _pF, 1 ); + char * FType = hb_arrayGetC( _pF, 2 ); + int FSize = ( int ) hb_arrayGetNI( _pF, 3 ); + int FDec = ( int ) hb_arrayGetNI( _pF, 4 ); + PHB_ITEM pField = hb_itemNew( NULL ); + + hb_snprintf( szField, 255, "{\"%s\", \"%s\", %i, %i}", + FName, FType, FSize, FDec ); + hb_arraySet( aField, u + 1, hb_itemPutC( pField, szField ) ); + hb_xfree( szField ); + hb_xfree( FName ); + hb_xfree( FType ); + hb_itemRelease( pField ); + } + } /* hb_arrayGetType( aDesc, j + 1 ) & HB_IT_ARRAY */ + + if( ! bNotArray ) + hb_arraySet( aDesc, j + 1, hb_itemPutC( pData, szDesc ) ); + + hb_xfree( szDesc ); + hb_itemRelease( pData ); + } /* for( j = 0; j < hb_arrayLen( aDesc ); j++ ) */ + } /* for( i = 0; i< hb_arrayLen( pInfo ); i++ ) */ + + hb_itemReturnRelease( pInfo ); + } /* ( HB_ISLOG( 2 ) && hb_parl( 2 ) ) */ + else + { + hb_itemReturn( Opened_DBF_Property ); + } + } + } +} + +HB_BOOL _sx_Used( void ) +{ + return Opened_DBF_Property ? hb_arrayLen( Opened_DBF_Property ) > 0 : HB_FALSE; +} + +HB_FUNC( SX_USED ) +{ + hb_retl( Opened_DBF_Property ? hb_arrayLen( Opened_DBF_Property ) > 0 : HB_FALSE ); +} + +int _sx_CheckOpenMode( const char * sSetDefault ) +{ + const char * sxOpenMode[] = { "READWRITE", "READONLY", "EXCLUSIVE" }; + int ui; + int iOpenMode = READWRITE; + + for( ui = 0; ui < 3; ui++ ) + { + if( strcmp( sxOpenMode[ ui ], sSetDefault ) == 0 ) + { + iOpenMode = ui; + break; + } + } + + return iOpenMode; +}