2007-12-20 11:44 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/common.mak
  * harbour/source/rtl/Makefile
  * harbour/include/hbgtcore.h
  + harbour/source/rtl/gtkeycod.c
    + added hb_gt_dos_keyCodeTanslate() - based on hb_gt_ReadKey()
      from GTDOS by David G. Holm <dholm@jsd-llc.com>

  * harbour/source/rtl/gtdos/gtdos.c
  * harbour/source/rtl/gtos2/gtos2.c
  * harbour/source/rtl/gtstd/gtstd.c
  * harbour/source/rtl/gtpca/gtpca.c
    * use hb_gt_dos_keyCodeTanslate() to eliminate repeated code

  * harbour/contrib/hbrddads/Makefile
  * harbour/contrib/hbpgsql/Makefile
    * updated code to locate directories with header files

  * harbour/source/rtl/hbini.prg
    ! fixed typo in HB_IniRead()

  * harbour/source/rtl/persist.prg
    ! eliminated internal static variable
This commit is contained in:
Przemyslaw Czerpak
2007-12-20 10:45:01 +00:00
parent 7634fa1f8a
commit 609f24e2e4
13 changed files with 272 additions and 384 deletions

View File

@@ -8,6 +8,30 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2007-12-20 11:44 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/common.mak
* harbour/source/rtl/Makefile
* harbour/include/hbgtcore.h
+ harbour/source/rtl/gtkeycod.c
+ added hb_gt_dos_keyCodeTanslate() - based on hb_gt_ReadKey()
from GTDOS by David G. Holm <dholm@jsd-llc.com>
* harbour/source/rtl/gtdos/gtdos.c
* harbour/source/rtl/gtos2/gtos2.c
* harbour/source/rtl/gtstd/gtstd.c
* harbour/source/rtl/gtpca/gtpca.c
* use hb_gt_dos_keyCodeTanslate() to eliminate repeated code
* harbour/contrib/hbrddads/Makefile
* harbour/contrib/hbpgsql/Makefile
* updated code to locate directories with header files
* harbour/source/rtl/hbini.prg
! fixed typo in HB_IniRead()
* harbour/source/rtl/persist.prg
! eliminated internal static variable
2007-12-20 08:06 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/contrib/hbct/files.c
! added missing 'return;' - in OS2 builds - it should fix value

View File

@@ -481,6 +481,7 @@ RTL_LIB_OBJS = \
$(OBJ_DIR)\gtclip$(OBJEXT) \
$(OBJ_DIR)\gtfunc$(OBJEXT) \
$(OBJ_DIR)\gtkbstat$(OBJEXT) \
$(OBJ_DIR)\gtkeycod$(OBJEXT) \
$(OBJ_DIR)\gtsys$(OBJEXT) \
$(OBJ_DIR)\gttone$(OBJEXT) \
$(OBJ_DIR)\gx$(OBJEXT) \

View File

@@ -18,8 +18,6 @@ LIBNAME=hbpgsql
include $(TOP)$(ROOT)config/lib.cf
ifeq ($(HB_COMPILER),mingw32)
CFLAGS := $(CFLAGS) -I/postgres/include
else
CFLAGS := $(CFLAGS) -I/usr/local/pgsql/include -I/usr/local/pgsql/include/libpq -I/usr/include/pgsql
endif
PG_DIRS = /usr/local/pgsql/include /usr/local/pgsql/include/libpq \
/usr/include/pgsql /usr/include/postgresql /postgres/include
CFLAGS += $(foreach d, $(PG_DIRS), $(if $(wildcard $(d)/libpq-fe.h),-I$(d),))

View File

