2012-10-16 12:29 UTC+0200 Viktor Szakats (harbour syenar.net)

* contrib/hbnf/bitclr.prg
  * contrib/hbnf/bitset.prg
  * contrib/hbnf/byt2bit.prg
  * contrib/hbnf/byt2hex.prg
  * contrib/hbnf/byteand.prg
  * contrib/hbnf/bytenot.prg
  * contrib/hbnf/byteor.prg
  * contrib/hbnf/bytexor.prg
  * contrib/hbnf/ftint86.ch
  * contrib/hbnf/isbit.prg
  * contrib/hbnf/isbiton.prg
  * contrib/hbnf/tempfile.prg
    % reworked bit functions to use HB_BIT*()

  * contrib/hbnf/workdays.prg
    * deleted unnecessary parantheses
This commit is contained in:
Viktor Szakats
2012-10-16 10:32:57 +00:00
parent c36cdb98ee
commit 9053ff561c
14 changed files with 45 additions and 104 deletions

View File

@@ -16,6 +16,24 @@
The license applies to all entries newer than 2009-04-28.
*/
2012-10-16 12:29 UTC+0200 Viktor Szakats (harbour syenar.net)
* contrib/hbnf/bitclr.prg
* contrib/hbnf/bitset.prg
* contrib/hbnf/byt2bit.prg
* contrib/hbnf/byt2hex.prg
* contrib/hbnf/byteand.prg
* contrib/hbnf/bytenot.prg
* contrib/hbnf/byteor.prg
* contrib/hbnf/bytexor.prg
* contrib/hbnf/ftint86.ch
* contrib/hbnf/isbit.prg
* contrib/hbnf/isbiton.prg
* contrib/hbnf/tempfile.prg
% reworked bit functions to use HB_BIT*()
* contrib/hbnf/workdays.prg
* deleted unnecessary parantheses
2012-10-16 11:12 UTC+0200 Viktor Szakats (harbour syenar.net)
* contrib/hbnf/acctmnth.prg
* contrib/hbnf/acctqtr.prg

View File

@@ -25,17 +25,8 @@
FUNCTION FT_BITCLR( cInbyte, nBitpos )
LOCAL cByte
IF HB_ISSTRING( cInbyte ) .AND. HB_ISNUMERIC( nBitpos )
IF nBitPos > 7 .OR. nBitPos < 0 .OR. nBitPos != Int( nBitPos )
cByte := NIL
ELSE
cByte := iif( ! FT_ISBIT( cInByte, nBitpos ), cInByte, ;
hb_BChar( hb_BCode( cInByte ) - ( 2 ^ nBitpos ) ) )
ENDIF
ELSE
cByte := NIL
RETURN hb_BChar( hb_bitReset( hb_BCode( cInbyte ), nBitpos ) )
ENDIF
RETURN cByte
RETURN NIL

View File

@@ -23,19 +23,10 @@
*
*/
FUNCTION FT_BITSET( cInByte, nBitpos )
LOCAL cByte
FUNCTION FT_BITSET( cInbyte, nBitpos )
IF HB_ISSTRING( cInbyte ) .AND. HB_ISNUMERIC( nBitpos )
IF nBitPos > 7 .OR. nBitPos < 0 .OR. nBitPos != Int( nBitPos )
cByte := NIL
ELSE
cByte := iif( FT_ISBIT( cInByte, nBitpos ), cInByte, ;
hb_BChar( hb_BCode( cInByte ) + ( 2 ^ nBitpos ) ) )
ENDIF
ELSE
cByte := NIL
RETURN hb_BChar( hb_bitSet( hb_BCode( cInbyte ), nBitpos ) )
ENDIF
RETURN cByte
RETURN NIL

View File

@@ -25,15 +25,15 @@
FUNCTION FT_BYT2BIT( cByte )
LOCAL nCounter, xBitstring
LOCAL nCounter, cBitstring
IF HB_ISSTRING( cByte )
xBitString := ""
cByte := hb_BCode( cByte )
cBitString := ""
FOR nCounter := 7 TO 0 STEP -1
xBitString += iif( FT_ISBIT( cByte, nCounter ), "1", "0" )
cBitString += iif( hb_bitTest( cByte, nCounter ), "1", "0" )
NEXT
ELSE
xBitString := NIL
RETURN cBitString
ENDIF
RETURN xBitString
RETURN NIL

View File

@@ -25,15 +25,8 @@
FUNCTION FT_BYT2HEX( cByte )
LOCAL cHexTable := "0123456789ABCDEF"
LOCAL xHexString
IF HB_ISSTRING( cByte )
xHexString := SubStr( cHexTable, Int( hb_BCode( cByte ) / 16 ) + 1, 1 ) + ;
SubStr( cHexTable, Int( hb_BCode( cByte ) % 16 ) + 1, 1 ) + ;
"h"
ELSE
xHexString := NIL
RETURN hb_StrToHex( Left( cByte, 1 ) ) + "h"
ENDIF
RETURN xHexString
RETURN NIL

View File

@@ -25,17 +25,8 @@
FUNCTION FT_BYTEAND( cByte1, cByte2 )
LOCAL nCounter, cNewByte
IF HB_ISSTRING( cByte1 ) .AND. HB_ISSTRING( cByte2 )
cNewByte := hb_BChar( 0 )
FOR nCounter := 0 TO 7 // test each bit position
IF FT_ISBIT( cByte1, nCounter ) .AND. FT_ISBIT( cByte2, nCounter )
cNewByte := FT_BITSET( cNewByte, nCounter )
ENDIF
NEXT
ELSE
cNewByte := NIL
RETURN hb_BChar( hb_bitAnd( hb_BCode( cByte1 ), hb_BCode( cByte2 ) ) )
ENDIF
RETURN cNewByte
RETURN NIL

