From 809fd031dcb3828c04f1fc186ff062b0cee3a794 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 5 Oct 2008 23:09:31 +0000 Subject: [PATCH] 2008-10-06 01:06 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * source/debug/debugger.prg * source/rtl/typefile.prg * source/rtl/tgetlist.prg * source/rtl/treport.prg * source/rtl/teditor.prg * Using [Q]QOut() functions instead of "[?]?" commands. * Using hb_Run() function instead of RUN command. * source/rtl/typefile.prg % Upped read buffer. * Formatting. % Got rid of a few unnecessary initialization. --- harbour/ChangeLog | 14 ++++++++ harbour/source/debug/debugger.prg | 14 +++++--- harbour/source/rtl/teditor.prg | 2 +- harbour/source/rtl/tgetlist.prg | 2 +- harbour/source/rtl/treport.prg | 39 ++++++++++---------- harbour/source/rtl/typefile.prg | 60 +++++++++++++++++++------------ 6 files changed, 81 insertions(+), 50 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 8403c2fdca..14956b243d 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,20 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-10-06 01:06 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * source/debug/debugger.prg + * source/rtl/typefile.prg + * source/rtl/tgetlist.prg + * source/rtl/treport.prg + * source/rtl/teditor.prg + * Using [Q]QOut() functions instead of "[?]?" commands. + * Using hb_Run() function instead of RUN command. + + * source/rtl/typefile.prg + % Upped read buffer. + * Formatting. + % Got rid of a few unnecessary initialization. + 2008-10-06 00:28 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * include/hbthread.h ! Blind fix for WinCE compilation after MT changes. diff --git a/harbour/source/debug/debugger.prg b/harbour/source/debug/debugger.prg index 76ee9a1391..9e95779e44 100644 --- a/harbour/source/debug/debugger.prg +++ b/harbour/source/debug/debugger.prg @@ -2034,17 +2034,21 @@ METHOD OSShell() CLASS HBDebugger SetColor( "W/N" ) CLS - ? "Type 'exit' to RETURN to the Debugger" + QOut( "Type 'exit' to RETURN to the Debugger" ) SetCursor( SC_NORMAL ) BEGIN SEQUENCE WITH { | objErr | Break( objErr ) } - IF At( "WINDOWS", cOs ) != 0 .OR. At( "DOS", cOs ) != 0 .OR. At( "OS/2", cOs ) != 0 + IF At( "WINDOWS", cOs ) != 0 .OR. ; + At( "DOS", cOs ) != 0 .OR. ; + At( "OS/2", cOs ) != 0 cShell := GetEnv( "COMSPEC" ) - RUN ( cShell ) - ELSEIF At( "LINUX", cOs ) != 0 .OR. At( "BSD", cOs ) != 0 .OR. At( "DARWIN", cOs ) != 0 + hb_Run( cShell ) + ELSEIF At( "LINUX", cOs ) != 0 .OR. ; + At( "BSD", cOs ) != 0 .OR. ; + At( "DARWIN", cOs ) != 0 cShell := GetEnv( "SHELL" ) - RUN ( cShell ) + hb_Run( cShell ) ELSE Alert( "Not implemented yet!" ) ENDIF diff --git a/harbour/source/rtl/teditor.prg b/harbour/source/rtl/teditor.prg index 28b67f020f..c070399cef 100644 --- a/harbour/source/rtl/teditor.prg +++ b/harbour/source/rtl/teditor.prg @@ -635,7 +635,7 @@ METHOD InsertState( lInsState ) CLASS HBEditor IF ISLOGICAL( lInsState ) ::lInsert := lInsState - SET( _SET_INSERT, lInsState ) + Set( _SET_INSERT, lInsState ) ENDIF RETURN Self diff --git a/harbour/source/rtl/tgetlist.prg b/harbour/source/rtl/tgetlist.prg index a5b96d765c..2df71c8021 100644 --- a/harbour/source/rtl/tgetlist.prg +++ b/harbour/source/rtl/tgetlist.prg @@ -508,7 +508,7 @@ METHOD GetApplyKey( nKey, oGet, oMenu, aMsg ) CLASS HBGetList IF oGet:typeOut IF Set( _SET_BELL ) - ?? Chr( 7 ) + QQOut( Chr( 7 ) ) ENDIF IF ! Set( _SET_CONFIRM ) oGet:exitState := GE_ENTER diff --git a/harbour/source/rtl/treport.prg b/harbour/source/rtl/treport.prg index 9f17311fee..e7b25f622e 100644 --- a/harbour/source/rtl/treport.prg +++ b/harbour/source/rtl/treport.prg @@ -587,13 +587,12 @@ METHOD ExecuteReport() CLASS HBReportForm IF !::lFirstPass // Don't bother first time through // Make a pass through all the groups - FOR nGroup := Len(::aReportData[RPT_GROUPS]) TO 1 STEP -1 - + FOR nGroup := Len( ::aReportData[ RPT_GROUPS ] ) TO 1 STEP -1 // make sure group has subtotals lAnySubTotals := .F. - FOR nCol := 1 TO Len(::aReportData[RPT_COLUMNS]) - IF ::aReportData[RPT_COLUMNS,nCol,RCT_TOTAL] + FOR nCol := 1 TO Len( ::aReportData[ RPT_COLUMNS ] ) + IF ::aReportData[ RPT_COLUMNS, nCol, RCT_TOTAL ] lAnySubTotals := .T. EXIT // NOTE ENDIF @@ -615,34 +614,34 @@ METHOD ExecuteReport() CLASS HBReportForm ENDIF // If this (sub)group has changed since the last record - IF lGroupChanged .OR. MakeAStr(Eval(::aReportData[RPT_GROUPS,nGroup,RGT_EXP]),; - ::aReportData[RPT_GROUPS,nGroup,RGT_TYPE]) != ::aGroupTotals[nGroup] + IF lGroupChanged .OR. MakeAStr( Eval( ::aReportData[ RPT_GROUPS, nGroup, RGT_EXP ] ),; + ::aReportData[ RPT_GROUPS, nGroup, RGT_TYPE ] ) != ::aGroupTotals[ nGroup ] - AAdd( aRecordHeader, iif( nGroup == 1, __NatMsg(_RFRM_SUBTOTAL),; - __NatMsg(_RFRM_SUBSUBTOTAL) ) ) + AAdd( aRecordHeader, iif( nGroup == 1, __NatMsg( _RFRM_SUBTOTAL ),; + __NatMsg( _RFRM_SUBSUBTOTAL ) ) ) AAdd( aRecordHeader, "" ) // Cycle through the columns, adding either the group // amount from ::aReportTotals or spaces wide enough for // the non-totaled columns - FOR nCol := 1 TO Len(::aReportData[RPT_COLUMNS]) - IF ::aReportData[RPT_COLUMNS,nCol,RCT_TOTAL] - aRecordHeader[ Len(aRecordHeader) ] += ; - Transform(::aReportTotals[nGroup+1,nCol], ; - ::aReportData[RPT_COLUMNS,nCol,RCT_PICT]) + FOR nCol := 1 TO Len( ::aReportData[ RPT_COLUMNS ] ) + IF ::aReportData[ RPT_COLUMNS, nCol, RCT_TOTAL ] + aRecordHeader[ Len( aRecordHeader ) ] += ; + Transform( ::aReportTotals[ nGroup + 1, nCol ], ; + ::aReportData[ RPT_COLUMNS, nCol, RCT_PICT ] ) // Zero out the group totals column from aReportTotals - ::aReportTotals[nGroup+1,nCol] := 0 + ::aReportTotals[ nGroup + 1, nCol ] := 0 ELSE - aRecordHeader[ Len(aRecordHeader) ] += ; - Space(::aReportData[RPT_COLUMNS,nCol,RCT_WIDTH]) + aRecordHeader[ Len( aRecordHeader ) ] += ; + Space( ::aReportData[ RPT_COLUMNS, nCol, RCT_WIDTH ] ) ENDIF - aRecordHeader[ Len(aRecordHeader) ] += " " + aRecordHeader[ Len( aRecordHeader ) ] += " " NEXT // Get rid of the extra space from the last column - aRecordHeader[Len(aRecordHeader)] := ; - LEFT( aRecordHeader[Len(aRecordHeader)], ; - Len(aRecordHeader[Len(aRecordHeader)]) - 1 ) + aRecordHeader[ Len( aRecordHeader ) ] := ; + Left( aRecordHeader[ Len( aRecordHeader ) ], ; + Len( aRecordHeader[ Len( aRecordHeader ) ] ) - 1 ) ENDIF NEXT diff --git a/harbour/source/rtl/typefile.prg b/harbour/source/rtl/typefile.prg index 6d6361d482..e527c2091b 100644 --- a/harbour/source/rtl/typefile.prg +++ b/harbour/source/rtl/typefile.prg @@ -54,19 +54,30 @@ #include "error.ch" #include "fileio.ch" -#define BUFFER_LENGTH 2048 +#define BUFFER_LENGTH 8192 PROCEDURE __TypeFile( cFile, lPrint ) - LOCAL nHandle, cBuffer, nRead := 0, nHasRead := 0, nSize := 0, nBuffer - LOCAL oErr, xRecover, nRetries - LOCAL aSaveSet[ 2 ] - LOCAL cDir, cName, cExt, cTmp, aPath, i - IF !ISLOGICAL( lPrint ) + LOCAL nHandle + LOCAL cBuffer + LOCAL nRead + LOCAL nHasRead + LOCAL nSize + LOCAL nBuffer + LOCAL oErr + LOCAL xRecover + LOCAL nRetries + LOCAL aSaveSet[ 2 ] + LOCAL cDir, cName, cExt + LOCAL cTmp + LOCAL aPath + LOCAL i + + IF ! ISLOGICAL( lPrint ) lPrint := .F. ENDIF - IF !ISCHARACTER( cFile ) + IF ! ISCHARACTER( cFile ) oErr := ErrorNew() oErr:severity := ES_ERROR oErr:genCode := EG_OPEN @@ -76,18 +87,18 @@ PROCEDURE __TypeFile( cFile, lPrint ) Eval( ErrorBlock(), oErr ) ENDIF - // If no drive/dir specified, search the SET DEFAULT and PATH directories + /* If no drive/dir specified, search the SET DEFAULT and PATH directories */ hb_FNameSplit( cFile, @cDir, @cName, @cExt ) IF Empty( cDir ) - cTmp := SET( _SET_DEFAULT ) + ";" + SET( _SET_PATH ) + cTmp := Set( _SET_DEFAULT ) + ";" + Set( _SET_PATH ) cTmp := StrTran( cTmp, ",", ";" ) i := Len( cTmp ) - DO WHILE SubStr( cTmp, i, 1 ) == ";" // remove last ";" - cTmp := LEFT( cTmp, --i ) + DO WHILE SubStr( cTmp, i, 1 ) == ";" /* remove last ";" */ + cTmp := Left( cTmp, --i ) ENDDO - aPath := HB_ATOKENS( cTmp, ";" ) - FOR i := 1 TO len( aPath ) + aPath := hb_ATokens( cTmp, ";" ) + FOR i := 1 TO Len( aPath ) IF File( cTmp := hb_FNameMerge( aPath[ i ], cName, cExt ) ) cFile := cTmp EXIT @@ -108,13 +119,13 @@ PROCEDURE __TypeFile( cFile, lPrint ) oErr:OsCode := FError() oErr:tries := ++nRetries xRecover := Eval( ErrorBlock(), oErr ) - IF ISLOGICAL( xRecover ) .AND. !xRecover // user select "Default" + IF ISLOGICAL( xRecover ) .AND. !xRecover /* user select "Default" */ RETURN ENDIF ENDDO - // NOTE: the NG say you should explicitly SET CONSOLE OFF if you wish to - // suppress output to screen. [ckedem] + /* NOTE: the NG say you should explicitly SET CONSOLE OFF if you wish to + suppress output to screen. [ckedem] */ IF lPrint aSaveSet[ 1 ] := Set( _SET_DEVICE, "PRINTER" ) @@ -125,16 +136,19 @@ PROCEDURE __TypeFile( cFile, lPrint ) nBuffer := Min( nSize, BUFFER_LENGTH ) FSeek( nHandle, 0 ) // go top - // here we try to read a line at a time but I think we could just - // display the whole buffer since it said: "without any headings or formating" - cbuffer := Space( nBuffer ) - ? // start in a new line - DO WHILE ( nRead := fread( nHandle, @cbuffer, nBuffer )) > 0 + /* Here we try to read a line at a time but I think we could just + display the whole buffer since it said: + "without any headings or formating" */ + + nHasRead := 0 + cBuffer := Space( nBuffer ) + QOut() /* starting a new line */ + DO WHILE ( nRead := FRead( nHandle, @cBuffer, nBuffer ) ) > 0 nHasRead += nRead - ?? cBuffer + QQOut( cBuffer ) nBuffer := Min( nSize - nHasRead, nBuffer ) - cbuffer := Space( nBuffer ) + cBuffer := Space( nBuffer ) ENDDO FClose( nHandle )