From a78f123db5381368fafae4b0e8b73e70545a8af4 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 6 Feb 2011 09:39:16 +0000 Subject: [PATCH] 2011-02-06 10:36 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbct/keysec.prg * contrib/hbct/keytime.prg ! Fixed KEYSEC() and KEYTIME() functions to work. They used xhb specific __KEYBOARD() extension, now swapped for HB_KEYPUT(). Reported by Georgewf. ! Fixed KEYSEC() to work around midnight. * Formatting. --- harbour/ChangeLog | 10 +++++++++ harbour/contrib/hbct/keysec.prg | 15 +++++++------ harbour/contrib/hbct/keytime.prg | 38 +++++++++++++++++--------------- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 599c2853eb..11b722e513 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,16 @@ The license applies to all entries newer than 2009-04-28. */ +2011-02-06 10:36 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbct/keysec.prg + * contrib/hbct/keytime.prg + ! Fixed KEYSEC() and KEYTIME() functions to work. + They used xhb specific __KEYBOARD() extension, now + swapped for HB_KEYPUT(). + Reported by Georgewf. + ! Fixed KEYSEC() to work around midnight. + * Formatting. + 2011-02-06 03:04 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbnetio/utils/hbnetio/netiosrv.prg * contrib/hbnetio/utils/hbnetio/netiocon.prg diff --git a/harbour/contrib/hbct/keysec.prg b/harbour/contrib/hbct/keysec.prg index 6794a40338..a3363258a3 100644 --- a/harbour/contrib/hbct/keysec.prg +++ b/harbour/contrib/hbct/keysec.prg @@ -58,7 +58,7 @@ FUNCTION KeySec( nKey, nTime, nCounter, lMode ) LOCAL nSeconds IF t_hIdle != NIL - HB_IDLEDEL( t_hIdle ) + hb_idleDel( t_hIdle ) t_hIdle := NIL ENDIF @@ -68,6 +68,7 @@ FUNCTION KeySec( nKey, nTime, nCounter, lMode ) ELSEIF nTime < 0 nTime := -nTime / 18.2 ENDIF + nTime *= 1000 IF ! ISNUMBER( nCounter ) nCounter := 1 ENDIF @@ -75,8 +76,8 @@ FUNCTION KeySec( nKey, nTime, nCounter, lMode ) lMode := .F. ENDIF - nSeconds := SECONDS() - t_hIdle := HB_IDLEADD( {|| doKeySec( nKey, nTime, lMode, ; + nSeconds := hb_milliSeconds() + t_hIdle := hb_idleAdd( {|| doKeySec( nKey, nTime, lMode, ; @nCounter, @nSeconds ) } ) RETURN .T. ENDIF @@ -84,17 +85,17 @@ FUNCTION KeySec( nKey, nTime, nCounter, lMode ) RETURN .F. STATIC PROCEDURE doKeySec( nKey, nTime, lMode, nCounter, nSeconds ) - LOCAL nSec := SECONDS() + LOCAL nSec := hb_milliSeconds() - IF lMode .AND. ! EMPTY( NEXTKEY() ) + IF lMode .AND. ! Empty( NextKey() ) nSeconds := nSec ELSEIF nCounter != 0 .AND. nSec - nSeconds >= nTime - __KEYBOARD( nKey ) + hb_keyPut( nKey ) IF nCounter > 0 nCounter-- ENDIF IF nCounter == 0 - HB_IDLEDEL( t_hIdle ) + hb_idleDel( t_hIdle ) t_hIdle := NIL ELSE nSeconds := nSec diff --git a/harbour/contrib/hbct/keytime.prg b/harbour/contrib/hbct/keytime.prg index bfb827984b..5e1efb5f36 100644 --- a/harbour/contrib/hbct/keytime.prg +++ b/harbour/contrib/hbct/keytime.prg @@ -58,57 +58,59 @@ FUNCTION KeyTime( nKey, cClockTime ) LOCAL nHour, nMin, nSec, nLast IF t_hIdle != NIL - HB_IDLEDEL( t_hIdle ) + hb_idleDel( t_hIdle ) t_hIdle := NIL ENDIF IF ISNUMBER( nKey ) .AND. ISCHARACTER( cClockTime ) - nHour := VAL( SUBSTR( cClockTime, 1, 2 ) ) - nMin := VAL( SUBSTR( cClockTime, 4, 2 ) ) - nSec := VAL( SUBSTR( cClockTime, 7, 2 ) ) + nHour := Val( SubStr( cClockTime, 1, 2 ) ) + nMin := Val( SubStr( cClockTime, 4, 2 ) ) + nSec := Val( SubStr( cClockTime, 7, 2 ) ) nLast := -1 - t_hIdle := HB_IDLEADD( {|| doKeyTime( nKey, cClockTime, nHour, nMin, nSec, ; + t_hIdle := hb_idleAdd( {|| doKeyTime( nKey, cClockTime, nHour, nMin, nSec, ; @nLast ) } ) RETURN .T. ENDIF -RETURN .F. + + RETURN .F. STATIC PROCEDURE doKeyTime( nKey, cClockTime, nHour, nMin, nSec, nLast ) - LOCAL ccTime := TIME() - LOCAL nHr := VAL( SUBSTR( ccTime, 1, 2 ) ) - LOCAL nMn := VAL( SUBSTR( ccTime, 4, 2 ) ) - LOCAL nSc := VAL( SUBSTR( ccTime, 7, 2 ) ) + LOCAL ccTime := Time() + LOCAL nHr := Val( SubStr( ccTime, 1, 2 ) ) + LOCAL nMn := Val( SubStr( ccTime, 4, 2 ) ) + LOCAL nSc := Val( SubStr( ccTime, 7, 2 ) ) IF nHour == 99 IF nHr > nLast - __KEYBOARD( nKey ) + hb_keyPut( nKey ) nLast := nHr IF nHr == 23 - HB_IDLEDEL( t_hIdle ) + hb_idleDel( t_hIdle ) t_hIdle := NIL ENDIF ENDIF ELSEIF nMin == 99 .AND. nHr == nHour IF nMn > nLast - __KEYBOARD( nKey ) + hb_keyPut( nKey ) nLast := nMn IF nMn == 59 - HB_IDLEDEL( t_hIdle ) + hb_idleDel( t_hIdle ) t_hIdle := NIL ENDIF ENDIF ELSEIF nSec == 99 .AND. nHr == nHour .AND. nMn == nMin IF nSc > nLast - __KEYBOARD( nKey ) + hb_keyPut( nKey ) nLast := nSc IF nSc == 59 - HB_IDLEDEL( t_hIdle ) + hb_idleDel( t_hIdle ) t_hIdle := NIL ENDIF ENDIF ELSEIF ccTime > cClockTime - __KEYBOARD( nKey ) - HB_IDLEDEL( t_hIdle ) + hb_keyPut( nKey ) + hb_idleDel( t_hIdle ) t_hIdle := NIL ENDIF + RETURN