From 23ab7135ff53a746c0aea9d9cdca1f5a361d6db0 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 3 Aug 1999 20:45:38 +0000 Subject: [PATCH] *** empty log message *** --- harbour/ChangeLog | 30 ++++++++ harbour/doc/codestyl.txt | 1 + harbour/funclist.txt | 23 +++--- harbour/include/gtapi.h | 1 + harbour/source/rtl/Makefile | 1 + harbour/source/rtl/adir.prg | 111 +++++++++++++++++++++++++++++ harbour/source/rtl/console.c | 19 ++++- harbour/source/rtl/filesys.c | 13 ++++ harbour/source/rtl/gtapi.c | 8 +++ harbour/source/rtl/setcolor.c | 10 ++- harbour/tests/working/Makefile | 2 + harbour/tests/working/ac_test.prg | 4 ++ harbour/tests/working/adirtest.prg | 34 +++++++++ harbour/tests/working/curdirt.prg | 13 ++++ harbour/tests/working/descend.prg | 4 ++ harbour/tests/working/rtl_test.prg | 6 +- 16 files changed, 267 insertions(+), 13 deletions(-) create mode 100644 harbour/source/rtl/adir.prg create mode 100644 harbour/tests/working/adirtest.prg create mode 100644 harbour/tests/working/curdirt.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 71faf47a7c..decae393c8 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,33 @@ +19990803-22:30 GMT+1 Victor Szel + * source/rtl/gtapi.c + include/gtapi.h + + hb_gtGetBlink() added. + (still dummy though) + * source/rtl/console.c + + SETBLINK() added. + * source/rtl/filesys.c + source/rtl/Makefile + tests/working/curdirt.prg + tests/working/Makefile + + CURDIR() plus test program CURDIRT added. + (Please update other makefiles accordingly) + Note that hb_fsCurDir() is not fully implemented yet, + so the test will not work like Clipper. + * source/rtl/setcolor.c + + COLORSELECT() added. + * source/rtl/adir.prg + source/rtl/Makefile + tests/working/adirtest.prg + tests/working/Makefile + + ADIR() plus test program ADIRTEST added. + (Please update other makefiles accordingly) + * funclist.txt + * Updated statuses + + Added some functions (_fs*()) + * doc/codestyl.txt + + "NOTE:" Added + * tests/working/descend.prg - Byref test added. + 19990803-19:00 GMT+1 Victor Szel * source/rtl/achoice.prg source/rtl/Makefile diff --git a/harbour/doc/codestyl.txt b/harbour/doc/codestyl.txt index a0ae3ae4a1..27249170b4 100644 --- a/harbour/doc/codestyl.txt +++ b/harbour/doc/codestyl.txt @@ -1,5 +1,6 @@ /* Please note the following comments we may use everywhere + NOTE: Notes TODO: something should be added here TOFIX: something needs to be fixed OBSOLETE: something could be removed from here diff --git a/harbour/funclist.txt b/harbour/funclist.txt index 12ac6f49fb..9cf96d547c 100644 --- a/harbour/funclist.txt +++ b/harbour/funclist.txt @@ -14,16 +14,16 @@ ; AADD ;R; ABS ;R; -ACHOICE ;N; +ACHOICE ;R; ACLONE ;R; ACOPY ;R; ADEL ;R; -ADIR ;N; +ADIR ;R; AEVAL ;R; AFIELDS ;N; AFILL ;R; AINS ;R; -ALERT ;N; +ALERT ;R; ALIAS ;N; ALLTRIM ;R; ALTD ;N; @@ -44,9 +44,9 @@ CDOW ;R; CHR ;R; CMONTH ;R; COL ;R; -COLORSELECT ;N; +COLORSELECT ;R; CTOD ;R; -CURDIR ;N; +CURDIR ;R; DATE ;R; DAY ;R; DBAPPEND ;S; @@ -172,7 +172,7 @@ MPOSTOLC ;N; NETERR ;N; NETNAME ;N; NEXTKEY ;S; -NOSNOW ;N; +NOSNOW ;R; OS ;S; OUTERR ;R; OUTSTD ;R; @@ -208,7 +208,7 @@ SETBLINK ;N; SETCANCEL ;N; SETCOLOR ;S; SETCURSOR ;N; -SETKEY ;N; +SETKEY ;R; SETMODE ;N; SETPOS ;R; SETPRC ;R; @@ -496,15 +496,22 @@ _errPutSubSystem ;R; _errPutTries ;R; _errRelease ;R; ; FILESYS API +_fsChDir ;R; +_fsChDrv ;R; _fsClose ;R; _fsCommit ;R; _fsCreate ;R; +_fsCurDir ;S; +_fsCurDrv ;R; _fsDelete ;R; _fsError ;R; -_fsExtOpen ;R; +_fsExtOpen ;N; +_fsIsDrv ;R; _fsLock ;R; +_fsMkDir ;R; _fsOpen ;R; _fsRead ;R; +_fsRmDir ;R; _fsRename ;R; _fsSeek ;R; _fsWrite ;R; diff --git a/harbour/include/gtapi.h b/harbour/include/gtapi.h index f8800a8282..afcea0e842 100644 --- a/harbour/include/gtapi.h +++ b/harbour/include/gtapi.h @@ -56,6 +56,7 @@ extern int hb_gtColorSelect(USHORT uiColorIndex); extern int hb_gtDispBegin(void); extern USHORT hb_gtDispCount(void); extern int hb_gtDispEnd(void); +extern int hb_gtGetBlink(BOOL * bBlink); extern int hb_gtGetColorStr(char * fpColorString); extern int hb_gtGetCursor(USHORT * uipCursorShape); extern int hb_gtGetPos(USHORT * uipRow, USHORT * uipCol); diff --git a/harbour/source/rtl/Makefile b/harbour/source/rtl/Makefile index 8138f8b695..2e1cc121e0 100644 --- a/harbour/source/rtl/Makefile +++ b/harbour/source/rtl/Makefile @@ -36,6 +36,7 @@ C_SOURCES=\ PRG_SOURCES=\ achoice.prg \ + adir.prg \ alert.prg \ asort.prg \ devoutp.prg \ diff --git a/harbour/source/rtl/adir.prg b/harbour/source/rtl/adir.prg new file mode 100644 index 0000000000..0d57e1b383 --- /dev/null +++ b/harbour/source/rtl/adir.prg @@ -0,0 +1,111 @@ +/* + * $Id$ + */ + +/* + Harbour Project source code + + Clipper compatibility function ADIR(). + + Copyright (C) 1999 Victor Szel + www - http://www.harbour-project.org + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version, with one exception: + + The exception is that if you link the Harbour Runtime Library (HRL) + and/or the Harbour Virtual Machine (HVM) with other files to produce + an executable, this does not by itself cause the resulting executable + to be covered by the GNU General Public License. Your use of that + executable is in no way restricted on account of linking the HRL + and/or HVM code into it. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit + their web site at http://www.gnu.org/). +*/ + +#include "directry.ch" + +FUNCTION aDir( cFileMask, aName, aSize, aDate, aTime, aAttr ) + + LOCAL aDir + LOCAL nDirLen + LOCAL nDirPos + + LOCAL nNameLen, nSizeLen, nDateLen, nTimeLen, nAttrLen + + LOCAL aFileInfo + + // ; CA-Clipper would fail on this case. + + IF !( ValType( cFileMask ) == "C" ) + RETURN 0 + ENDIF + + // ; + + /* TODO: Some portable code should be added here, which would */ + /* use the drive + dir from Set( _SET_DEFAULT ) if there */ + /* was none specified in cFileMask */ + + // ; + + IF ValType( aAttr ) == "A" + aDir := Directory( cFileMask, "HSD" ) + ELSE + aDir := Directory( cFileMask ) + ENDIF + + IF Valtype( aName ) == 'A' + nNameLen := Len( aName ) + ENDIF + IF Valtype( aSize ) == 'A' + nSizeLen := Len( aSize ) + ENDIF + IF Valtype( aDate ) == 'A' + nDateLen := Len( aDate ) + ENDIF + IF Valtype( aTime ) == 'A' + nTimeLen := Len( aTime ) + ENDIF + IF Valtype( aAttr ) == 'A' + nAttrLen := Len( aAttr ) + ENDIF + + // ; + + nDirLen := Len( aDir ) + + FOR nDirPos := 1 TO nDirLen + + aFileInfo := aDir[ nDirPos ] + + IF nNameLen != NIL .AND. nNameLen >= nDirPos + aName[ nDirPos ] := aFileInfo[ F_NAME ] + ENDIF + IF nSizeLen != NIL .AND. nSizeLen >= nDirPos + aSize[ nDirPos ] := aFileInfo[ F_SIZE ] + ENDIF + IF nDateLen != NIL .AND. nDateLen >= nDirPos + aDate[ nDirPos ] := aFileInfo[ F_DATE ] + ENDIF + IF nTimeLen != NIL .AND. nTimeLen >= nDirPos + aTime[ nDirPos ] := aFileInfo[ F_TIME ] + ENDIF + IF nAttrLen != NIL .AND. nAttrLen >= nDirPos + aAttr[ nDirPos ] := aFileInfo[ F_ATTR ] + ENDIF + + NEXT + + RETURN nDirLen + diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index d59ee76174..f019cc8e53 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -88,6 +88,7 @@ HARBOUR HB_ROW( void ); HARBOUR HB_SCROLL( void ); HARBOUR HB_SAVESCREEN( void ); HARBOUR HB_SETCURSOR( void ); +HARBOUR HB_SETBLINK( void ); HARBOUR HB_SETPOS( void ); HARBOUR HB_SETPRC( void ); HARBOUR HB_SHADOW( void ); @@ -115,6 +116,7 @@ HB_INIT_SYMBOLS_BEGIN( Console__InitSymbols ) { "SCROLL" , FS_PUBLIC, HB_SCROLL , 0 }, { "SAVESCREEN", FS_PUBLIC, HB_SAVESCREEN, 0 }, { "SETCURSOR" , FS_PUBLIC, HB_SETCURSOR , 0 }, +{ "SETBLINK" , FS_PUBLIC, HB_SETBLINK , 0 }, { "SETPOS" , FS_PUBLIC, HB_SETPOS , 0 }, { "SETPRC" , FS_PUBLIC, HB_SETPRC , 0 }, { "SHADOW" , FS_PUBLIC, HB_SHADOW , 0 }, @@ -943,7 +945,7 @@ HARBOUR HB_ISCOLOR (void) HARBOUR HB_NOSNOW (void) { #ifdef HARBOUR_USE_GTAPI - if (ISLOG(1)) + if ( ISLOG( 1 ) ) { hb_gtSetSnowFlag(hb_parl(1)); } @@ -1030,6 +1032,21 @@ HARBOUR HB_SETCURSOR( void ) #endif } +HARBOUR HB_SETBLINK( void ) +{ +#ifdef HARBOUR_USE_GTAPI + BOOL bPreviousBlink; + + hb_gtGetBlink( &bPreviousBlink ); + if ( ISLOG( 1 ) ) + hb_gtSetBlink( hb_parl( 1 ) ); + + hb_retl( bPreviousBlink ); +#else + hb_retl( FALSE ); +#endif +} + HARBOUR HB___ACCEPT( void ) /* Internal Clipper function used in ACCEPT command */ /* Basically the simplest Clipper function to */ /* receive data. Parameter : cPrompt. Returns : cRet */ diff --git a/harbour/source/rtl/filesys.c b/harbour/source/rtl/filesys.c index f6e16f1809..aff8fbbf8a 100644 --- a/harbour/source/rtl/filesys.c +++ b/harbour/source/rtl/filesys.c @@ -3,6 +3,7 @@ */ #include +#include #include "extend.h" #include "init.h" #include "filesys.h" @@ -133,6 +134,7 @@ HARBOUR HB_FREADSTR( void ); HARBOUR HB_FRENAME( void ); HARBOUR HB_FSEEK( void ); HARBOUR HB_FWRITE( void ); +HARBOUR HB_CURDIR( void ); HARBOUR HB_I2BIN( void ); HARBOUR HB_L2BIN( void ); HARBOUR HB_W2BIN( void ); @@ -151,6 +153,7 @@ HB_INIT_SYMBOLS_BEGIN( Files__InitSymbols ) { "FREADSTR", FS_PUBLIC, HB_FREADSTR, 0 }, { "FSEEK" , FS_PUBLIC, HB_FSEEK , 0 }, { "FWRITE" , FS_PUBLIC, HB_FWRITE , 0 }, +{ "CURDIR" , FS_PUBLIC, HB_CURDIR , 0 }, { "I2BIN" , FS_PUBLIC, HB_I2BIN , 0 }, { "L2BIN" , FS_PUBLIC, HB_L2BIN , 0 }, { "W2BIN" , FS_PUBLIC, HB_W2BIN , 0 } @@ -511,6 +514,8 @@ BYTEP hb_fsCurDir ( USHORT uiDrive ) return (BYTEP)cwd_buff; } +/* TODO: Implement nDrive */ + USHORT hb_fsChDrv ( BYTEP nDrive ) { USHORT result; @@ -781,6 +786,14 @@ HARBOUR HB_FREADSTR( void ) return; } +/* NOTE: This function should not return the leading and trailing */ +/* (back)slashes. */ + +HARBOUR HB_CURDIR( void ) +{ + hb_retc( hb_fsCurDir( ( ISCHAR( 1 ) && hb_parclen( 1 ) ) ? (USHORT)( toupper( *hb_parc( 1 ) ) - 'A' + 1 ) : 0 ) ); +} + HARBOUR HB_BIN2I( void ) { PHB_ITEM arg1_it = hb_param( 1, IT_STRING ); diff --git a/harbour/source/rtl/gtapi.c b/harbour/source/rtl/gtapi.c index ac3ef43ae8..8fcc6deea0 100644 --- a/harbour/source/rtl/gtapi.c +++ b/harbour/source/rtl/gtapi.c @@ -60,6 +60,7 @@ /* TODO: functions not implemented yet int hb_gtPostExt(void); int hb_gtPreExt(void); +int hb_gtGetBlink(BOOL * bBlink); int hb_gtSetBlink(BOOL bBlink); int hb_gtSetMode(USHORT uiRows, USHORT uiCols); */ @@ -576,6 +577,13 @@ int hb_gtScrDim(USHORT * uipHeight, USHORT * uipWidth) return(0); } +int hb_gtGetBlink(BOOL * bBlink) +{ + *bBlink = FALSE; + + return ( 0 ); +} + int hb_gtSetBlink(BOOL bBlink) { HB_SYMBOL_UNUSED( bBlink ); diff --git a/harbour/source/rtl/setcolor.c b/harbour/source/rtl/setcolor.c index b59e327084..e936a9da64 100644 --- a/harbour/source/rtl/setcolor.c +++ b/harbour/source/rtl/setcolor.c @@ -58,9 +58,11 @@ char *hb_setColor( char *sColor ) } HARBOUR HB_SETCOLOR( void ); +HARBOUR HB_COLORSELECT( void ); HB_INIT_SYMBOLS_BEGIN( SETCOLOR__InitSymbols ) -{ "SETCOLOR", FS_PUBLIC, HB_SETCOLOR, 0 } +{ "SETCOLOR" , FS_PUBLIC, HB_SETCOLOR , 0 }, +{ "COLORSELECT" , FS_PUBLIC, HB_COLORSELECT, 0 } HB_INIT_SYMBOLS_END( SETCOLOR__InitSymbols ); #if ! defined(__GNUC__) #pragma startup SETCOLOR__InitSymbols @@ -70,3 +72,9 @@ HARBOUR HB_SETCOLOR( void ) { hb_retc( hb_setColor( hb_pcount() ? hb_parc(1) : NULL ) ); } + +HARBOUR HB_COLORSELECT( void ) +{ + if (ISNUM(1)) + hb_gtColorSelect( hb_parni(1) ); +} diff --git a/harbour/tests/working/Makefile b/harbour/tests/working/Makefile index 9ea84a0535..8a2b4a30bf 100644 --- a/harbour/tests/working/Makefile +++ b/harbour/tests/working/Makefile @@ -17,6 +17,7 @@ endif ifeq ($(PM),) # PM not defined = build all files PRG_SOURCES=\ ac_test.prg \ + adirtest.prg \ ainstest.prg \ and_or.prg \ array16.prg \ @@ -39,6 +40,7 @@ PRG_SOURCES=\ codebloc.prg \ comments.prg \ copyfile.prg \ + curdirt.prg \ dates.prg \ dates2.prg \ dates3.prg \ diff --git a/harbour/tests/working/ac_test.prg b/harbour/tests/working/ac_test.prg index e9fadbac60..70d4a873fb 100644 --- a/harbour/tests/working/ac_test.prg +++ b/harbour/tests/working/ac_test.prg @@ -1,3 +1,7 @@ +/* + * $Id$ + */ + *+==================================================================== *+ *+ Source Module => E:\MULTI\AC_TEST.PRG diff --git a/harbour/tests/working/adirtest.prg b/harbour/tests/working/adirtest.prg new file mode 100644 index 0000000000..ae15cef13e --- /dev/null +++ b/harbour/tests/working/adirtest.prg @@ -0,0 +1,34 @@ +/* + * $Id$ + */ + +FUNCTION Main() + + TestIt( "*.*" ) + TestIt( "\" ) + TestIt( "..\" ) + TestIt( "..\*.*" ) + + RETURN NIL + +STATIC FUNCTION TestIt( cSpec ) + + LOCAL a := ADIR( cSpec ) + + LOCAL a1 := Array(a) + LOCAL a2 := 10 + LOCAL a3 := Array(a - 1) + LOCAL a4 := NIL + LOCAL a5 := Array(a + 1) + + OutStd( "--------------------------------------------------------" ) + OutStd( Chr(13) + Chr(10) ) + + ADIR( cSpec , a1, a2, a3, a4, a5) + + aEval(a1, {|tmp| OutStd( tmp ), OutStd( Chr(13) + Chr(10) ) }) + aEval(a3, {|tmp| OutStd( tmp ), OutStd( Chr(13) + Chr(10) ) }) + aEval(a5, {|tmp| OutStd( tmp ), OutStd( Chr(13) + Chr(10) ) }) + + RETURN NIL + diff --git a/harbour/tests/working/curdirt.prg b/harbour/tests/working/curdirt.prg new file mode 100644 index 0000000000..775bd2be49 --- /dev/null +++ b/harbour/tests/working/curdirt.prg @@ -0,0 +1,13 @@ +/* + * $Id$ + */ + +FUNCTION Main() + + OutStd( CurDir() + Chr(13) + Chr(10) ) + OutStd( CurDir("C") + Chr(13) + Chr(10) ) + OutStd( CurDir("C:") + Chr(13) + Chr(10) ) + OutStd( CurDir("D:") + Chr(13) + Chr(10) ) + OutStd( CurDir("A") + Chr(13) + Chr(10) ) + + RETURN NIL diff --git a/harbour/tests/working/descend.prg b/harbour/tests/working/descend.prg index a75d9a38f9..e690f0a37a 100644 --- a/harbour/tests/working/descend.prg +++ b/harbour/tests/working/descend.prg @@ -7,7 +7,11 @@ function main() LOCAL dDate + LOCAL cString + cString := "HARBOUR POWER & MAGIC" + OutSpec( Descend( cString ) ) + OutSpec( Descend( &cString ) ) OutSpec( Descend( "HARBOUR POWER & MAGIC" ) ) OutSpec( Descend( Descend( "HARBOUR POWER & MAGIC" ) ) ) OutSpec( Descend( .f. ) ) diff --git a/harbour/tests/working/rtl_test.prg b/harbour/tests/working/rtl_test.prg index c8c41e4359..35a94c64d4 100644 --- a/harbour/tests/working/rtl_test.prg +++ b/harbour/tests/working/rtl_test.prg @@ -1,6 +1,6 @@ -// -// $Id$ -// +/* + * $Id$ + */ /* Harbour Project source code