@@ -18,12 +18,9 @@ ifeq ($(HB_ARCHITECTURE),w32)
C_USR += -DWIN32
endif
ifneq ($(wildcard /usr/local/ads/acesdk/ace.h),)
C_USR += -I/usr/local/ads/acesdk
else
ifneq ($(wildcard $(HOME)/ads/acesdk/ace.h),)
C_USR += -I/usr/local/ads/acesdk
endif
ifeq ($(ACE_DIRS),)
export ACE_DIRS = /usr/local $(HOME)
C_USR += $(foreach d, $(ACE_DIRS), $(if $(wildcard $(d)/ads/acesdk/ace.h),-I$(d)/ads/acesdk,))
endif
include $(TOP)$(ROOT)config/header.cf

View File

@@ -599,6 +599,8 @@ extern int hb_gt_w32_getKbdState( void );
extern void hb_gt_w32_setKbdState( int kbdShifts );
extern void hb_gt_w32_tone( double dFrequency, double dDuration );
#endif /* HB_OS_WIN_32 */
#if defined( HB_OS_DOS ) || defined( HB_OS_OS2 )
int hb_gt_dos_keyCodeTanslate( int iKey );
#endif /* HB_OS_DOS || HB_OS_OS2 */
#endif /* HB_GTCORE_H_ */

View File

@@ -46,6 +46,7 @@ C_SOURCES=\
gtclip.c \
gtfunc.c \
gtkbstat.c \
gtkeycod.c \
gtsys.c \
gttone.c \
gx.c \

View File

@@ -889,123 +889,12 @@ static int hb_gt_dos_ReadKey( PHB_GT pGT, int iEventMask )
#endif
}
/* Perform key translations */
switch( ch )
{
case -1: /* No key available */
return 0;
case 328: /* Up arrow */
ch = K_UP;
break;
case 336: /* Down arrow */
ch = K_DOWN;
break;
case 331: /* Left arrow */
ch = K_LEFT;
break;
case 333: /* Right arrow */
ch = K_RIGHT;
break;
case 327: /* Home */
ch = K_HOME;
break;
case 335: /* End */
ch = K_END;
break;
case 329: /* Page Up */
ch = K_PGUP;
break;
case 337: /* Page Down */
ch = K_PGDN;
break;
case 371: /* Ctrl + Left arrow */
ch = K_CTRL_LEFT;
break;
case 372: /* Ctrl + Right arrow */
ch = K_CTRL_RIGHT;
break;
case 375: /* Ctrl + Home */
ch = K_CTRL_HOME;
break;
case 373: /* Ctrl + End */
ch = K_CTRL_END;
break;
case 388: /* Ctrl + Page Up */
ch = K_CTRL_PGUP;
break;
case 374: /* Ctrl + Page Down */
ch = K_CTRL_PGDN;
break;
case 338: /* Insert */
ch = K_INS;
break;
case 339: /* Delete */
ch = K_DEL;
break;
case 315: /* F1 */
ch = K_F1;
break;
case 316: /* F2 */
case 317: /* F3 */
case 318: /* F4 */
case 319: /* F5 */
case 320: /* F6 */
case 321: /* F7 */
case 322: /* F8 */
case 323: /* F9 */
case 324: /* F10 */
ch = 315 - ch;
break;
case 340: /* Shift + F1 */
case 341: /* Shift + F2 */
case 342: /* Shift + F3 */
case 343: /* Shift + F4 */
case 344: /* Shift + F5 */
case 345: /* Shift + F6 */
case 346: /* Shift + F7 */
case 347: /* Shift + F8 */
case 348: /* Shift + F9 */
case 349: /* Shift + F10 */
case 350: /* Ctrl + F1 */
case 351: /* Ctrl + F2 */
case 352: /* Ctrl + F3 */
case 353: /* Ctrl + F4 */
case 354: /* Ctrl + F5 */
case 355: /* Ctrl + F6 */
case 356: /* Ctrl + F7 */
case 357: /* Ctrl + F8 */
case 358: /* Ctrl + F9 */
case 359: /* Ctrl + F10 */
case 360: /* Alt + F1 */
case 361: /* Alt + F2 */
case 362: /* Alt + F3 */
case 363: /* Alt + F4 */
case 364: /* Alt + F5 */
case 365: /* Alt + F6 */
case 366: /* Alt + F7 */
case 367: /* Alt + F8 */
case 368: /* Alt + F9 */
case 369: /* Alt + F10 */
ch = 330 - ch;
break;
case 389: /* F11 */
case 390: /* F12 */
case 391: /* Shift + F11 */
case 392: /* Shift + F12 */
case 393: /* Ctrl + F11 */
case 394: /* Ctrl + F12 */
case 395: /* Alt + F11 */
case 396: /* Alt + F12 */
ch = 349 - ch;
}
ch = hb_gt_dos_keyCodeTanslate( ch );
if( ch == 0 )
{
ch = HB_GTSELF_MOUSEREADKEY( pGT, iEventMask );
}
else if( ch > 0 && ch <= 255 )
{
ch = s_keyTrans[ ch ];
}
return ch;
}

