From 46ae9d2f68f335e8a778a1828ab04be60f891d1e Mon Sep 17 00:00:00 2001 From: Ron Pinkas Date: Fri, 24 Nov 2000 21:00:13 +0000 Subject: [PATCH] 2000-11-24 12:50 UTC+0800 Ron Pinkas * include/hbset.h * include/set.ch * source/pp/pptable.c + Added _SET_IDLEREPEAT = 101 * source/rtl/set.c + Added suport for SET( _SET_IDLEREPEAT ) - Default is .T. * source/rtl/idle.c - Removed HB_IDLE_RESET() * Changed handling of Idle Process to default to REPEAT. * tests/onidle.prg - Removed call to HB_IDLE_RESET() + tests/testidle.prg + New test of Idle Blocks in default (REPEAT) mode and optional NON REPEAT mode. --- harbour/ChangeLog | 18 ++++++++++++++++++ harbour/include/hbset.h | 7 ++++--- harbour/include/set.ch | 3 ++- harbour/source/pp/pptable.c | 3 ++- harbour/source/rtl/idle.c | 13 +++---------- harbour/source/rtl/set.c | 10 ++++++++-- harbour/tests/onidle.prg | 2 +- harbour/tests/testidle.prg | 28 ++++++++++++++++++++++++++++ 8 files changed, 66 insertions(+), 18 deletions(-) create mode 100644 harbour/tests/testidle.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9b92e6e0a2..da9379cb3f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,21 @@ +2000-11-24 12:50 UTC+0800 Ron Pinkas + * include/hbset.h + * include/set.ch + * source/pp/pptable.c + + Added _SET_IDLEREPEAT = 101 + * source/rtl/set.c + + Added suport for SET( _SET_IDLEREPEAT ) - Default is .T. + + * source/rtl/idle.c + - Removed HB_IDLE_RESET() + * Changed handling of Idle Process to default to REPEAT. + + * tests/onidle.prg + - Removed call to HB_IDLE_RESET() + + + tests/testidle.prg + + New test of Idle Blocks in default (REPEAT) mode and optional NON REPEAT mode. + 2000-11-24 19:22 GMT+1 Maurilio Longo * contrib/mysql/tmysql.prg + ::FieldGet() and ::FieldPut() methods now accept a field name as field identifier and not diff --git a/harbour/include/hbset.h b/harbour/include/hbset.h index 68140c454c..4ce0907a93 100644 --- a/harbour/include/hbset.h +++ b/harbour/include/hbset.h @@ -100,13 +100,14 @@ typedef enum HB_SET_MFILEEXT = 42, HB_SET_STRICTREAD = 43, - HB_SET_OPTIMIZE = 44, + HB_SET_OPTIMIZE = 44, HB_SET_AUTOPEN = 45, HB_SET_AUTORDER = 46, HB_SET_AUTOSHARE = 47, /* Harbour SET extensions start at 100 */ - HB_SET_LANGUAGE = 100 + HB_SET_LANGUAGE = 100, + HB_SET_IDLEREPEAT = 101 } HB_set_enum; typedef struct @@ -172,4 +173,4 @@ extern void hb_setRelease( void ); } #endif -#endif /* HB_SET_H_ */ \ No newline at end of file +#endif /* HB_SET_H_ */ diff --git a/harbour/include/set.ch b/harbour/include/set.ch index fcc005559c..2e0cbd4e3f 100644 --- a/harbour/include/set.ch +++ b/harbour/include/set.ch @@ -98,8 +98,9 @@ #define _SET_COUNT 47 #define _SET_LANGUAGE 100 /* Harbour extension */ +#define _SET_IDLEREPEAT 101 /* Harbour extension */ #define HB_SET_BASE 100 -#define HB_SET_COUNT 1 +#define HB_SET_COUNT 2 #endif /* _SET_CH */ diff --git a/harbour/source/pp/pptable.c b/harbour/source/pp/pptable.c index 44086516b7..f4360707b1 100644 --- a/harbour/source/pp/pptable.c +++ b/harbour/source/pp/pptable.c @@ -103,6 +103,7 @@ void hb_pp_Table( void ) static DEFINES sD___49 = {"_SET_AUTORDER",NULL,-1,"46", &sD___48 }; static DEFINES sD___50 = {"_SET_AUTOSHARE",NULL,-1,"47", &sD___49 }; static DEFINES sD___51 = {"_SET_LANGUAGE",NULL,-1,"100", &sD___50 }; + static DEFINES sD___52 = {"_SET_IDLEREPEAT",NULL,-1,"101", &sD___51 }; static COMMANDS sC___1 = {0,"NOTE","\1A30",NULL,NULL }; static COMMANDS sC___2 = {0,"DO","WHILE \1A00","while \1A00",&sC___1 }; @@ -398,7 +399,7 @@ void hb_pp_Table( void ) static COMMANDS sC___238 = {0,"SET","ORDER TO TAG \1A40 [IN \1B40]","ordSetFocus( \1A30 [, \1B30] )",&sC___237 }; static COMMANDS sC___239 = {0,"SET","ORDER TO","ordSetFocus(0)",&sC___238 }; - hb_pp_topDefine = &sD___51; + hb_pp_topDefine = &sD___52; hb_pp_topCommand = &sC___239; hb_pp_topTranslate = NULL; } diff --git a/harbour/source/rtl/idle.c b/harbour/source/rtl/idle.c index c6a905b821..5d8cab3b43 100644 --- a/harbour/source/rtl/idle.c +++ b/harbour/source/rtl/idle.c @@ -69,8 +69,8 @@ USHORT hb_vm_uiIdleMaxTask = 0; /* flag to indicate GarbageCollection should be done in idle state. */ BOOL hb_vm_bCollectGarbage = TRUE; -/* Dont allow repeated processing of Idle Tasks by default */ -BOOL hb_vm_bResetIdle = FALSE; +/* Allow repeated processing of Idle Tasks by default */ +BOOL hb_vm_bIdleRepeat = TRUE; int hb_inkeyNext( void ); /* Return the next key without extracting it */ @@ -144,9 +144,8 @@ void hb_idleState( void ) return; } - if( hb_vm_bResetIdle && hb_vm_uiIdleTask == hb_vm_uiIdleMaxTask ) + if( hb_vm_bIdleRepeat && hb_vm_uiIdleTask == hb_vm_uiIdleMaxTask ) { - hb_vm_bResetIdle = FALSE; hb_vm_uiIdleTask = 0; hb_vm_bCollectGarbage = TRUE; @@ -185,17 +184,11 @@ HB_FUNC( HB_IDLESTATE ) if( hb_vm_uiIdleTask == hb_vm_uiIdleMaxTask ) { - hb_vm_bResetIdle = FALSE; hb_vm_uiIdleTask = 0; hb_vm_bCollectGarbage = TRUE; } } -HB_FUNC( HB_IDLE_RESET ) -{ - hb_vm_bResetIdle = TRUE; -} - /* add a new background task and return its handle */ HB_FUNC( HB_IDLEADD ) { diff --git a/harbour/source/rtl/set.c b/harbour/source/rtl/set.c index 258da27f15..f2877389b2 100644 --- a/harbour/source/rtl/set.c +++ b/harbour/source/rtl/set.c @@ -43,6 +43,8 @@ #include "hbapilng.h" #include "hbset.h" +extern hb_vm_bIdleRepeat; + HB_SET_STRUCT hb_set; static BOOL set_logical( PHB_ITEM pItem ) @@ -209,7 +211,7 @@ static FHANDLE open_handle( char * file_name, BOOL bAppend, char * def_ext, HB_s { USHORT uiAction; - /* NOTE: using switch() here will result in a compiler warning. + /* NOTE: using switch() here will result in a compiler warning. [vszakats] */ if( set_specifier == HB_SET_ALTFILE ) uiAction = hb_errRT_TERM( EG_CREATE, 2013, NULL, path, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY ); @@ -617,6 +619,10 @@ HB_FUNC( SET ) hb_langSelectID( hb_itemGetCPtr( pArg2 ) ); } break; + case HB_SET_IDLEREPEAT : + hb_retl( hb_vm_bIdleRepeat ); + if( args > 1 ) hb_vm_bIdleRepeat = set_logical( pArg2 ); + break; default : /* Return NIL if called with invalid SET specifier */ break; @@ -670,7 +676,7 @@ void hb_setInitialize( void ) hb_set.HB_SET_MESSAGE = 0; hb_set.HB_SET_MFILEEXT = ( char * ) hb_xgrab( 1 ); hb_set.HB_SET_MFILEEXT[ 0 ] = '\0'; - hb_set.HB_SET_OPTIMIZE = FALSE; + hb_set.HB_SET_OPTIMIZE = FALSE; hb_set.HB_SET_PATH = ( char * ) hb_xgrab( 1 ); hb_set.HB_SET_PATH[ 0 ] = '\0'; hb_set.HB_SET_PRINTER = FALSE; diff --git a/harbour/tests/onidle.prg b/harbour/tests/onidle.prg index f675b50adb..46c33638b4 100644 --- a/harbour/tests/onidle.prg +++ b/harbour/tests/onidle.prg @@ -21,7 +21,7 @@ LOCAL nPrev:=SECONDS() @ 11,2 SAY "Memory after TEST() and before collecting" + STR( MEMORY(HB_MEM_USED) ) HB_GCALL() @ 12,2 SAY "Memory after collecting" + STR( MEMORY(HB_MEM_USED) ) - nH1 = HB_IDLEADD( {|| DEVPOS(0,01), DEVOUT( TIME() ), HB_IDLE_RESET() } ) + nH1 = HB_IDLEADD( {|| DEVPOS(0,01), DEVOUT( TIME() ) } ) nH2 = HB_IDLEADD( {|| DEVPOS(0,21), TEST(), DEVOUT( MEMORY(HB_MEM_USED) ) } ) nH3 = HB_IDLEADD( {|| DEVPOS(0,41), IIF(n=4,n:=1,n++),DEVOUT(aSign[n]) } ) nH4 = HB_IDLEADD( {|| DEVPOS(0,61), DEVOUT( 1000*(SECONDS()-nPrev) ), nPrev:=SECONDS() } ) diff --git a/harbour/tests/testidle.prg b/harbour/tests/testidle.prg new file mode 100644 index 0000000000..1882f18f4c --- /dev/null +++ b/harbour/tests/testidle.prg @@ -0,0 +1,28 @@ +// #include "set.ch" - Preset in pptable.c + +PROCEDURE MAIN() + + LOCAL bIdle := {|| QOut( "Idle Block" ) } + + CLS + + ? _SET_IDLEREPEAT + + ? "DEFAULT IDLEREPEAT =", SET( _SET_IDLEREPEAT ) + ? + ? "Idle Block should be displayed multiple times until key or 10 seconds elapsed!" + ? "Press any key to begin..." + ? + Inkey(0) + + HB_IDLEADD( bIdle ) + Inkey( 2 ) + + SET( _SET_IDLEREPEAT, .F. ) + + CLS + ? "Idle Block should display ONCE! while waitning for key or 10 seconds elapsed!" + ? + Inkey( 2 ) + +RETURN