View File

@@ -26,17 +26,8 @@
FUNCTION FT_BYTENOT( cByte )
LOCAL nCounter, cNewByte
IF HB_ISSTRING( cByte )
cNewByte := hb_BChar( 0 )
FOR nCounter := 0 TO 7 // test each bit position
IF ! FT_ISBIT( cByte, nCounter )
cNewByte := FT_BITSET( cNewByte, nCounter )
ENDIF
NEXT
ELSE
cNewByte := NIL
RETURN hb_BChar( hb_bitNot( hb_BCode( cByte ) ) )
ENDIF
RETURN cNewByte
RETURN NIL

View File

@@ -25,17 +25,8 @@
FUNCTION FT_BYTEOR( cByte1, cByte2 )
LOCAL nCounter, cNewByte
IF HB_ISSTRING( cByte1 ) .AND. HB_ISSTRING( cByte2 )
cNewByte := hb_BChar( 0 )
FOR nCounter := 0 TO 7 // test each bit position
IF FT_ISBIT( cByte1, nCounter ) .OR. FT_ISBIT( cByte2, nCounter )
cNewByte := FT_BITSET( cNewByte, nCounter )
ENDIF
NEXT
ELSE
cNewByte := NIL
RETURN hb_BChar( hb_bitOr( hb_BCode( cByte1 ), hb_BCode( cByte2 ) ) )
ENDIF
RETURN cNewByte
RETURN NIL

View File

@@ -28,19 +28,8 @@
FUNCTION FT_BYTEXOR( cByte1, cByte2 )
LOCAL nCounter, cNewByte
IF HB_ISSTRING( cByte1 ) .AND. HB_ISSTRING( cByte2 )
cNewByte := hb_BChar( 0 )
FOR nCounter := 0 TO 7 // test each bit position
IF FT_ISBIT( cByte1, nCounter ) .OR. FT_ISBIT( cByte2, nCounter )
IF ! ( FT_ISBIT( cByte1, nCounter ) .AND. FT_ISBIT( cByte2, nCounter ) )
cNewByte := FT_BITSET( cNewByte, nCounter )
ENDIF
ENDIF
NEXT
ELSE
cNewByte := NIL
RETURN hb_BChar( hb_bitXor( hb_BCode( cByte1 ), hb_BCode( cByte2 ) ) )
ENDIF
RETURN cNewByte
RETURN NIL

View File

@@ -71,6 +71,6 @@
#translate REG_ES => .F.
#translate highbyte( <X> ) => ( int( iif( (<X>) \< 0, 65536 + (<X>), (<X>) ) / 256 ) )
#translate lowbyte( <X> ) => ( iif( (<X>) \< 0, 65536 + (<X>), (<X>) ) % 256 )
#translate carrySet( <XFLAGS> ) => ( ft_isbiton( ( <XFLAGS> ), FLAG_CARRY ) )
#translate carrySet( <XFLAGS> ) => ( hb_bitTest( <XFLAGS>, FLAG_CARRY ) )
#endif // __FTINT86_CH__

View File

@@ -25,16 +25,8 @@
FUNCTION FT_ISBIT( cInbyte, nBitPos )
LOCAL lBitStat
IF HB_ISSTRING( cInbyte ) .AND. HB_ISNUMERIC( nBitPos )
IF nBitPos > 7 .OR. nBitPos < 0 .OR. nBitPos != Int( nBitPos )
lBitStat := NIL
ELSE
lBitStat := Int( ( ( hb_BCode( cInByte ) * ( 2 ^ ( 7 - nBitPos ) ) ) % 256 ) / 128 ) == 1
ENDIF
ELSE
lBitStat := NIL
RETURN hb_bitTest( hb_BCode( cInbyte ), nBitpos )
ENDIF
RETURN lBitStat
RETURN NIL

View File

@@ -27,10 +27,4 @@
*/
FUNCTION FT_ISBITON( nWord, nBit )
nWord := iif( nWord < 0, nWord + 65536, nWord )
nWord := Int( nWord * ( 2 ^ ( 15 - nBit ) ) )
nWord := Int( nWord % 65536 )
nWord := Int( nWord / 32768 )
RETURN ( nWord == 1 )
RETURN hb_bitTest( nWord, nBit )

View File

@@ -79,7 +79,7 @@ FUNCTION FT_TEMPFIL( cPath, lHide, nHandle )
* sitting in AX that needs to be closed.
*/
IF ! ft_isBitOn( aRegs[ 3 ], FLAG_CARRY )
IF ! hb_bitTest( aRegs[ 3 ], FLAG_CARRY )
IF PCount() >= 3
nHandle := aRegs[ 1 ]
ELSE

View File

@@ -58,7 +58,7 @@ FUNCTION FT_WorkDays( dStart, dStop )
nWorkDays := Int( nDays / 7 ) * 5 + nAdjust
ELSEIF ( DOW( dStart ) != 1 .AND. DOW( dStart ) != 7 )
ELSEIF DOW( dStart ) != 1 .AND. DOW( dStart ) != 7
nWorkDays := 1