View File

@@ -0,0 +1,178 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* hb_gt_dos_keyCodeTanslate()
* function used by DOS, WIN and OS2 ports of few GTs which use
* getkey()/getch()/_read_kbd()/KbdCharIn() or similar function
* for keyboard input
* based on hb_gt_ReadKey() from GTDOS code by:
* Copyright 1999 David G. Holm <dholm@jsd-llc.com>
*
* 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.
*
*/
/* NOTE: User programs should never call this layer directly! */
#include "hbgtcore.h"
#if defined( HB_OS_DOS ) || defined( HB_OS_WIN_32 ) || defined( HB_OS_OS2 )
int hb_gt_dos_keyCodeTanslate( int iKey )
{
/* Perform key translations */
switch( iKey )
{
case -1: /* No key available */
iKey = 0;
break;
case 328: /* Up arrow */
iKey = K_UP;
break;
case 336: /* Down arrow */
iKey = K_DOWN;
break;
case 331: /* Left arrow */
iKey = K_LEFT;
break;
case 333: /* Right arrow */
iKey = K_RIGHT;
break;
case 327: /* Home */
iKey = K_HOME;
break;
case 335: /* End */
iKey = K_END;
break;
case 329: /* Page Up */
iKey = K_PGUP;
break;
case 337: /* Page Down */
iKey = K_PGDN;
break;
case 371: /* Ctrl + Left arrow */
iKey = K_CTRL_LEFT;
break;
case 372: /* Ctrl + Right arrow */
iKey = K_CTRL_RIGHT;
break;
case 375: /* Ctrl + Home */
iKey = K_CTRL_HOME;
break;
case 373: /* Ctrl + End */
iKey = K_CTRL_END;
break;
case 388: /* Ctrl + Page Up */
iKey = K_CTRL_PGUP;
break;
case 374: /* Ctrl + Page Down */
iKey = K_CTRL_PGDN;
break;
case 338: /* Insert */
iKey = K_INS;
break;
case 339: /* Delete */
iKey = K_DEL;
break;
case 315: /* F1 */
iKey = K_F1;
break;
case 316: /* F2 */
case 317: /* F3 */
case 318: /* F4 */
case 319: /* F5 */
case 320: /* F6 */
case 321: /* F7 */
case 322: /* F8 */
case 323: /* F9 */
case 324: /* F10 */
iKey = 315 - iKey;
break;
case 340: /* Shift + F1 */
case 341: /* Shift + F2 */
case 342: /* Shift + F3 */
case 343: /* Shift + F4 */
case 344: /* Shift + F5 */
case 345: /* Shift + F6 */
case 346: /* Shift + F7 */
case 347: /* Shift + F8 */
case 348: /* Shift + F9 */
case 349: /* Shift + F10 */
case 350: /* Ctrl + F1 */
case 351: /* Ctrl + F2 */
case 352: /* Ctrl + F3 */
case 353: /* Ctrl + F4 */
case 354: /* Ctrl + F5 */
case 355: /* Ctrl + F6 */
case 356: /* Ctrl + F7 */
case 357: /* Ctrl + F8 */
case 358: /* Ctrl + F9 */
case 359: /* Ctrl + F10 */
case 360: /* Alt + F1 */
case 361: /* Alt + F2 */
case 362: /* Alt + F3 */
case 363: /* Alt + F4 */
case 364: /* Alt + F5 */
case 365: /* Alt + F6 */
case 366: /* Alt + F7 */
case 367: /* Alt + F8 */
case 368: /* Alt + F9 */
case 369: /* Alt + F10 */
iKey = 330 - iKey;
break;
case 389: /* F11 */
case 390: /* F12 */
case 391: /* Shift + F11 */
case 392: /* Shift + F12 */
case 393: /* Ctrl + F11 */
case 394: /* Ctrl + F12 */
case 395: /* Alt + F11 */
case 396: /* Alt + F12 */
iKey = 349 - iKey;
}
return iKey;
}
#endif /* HB_OS_DOS || HB_OS_WIN_32 || HB_OS_OS2 */

