From a29a440adf80034d0ca9315cd2422ba2844e4d9c Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 16 Oct 2012 19:15:53 +0000 Subject: [PATCH] 2012-10-16 21:14 UTC+0200 Viktor Szakats (harbour syenar.net) * contrib/hbnf/acctmnth.prg * contrib/hbnf/acctqtr.prg * contrib/hbnf/acctweek.prg * contrib/hbnf/acctyear.prg * contrib/hbnf/savearr.prg % some more minor cleanups and opts --- harbour/ChangeLog | 8 ++++++++ harbour/contrib/hbnf/acctmnth.prg | 6 +++--- harbour/contrib/hbnf/acctqtr.prg | 12 ++++++------ harbour/contrib/hbnf/acctweek.prg | 5 ++--- harbour/contrib/hbnf/acctyear.prg | 4 ++++ harbour/contrib/hbnf/savearr.prg | 30 ++++++++++++++++++------------ 6 files changed, 41 insertions(+), 24 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index ffcca78c1f..61f2a418aa 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,14 @@ The license applies to all entries newer than 2009-04-28. */ +2012-10-16 21:14 UTC+0200 Viktor Szakats (harbour syenar.net) + * contrib/hbnf/acctmnth.prg + * contrib/hbnf/acctqtr.prg + * contrib/hbnf/acctweek.prg + * contrib/hbnf/acctyear.prg + * contrib/hbnf/savearr.prg + % some more minor cleanups and opts + 2012-10-16 20:58 UTC+0200 Viktor Szakats (harbour syenar.net) * contrib/hbzebra/codabar.c ! minor correction to prev diff --git a/harbour/contrib/hbnf/acctmnth.prg b/harbour/contrib/hbnf/acctmnth.prg index 348c802fe4..1e617491ac 100644 --- a/harbour/contrib/hbnf/acctmnth.prg +++ b/harbour/contrib/hbnf/acctmnth.prg @@ -28,7 +28,7 @@ FUNCTION FT_ACCTMONTH( dGivenDate, nMonthNum ) - LOCAL nYTemp, nMTemp, lIsMonth, aRetVal + LOCAL nYTemp, nMTemp, aRetVal IF HB_ISNUMERIC( dGivenDate ) nMonthNum := dGivenDate @@ -44,6 +44,7 @@ FUNCTION FT_ACCTMONTH( dGivenDate, nMonthNum ) aRetVal[ 3 ] := FT_ACCTADJ( aRetVal[ 3 ], .T. ) IF dGivenDate < aRetVal[ 2 ] + dGivenDate := FT_MADD( dGivenDate, - 1 ) aRetVal := FT_MONTH( dGivenDate ) nMTemp -= 1 @@ -68,8 +69,7 @@ FUNCTION FT_ACCTMONTH( dGivenDate, nMonthNum ) ENDIF - lIsMonth := HB_ISNUMERIC( nMonthNum ) - IF lIsMonth + IF HB_ISNUMERIC( nMonthNum ) IF nMonthNum < 1 .OR. nMonthNum > 12 nMonthNum := 12 ENDIF diff --git a/harbour/contrib/hbnf/acctqtr.prg b/harbour/contrib/hbnf/acctqtr.prg index 85d46acd6e..5853ccf3f5 100644 --- a/harbour/contrib/hbnf/acctqtr.prg +++ b/harbour/contrib/hbnf/acctqtr.prg @@ -28,7 +28,7 @@ FUNCTION FT_ACCTQTR( dGivenDate, nQtrNum ) - LOCAL nYTemp, nQTemp, lIsQtr, aRetVal + LOCAL nYTemp, nQTemp, aRetVal IF HB_ISNUMERIC( dGivenDate ) nQtrNum := dGivenDate @@ -44,6 +44,7 @@ FUNCTION FT_ACCTQTR( dGivenDate, nQtrNum ) aRetVal[ 3 ] := FT_ACCTADJ( aRetVal[ 3 ], .T. ) IF dGivenDate < aRetVal[ 2 ] + dGivenDate := FT_MADD( dGivenDate, - 1 ) aRetVal := FT_QTR( dGivenDate ) nQTemp -= 1 @@ -54,7 +55,7 @@ FUNCTION FT_ACCTQTR( dGivenDate, nQtrNum ) aRetVal[ 2 ] := FT_ACCTADJ( aRetVal[ 2 ] ) aRetVal[ 3 ] := FT_ACCTADJ( aRetVal[ 3 ], .T. ) - ELSEIF dGivenDate > aRetVal[3] + ELSEIF dGivenDate > aRetVal[ 3 ] dGivenDate := FT_MADD( dGivenDate, 1 ) aRetVal := FT_QTR( dGivenDate ) @@ -63,13 +64,12 @@ FUNCTION FT_ACCTQTR( dGivenDate, nQtrNum ) nYTemp += 1 nQTemp := 1 ENDIF - aRetVal[2] := FT_ACCTADJ( aRetVal[ 2 ] ) - aRetVal[3] := FT_ACCTADJ( aRetVal[ 3 ], .T. ) + aRetVal[ 2 ] := FT_ACCTADJ( aRetVal[ 2 ] ) + aRetVal[ 3 ] := FT_ACCTADJ( aRetVal[ 3 ], .T. ) ENDIF - lIsQtr := HB_ISNUMERIC( nQtrNum ) - IF lIsQtr + IF HB_ISNUMERIC( nQtrNum ) IF nQtrNum < 1 .OR. nQtrNum > 4 nQtrNum := 4 ENDIF diff --git a/harbour/contrib/hbnf/acctweek.prg b/harbour/contrib/hbnf/acctweek.prg index 9590d63476..4f53a024d9 100644 --- a/harbour/contrib/hbnf/acctweek.prg +++ b/harbour/contrib/hbnf/acctweek.prg @@ -28,7 +28,7 @@ FUNCTION FT_ACCTWEEK( dGivenDate, nWeekNum ) - LOCAL nTemp, lIsWeek, aRetVal + LOCAL nTemp, aRetVal IF HB_ISNUMERIC( dGivenDate ) nWeekNum := dGivenDate @@ -39,8 +39,7 @@ FUNCTION FT_ACCTWEEK( dGivenDate, nWeekNum ) aRetVal := FT_ACCTYEAR( dGivenDate ) - lIsWeek := HB_ISNUMERIC( nWeekNum ) - IF lIsWeek + IF HB_ISNUMERIC( nWeekNum ) nTemp := Int( ( aRetVal[ 3 ] - aRetVal[ 2 ] ) / 7 ) + 1 IF nWeekNum < 1 .OR. nWeekNum > nTemp nWeekNum := nTemp diff --git a/harbour/contrib/hbnf/acctyear.prg b/harbour/contrib/hbnf/acctyear.prg index bb8c74bc6f..44b17e69c4 100644 --- a/harbour/contrib/hbnf/acctyear.prg +++ b/harbour/contrib/hbnf/acctyear.prg @@ -40,15 +40,19 @@ FUNCTION FT_ACCTYEAR( dGivenDate ) aRetVal[ 3 ] := FT_ACCTADJ( aRetVal[ 3 ], .T. ) IF dGivenDate < aRetVal[ 2 ] + aRetVal := FT_YEAR( FT_MADD( dGivenDate, - 1 ) ) nYTemp-- aRetVal[ 2 ] := FT_ACCTADJ( aRetVal[ 2 ] ) aRetVal[ 3 ] := FT_ACCTADJ( aRetVal[ 3 ], .T. ) + ELSEIF dGivenDate > aRetVal[ 3 ] + aRetVal := FT_YEAR( FT_MADD( dGivenDate, 1 ) ) nYTemp++ aRetVal[ 2 ] := FT_ACCTADJ( aRetVal[ 2 ] ) aRetVal[ 3 ] := FT_ACCTADJ( aRetVal[ 3 ], .T. ) + ENDIF aRetVal[ 1 ] := Str( nYTemp, 4 ) diff --git a/harbour/contrib/hbnf/savearr.prg b/harbour/contrib/hbnf/savearr.prg index 9754f59e14..fe491244fc 100644 --- a/harbour/contrib/hbnf/savearr.prg +++ b/harbour/contrib/hbnf/savearr.prg @@ -30,7 +30,7 @@ * */ -FUNCTION FT_SAVEARR( aArray, cFileName, nErrorCode ) +FUNCTION FT_SAVEARR( aArray, cFileName, /* @ */ nErrorCode ) LOCAL nHandle, lRet @@ -49,7 +49,7 @@ FUNCTION FT_SAVEARR( aArray, cFileName, nErrorCode ) RETURN lRet -STATIC FUNCTION _ftsavesub( xMemVar, nHandle, nErrorCode ) +STATIC FUNCTION _ftsavesub( xMemVar, nHandle, /* @ */ nErrorCode ) LOCAL cValType, nLen, cString @@ -58,8 +58,8 @@ STATIC FUNCTION _ftsavesub( xMemVar, nHandle, nErrorCode ) cValType := ValType( xMemVar ) FWrite( nHandle, cValType, 1 ) IF FError() == 0 - DO CASE - CASE cValType == "A" + SWITCH cValType + CASE "A" nLen := Len( xMemVar ) FWrite( nHandle, L2Bin( nLen ), 4 ) IF FError() == 0 @@ -67,26 +67,32 @@ STATIC FUNCTION _ftsavesub( xMemVar, nHandle, nErrorCode ) ELSE lRet := .F. ENDIF - CASE cValType == "B" + EXIT + CASE "B" lRet := .F. - CASE cValType == "C" + EXIT + CASE "C" nLen := Len( xMemVar ) FWrite( nHandle, L2Bin( nLen ), 4 ) FWrite( nHandle, xMemVar ) - CASE cValType == "D" + EXIT + CASE "D" nLen := 8 FWrite( nHandle, L2Bin( nLen ), 4 ) FWrite( nHandle, DToC( xMemVar ) ) - CASE cValType == "L" + EXIT + CASE "L" nLen := 1 FWrite( nHandle, L2Bin( nLen ), 4 ) FWrite( nHandle, iif( xMemVar, "T", "F" ) ) - CASE cValType == "N" + EXIT + CASE "N" cString := Str( xMemVar ) nLen := Len( cString ) FWrite( nHandle, L2Bin( nLen ), 4 ) FWrite( nHandle, cString ) - ENDCASE + EXIT + ENDSWITCH ELSE lRet := .F. ENDIF @@ -94,7 +100,7 @@ STATIC FUNCTION _ftsavesub( xMemVar, nHandle, nErrorCode ) RETURN lRet -FUNCTION FT_RESTARR( cFileName, nErrorCode ) +FUNCTION FT_RESTARR( cFileName, /* @ */ nErrorCode ) LOCAL nHandle, aArray @@ -109,7 +115,7 @@ FUNCTION FT_RESTARR( cFileName, nErrorCode ) RETURN aArray -STATIC FUNCTION _ftrestsub( nHandle, nErrorCode ) +STATIC FUNCTION _ftrestsub( nHandle, /* @ */ nErrorCode ) LOCAL cValType, nLen, cLenStr, xMemVar, cMemVar, nk