View File

@@ -615,134 +615,19 @@ static int hb_gt_os2_ReadKey( PHB_GT pGT, int iEventMask )
/* It was an extended function key lead-in code, so read the actual function key and then offset it by 256,
unless extended keyboard events are allowed, in which case offset it by 512 */
if( ( s_key->chChar == 0xE0 ) && ( iEventMask & INKEY_RAW ) )
{
ch = ( int ) s_key->chScan + 512;
}
else
{
ch = ( int ) s_key->chScan + 256;
}
}
else if ( s_key->fbStatus & KBDTRF_FINAL_CHAR_IN )
{
ch = ( int ) s_key->chChar;
}
else
{
ch = 0;
}
/* Perform key translations */
switch( ch )
{
case 328: /* Up arrow */
ch = K_UP;
break;
case 336: /* Down arrow */
ch = K_DOWN;
break;
case 331: /* Left arrow */
ch = K_LEFT;
break;
case 333: /* Right arrow */
ch = K_RIGHT;
break;
case 327: /* Home */
ch = K_HOME;
break;
case 335: /* End */
ch = K_END;
break;
case 329: /* Page Up */
ch = K_PGUP;
break;
case 337: /* Page Down */
ch = K_PGDN;
break;
case 371: /* Ctrl + Left arrow */
ch = K_CTRL_LEFT;
break;
case 372: /* Ctrl + Right arrow */
ch = K_CTRL_RIGHT;
break;
case 375: /* Ctrl + Home */
ch = K_CTRL_HOME;
break;
case 373: /* Ctrl + End */
ch = K_CTRL_END;
break;
case 388: /* Ctrl + Page Up */
ch = K_CTRL_PGUP;
break;
case 374: /* Ctrl + Page Down */
ch = K_CTRL_PGDN;
break;
case 338: /* Insert */
ch = K_INS;
break;
case 339: /* Delete */
ch = K_DEL;
break;
case 315: /* F1 */
ch = K_F1;
break;
case 316: /* F2 */
case 317: /* F3 */
case 318: /* F4 */
case 319: /* F5 */
case 320: /* F6 */
case 321: /* F7 */
case 322: /* F8 */
case 323: /* F9 */
case 324: /* F10 */
ch = 315 - ch;
break;
case 340: /* Shift + F1 */
case 341: /* Shift + F2 */
case 342: /* Shift + F3 */
case 343: /* Shift + F4 */
case 344: /* Shift + F5 */
case 345: /* Shift + F6 */
case 346: /* Shift + F7 */
case 347: /* Shift + F8 */
case 348: /* Shift + F9 */
case 349: /* Shift + F10 */
case 350: /* Ctrl + F1 */
case 351: /* Ctrl + F2 */
case 352: /* Ctrl + F3 */
case 353: /* Ctrl + F4 */
case 354: /* Ctrl + F5 */
case 355: /* Ctrl + F6 */
case 356: /* Ctrl + F7 */
case 357: /* Ctrl + F8 */
case 358: /* Ctrl + F9 */
case 359: /* Ctrl + F10 */
case 360: /* Alt + F1 */
case 361: /* Alt + F2 */
case 362: /* Alt + F3 */
case 363: /* Alt + F4 */
case 364: /* Alt + F5 */
case 365: /* Alt + F6 */
case 366: /* Alt + F7 */
case 367: /* Alt + F8 */
case 368: /* Alt + F9 */
case 369: /* Alt + F10 */
ch = 330 - ch;
break;
case 389: /* F11 */
case 390: /* F12 */
case 391: /* Shift + F11 */
case 392: /* Shift + F12 */
case 393: /* Ctrl + F11 */
case 394: /* Ctrl + F12 */
case 395: /* Alt + F11 */
case 396: /* Alt + F12 */
ch = 349 - ch;
}
ch = hb_gt_dos_keyCodeTanslate( ch );
if( ch == 0 )
{
ch = HB_GTSELF_MOUSEREADKEY( pGT, iEventMask );
}
return ch;
}

View File

@@ -582,122 +582,25 @@ static int hb_gt_pca_ReadKey( PHB_GT pGT, int iEventMask )
/* _read_kbd() returns -1 for no key, the switch statement will handle
this. */
/* Perform key translations */
switch( ch )
{
case -1: /* No key available */
ch = 0;
break;
case 328: /* Up arrow */
ch = K_UP;
break;
case 336: /* Down arrow */
ch = K_DOWN;
break;
case 331: /* Left arrow */
ch = K_LEFT;
break;
case 333: /* Right arrow */
ch = K_RIGHT;
break;
case 327: /* Home */
ch = K_HOME;
break;
case 335: /* End */
ch = K_END;
break;
case 329: /* Page Up */
ch = K_PGUP;
break;
case 337: /* Page Down */
ch = K_PGDN;
break;
case 371: /* Ctrl + Left arrow */
ch = K_CTRL_LEFT;
break;
case 372: /* Ctrl + Right arrow */
ch = K_CTRL_RIGHT;
break;
case 375: /* Ctrl + Home */
ch = K_CTRL_HOME;
break;
case 373: /* Ctrl + End */
ch = K_CTRL_END;
break;
case 388: /* Ctrl + Page Up */
ch = K_CTRL_PGUP;
break;
case 374: /* Ctrl + Page Down */
ch = K_CTRL_PGDN;
break;
case 338: /* Insert */
ch = K_INS;
break;
case 339: /* Delete */
ch = K_DEL;
break;
case 315: /* F1 */
ch = K_F1;
break;
case 316: /* F2 */
case 317: /* F3 */
case 318: /* F4 */
case 319: /* F5 */
case 320: /* F6 */
case 321: /* F7 */
case 322: /* F8 */
case 323: /* F9 */
case 324: /* F10 */
ch = 315 - ch;
break;
case 340: /* Shift + F1 */
case 341: /* Shift + F2 */
case 342: /* Shift + F3 */
case 343: /* Shift + F4 */
case 344: /* Shift + F5 */
case 345: /* Shift + F6 */
case 346: /* Shift + F7 */
case 347: /* Shift + F8 */
case 348: /* Shift + F9 */
case 349: /* Shift + F10 */
case 350: /* Ctrl + F1 */
case 351: /* Ctrl + F2 */
case 352: /* Ctrl + F3 */
case 353: /* Ctrl + F4 */
case 354: /* Ctrl + F5 */
case 355: /* Ctrl + F6 */
case 356: /* Ctrl + F7 */
case 357: /* Ctrl + F8 */
case 358: /* Ctrl + F9 */
case 359: /* Ctrl + F10 */
case 360: /* Alt + F1 */
case 361: /* Alt + F2 */
case 362: /* Alt + F3 */
case 363: /* Alt + F4 */
case 364: /* Alt + F5 */
case 365: /* Alt + F6 */
case 366: /* Alt + F7 */
case 367: /* Alt + F8 */
case 368: /* Alt + F9 */
case 369: /* Alt + F10 */
ch = 330 - ch;
break;
case 389: /* F11 */
case 390: /* F12 */
case 391: /* Shift + F11 */
case 392: /* Shift + F12 */
case 393: /* Ctrl + F11 */
case 394: /* Ctrl + F12 */
case 395: /* Alt + F11 */
case 396: /* Alt + F12 */
ch = 349 - ch;
}
ch = hb_gt_dos_keyCodeTanslate( ch );
if( ch > 0 && ch <= 255 )
ch = s_keyTransTbl[ ch ];
#elif defined( _MSC_VER ) && !defined( HB_WINCE )
if( s_bStdinConsole )
{
if( _kbhit() ) ch = _getch();
if( ch >= 0 && ch <= 255 )
ch = s_keyTransTbl[ ch ];
if( _kbhit() )
{
ch = _getch();
if( ( ch == 0 || ch == 224 ) && _kbhit() )
{
/* It was a function key lead-in code, so read the actual
function key and then offset it by 256 */
ch = _getch() + 256;
}
ch = hb_gt_dos_keyCodeTanslate( ch );
if( ch > 0 && ch <= 255 )
ch = s_keyTransTbl[ ch ];
}
}
else if( !_eof( s_hFilenoStdin ) )
{

View File

@@ -319,9 +319,19 @@ static int hb_gt_std_ReadKey( PHB_GT pGT, int iEventMask )
#if defined( _MSC_VER ) && !defined( HB_WINCE )
if( pGTSTD->fStdinConsole )
{
if( _kbhit() ) ch = _getch();
if( ch >= 0 && ch <= 255 )
ch = pGTSTD->keyTransTbl[ ch ];
if( _kbhit() )
{
ch = _getch();
if( ( ch == 0 || ch == 224 ) && _kbhit() )
{
/* It was a function key lead-in code, so read the actual
function key and then offset it by 256 */
ch = _getch() + 256;
}
ch = hb_gt_dos_keyCodeTanslate( ch );
if( ch > 0 && ch <= 255 )
ch = pGTSTD->keyTransTbl[ ch ];
}
}
else if( !_eof( pGTSTD->hStdin ) )
{

View File

@@ -110,14 +110,9 @@ STATIC FUNCTION hb_IniRdLow( hIni, cFileSpec, bKeyCaseSens, cSplitters, bAutoMai
LOCAL cFile, nLen
LOCAL aKeyVal, hCurrentSection
LOCAL hFile, nLineEnd
LOCAL cData, cBuffer, cLine
LOCAL cData, cLine
LOCAL reComment, reInclude, reSection, reSplitters
reComment := hb_RegexComp( s_cHalfLineComment + "|^[ \t]*" + s_cLineComment )
reInclude := hb_RegexComp( "include (.*)" )
reSection := hb_RegexComp( "[[](.*)[]]" )
reSplitters := hb_RegexComp( cSplitters )
aFiles := hb_aTokens( cFileSpec, hb_OSPathListSeparator() )
IF Empty( aFiles )
aFiles := { cFileSpec }
@@ -136,11 +131,16 @@ STATIC FUNCTION hb_IniRdLow( hIni, cFileSpec, bKeyCaseSens, cSplitters, bAutoMai
RETURN NIL
ENDIF
reComment := hb_RegexComp( s_cHalfLineComment + "|^[ \t]*" + s_cLineComment )
reInclude := hb_RegexComp( "include (.*)" )
reSection := hb_RegexComp( "[[](.*)[]]" )
reSplitters := hb_RegexComp( cSplitters )
/* we'll read the whole file, then we'll break it in lines. */
cBuffer := Space( FSeek( hFile, 0, FS_END ) )
cData := Space( FSeek( hFile, 0, FS_END ) )
FSeek( hFile, 0, FS_SET )
nLen := FRead( hFile, @cBuffer, Len( cBuffer ) )
cBuffer := Left( cBuffer, nLen )
nLen := FRead( hFile, @cData, Len( cData ) )
cData := Left( cData, nLen )
FClose( hFile )
/* Always begin with the MAIN section */

View File

@@ -53,14 +53,12 @@
#include "hbclass.ch"
#include "common.ch"
extern HB_STOD
CREATE CLASS HBPersistent
METHOD CreateNew() INLINE Self
METHOD LoadFromFile( cFileName ) INLINE ::LoadFromText( MemoRead( cFileName ) )
METHOD LoadFromText( cObjectText )
METHOD SaveToText( cObjectName )
METHOD SaveToText( cObjectName, nIndent )
METHOD SaveToFile( cFileName ) INLINE MemoWrit( cFileName, ::SaveToText() )
ENDCLASS
@@ -108,18 +106,21 @@ METHOD LoadFromText( cObjectText ) CLASS HBPersistent
return .T.
METHOD SaveToText( cObjectName ) CLASS HBPersistent
METHOD SaveToText( cObjectName, nIndent ) CLASS HBPersistent
local oNew := &( ::ClassName() + "()" ):CreateNew()
local aProperties, n, uValue, uNewValue, cObject, cType
static s_nIndent := -3
DEFAULT cObjectName TO "o" + ::ClassName()
s_nIndent += 3
cObject := iif( s_nIndent > 0, hb_OSNewLine(), "" ) + Space( s_nIndent ) + ;
"OBJECT " + iif( s_nIndent != 0, "::", "" ) + cObjectName + " AS " + ;
if nIndent == NIL
nIndent := 0
else
nIndent += 3
endif
cObject := iif( nIndent > 0, hb_OSNewLine(), "" ) + Space( nIndent ) + ;
"OBJECT " + iif( nIndent != 0, "::", "" ) + cObjectName + " AS " + ;
::ClassName() + hb_OSNewLine()
aProperties := __ClsGetProperties( ::ClassH )
@@ -133,16 +134,16 @@ METHOD SaveToText( cObjectName ) CLASS HBPersistent
do case
case cType == "A"
s_nIndent += 3
cObject += ArrayToText( uValue, aProperties[ n ], s_nIndent )
s_nIndent -= 3
nIndent += 3
cObject += ArrayToText( uValue, aProperties[ n ], nIndent )
nIndent -= 3
if n < Len( aProperties )
cObject += hb_OSNewLine()
endif
case cType == "O"
if __objDerivedFrom( uValue, "HBPERSISTENT" )
cObject += uValue:SaveToText( aProperties[ n ] )
cObject += uValue:SaveToText( aProperties[ n ], nIndent )
endif
if n < Len( aProperties )
cObject += hb_OSNewLine()
@@ -152,7 +153,7 @@ METHOD SaveToText( cObjectName ) CLASS HBPersistent
if n == 1
cObject += hb_OSNewLine()
endif
cObject += Space( s_nIndent ) + " ::" + ;
cObject += Space( nIndent ) + " ::" + ;
aProperties[ n ] + " = " + ValToText( uValue ) + ;
hb_OSNewLine()
endcase
@@ -161,8 +162,7 @@ METHOD SaveToText( cObjectName ) CLASS HBPersistent
next
cObject += hb_OSNewLine() + Space( s_nIndent ) + "ENDOBJECT" + hb_OSNewLine()
s_nIndent -= 3
cObject += hb_OSNewLine() + Space( nIndent ) + "ENDOBJECT" + hb_OSNewLine()
return cObject
@@ -186,7 +186,7 @@ static function ArrayToText( aArray, cName, nIndent )
case cType == "O"
if __objDerivedFrom( uValue, "HBPERSISTENT" )
cArray += uValue:SaveToText( cName + "[ " + AllTrim( Str( n ) ) + ;
" ]" )
" ]", nIndent )
endif
otherwise