From 796887cd1ef5f1301ea89b64b54cf6b5920db4a2 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 14 Oct 2012 20:53:59 +0000 Subject: [PATCH] 2012-10-14 22:43 UTC+0200 Viktor Szakats (harbour syenar.net) * contrib/hbnf/dispc.c ! static vars moved to a structure and that structure moved to TSD so it's now MT compatible. * contrib/hbnf/datecnfg.prg % FT_DATECNFG() do not set _SET_DATEFORMAT internally * contrib/hbnf/pegs.prg + doesn't use THREAD STATIC anymore, but reentrant code * contrib/hbnf/savearr.prg + do not use PRIVATE var. * TOFIX added. This code only works with CENTURY OFF and the on-disk format is dependent on _SET_DATEFORMAT. * contrib/hbnf/woy.prg % FT_WOY()/FT_DOY(): optimized out legacy hacks dealing with century handling and CTOD() usage. * contrib/hbnf/year.prg * avoided one internal CTOD() call. % do not set _SET_DATEFORMAT internally * contrib/hbnf/dfile.prg * use fileio.ch constant * contrib/hbnf/tests/calendar.prg * contrib/hbnf/tests/datecnfg.prg * contrib/hbnf/tests/menu1.prg * contrib/hbnf/tests/savearr.prg * contrib/hbnf/tests/setdate.prg * contrib/hbnf/tests/tbwhile.prg * contrib/hbnf/tests/wda.prg * contrib/hbnf/tests/workdays.prg * contrib/hbnf/tests/woy.prg ! avoid using CTOD() (use date type and STOD() instead) + SET CENTURY ON where dates are displayed + hb_langSelect( "EN" ) where output has language dependent strings + TOFIX added where NF code is incompatible with CENTURY ON (and RTEs) + use LOCAL instead of MEMVAR * contrib/gtwvg/hbgtwvg.ch * include/hbgtinfo.ch * Marked deprecated and unused HB_GTE_* constants with HB_LEGACY_LEVEL4. INCOMPATIBLE. Use locally defined constants for these or HB_K_* constants from inkey.ch or hbgtwvg.ch if you use contrib/GTWVG. * contrib/hbnf/doc/en/acctadj.txt * contrib/hbnf/doc/en/acctmnth.txt * contrib/hbnf/doc/en/acctqtr.txt * contrib/hbnf/doc/en/acctweek.txt * contrib/hbnf/doc/en/acctyear.txt * contrib/hbnf/doc/en/dayofyr.txt * contrib/hbnf/doc/en/daytobow.txt * contrib/hbnf/doc/en/elapsed.txt * contrib/hbnf/doc/en/firstday.txt * contrib/hbnf/doc/en/lastday.txt * contrib/hbnf/doc/en/madd.txt * contrib/hbnf/doc/en/month.txt * contrib/hbnf/doc/en/qtr.txt * contrib/hbnf/doc/en/savearr.txt * contrib/hbnf/doc/en/setdate.txt * contrib/hbnf/doc/en/stod.txt * contrib/hbnf/doc/en/wda.txt * contrib/hbnf/doc/en/week.txt * contrib/hbnf/doc/en/workdays.txt * contrib/hbnf/doc/en/woy.txt * contrib/hbnf/doc/en/year.txt ! use STOD() instead of setting dependent (and not Y2K compatible) CTOD() --- harbour/ChangeLog | 74 ++++ harbour/contrib/gtwvg/hbgtwvg.ch | 2 +- harbour/contrib/hbnf/datecnfg.prg | 9 +- harbour/contrib/hbnf/dfile.prg | 8 +- harbour/contrib/hbnf/dispc.c | 538 ++++++++++++----------- harbour/contrib/hbnf/doc/en/acctadj.txt | 16 +- harbour/contrib/hbnf/doc/en/acctmnth.txt | 4 +- harbour/contrib/hbnf/doc/en/acctqtr.txt | 16 +- harbour/contrib/hbnf/doc/en/acctweek.txt | 16 +- harbour/contrib/hbnf/doc/en/acctyear.txt | 8 +- harbour/contrib/hbnf/doc/en/dayofyr.txt | 20 +- harbour/contrib/hbnf/doc/en/daytobow.txt | 2 +- harbour/contrib/hbnf/doc/en/elapsed.txt | 18 +- harbour/contrib/hbnf/doc/en/firstday.txt | 2 +- harbour/contrib/hbnf/doc/en/lastday.txt | 2 +- harbour/contrib/hbnf/doc/en/madd.txt | 4 +- harbour/contrib/hbnf/doc/en/month.txt | 22 +- harbour/contrib/hbnf/doc/en/qtr.txt | 22 +- harbour/contrib/hbnf/doc/en/savearr.txt | 40 +- harbour/contrib/hbnf/doc/en/setdate.txt | 4 +- harbour/contrib/hbnf/doc/en/stod.txt | 6 +- harbour/contrib/hbnf/doc/en/wda.txt | 6 +- harbour/contrib/hbnf/doc/en/week.txt | 22 +- harbour/contrib/hbnf/doc/en/workdays.txt | 6 +- harbour/contrib/hbnf/doc/en/woy.txt | 28 +- harbour/contrib/hbnf/doc/en/year.txt | 14 +- harbour/contrib/hbnf/pegs.prg | 136 +++--- harbour/contrib/hbnf/savearr.prg | 8 +- harbour/contrib/hbnf/tests/calendar.prg | 3 + harbour/contrib/hbnf/tests/datecnfg.prg | 3 + harbour/contrib/hbnf/tests/menu1.prg | 3 + harbour/contrib/hbnf/tests/savearr.prg | 3 + harbour/contrib/hbnf/tests/setdate.prg | 7 +- harbour/contrib/hbnf/tests/tbwhile.prg | 3 +- harbour/contrib/hbnf/tests/wda.prg | 4 +- harbour/contrib/hbnf/tests/workdays.prg | 2 +- harbour/contrib/hbnf/tests/woy.prg | 43 +- harbour/contrib/hbnf/woy.prg | 38 +- harbour/contrib/hbnf/year.prg | 14 +- harbour/include/hbgtinfo.ch | 4 +- 40 files changed, 633 insertions(+), 547 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index c96d4f596d..73534ce2f2 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,80 @@ The license applies to all entries newer than 2009-04-28. */ +2012-10-14 22:43 UTC+0200 Viktor Szakats (harbour syenar.net) + * contrib/hbnf/dispc.c + ! static vars moved to a structure and that structure + moved to TSD so it's now MT compatible. + + * contrib/hbnf/datecnfg.prg + % FT_DATECNFG() do not set _SET_DATEFORMAT internally + + * contrib/hbnf/pegs.prg + + doesn't use THREAD STATIC anymore, but reentrant code + + * contrib/hbnf/savearr.prg + + do not use PRIVATE var. + * TOFIX added. This code only works with CENTURY OFF + and the on-disk format is dependent on _SET_DATEFORMAT. + + * contrib/hbnf/woy.prg + % FT_WOY()/FT_DOY(): optimized out legacy hacks dealing + with century handling and CTOD() usage. + + * contrib/hbnf/year.prg + * avoided one internal CTOD() call. + % do not set _SET_DATEFORMAT internally + + * contrib/hbnf/dfile.prg + * use fileio.ch constant + + * contrib/hbnf/tests/calendar.prg + * contrib/hbnf/tests/datecnfg.prg + * contrib/hbnf/tests/menu1.prg + * contrib/hbnf/tests/savearr.prg + * contrib/hbnf/tests/setdate.prg + * contrib/hbnf/tests/tbwhile.prg + * contrib/hbnf/tests/wda.prg + * contrib/hbnf/tests/workdays.prg + * contrib/hbnf/tests/woy.prg + ! avoid using CTOD() (use date type and STOD() instead) + + SET CENTURY ON where dates are displayed + + hb_langSelect( "EN" ) where output has language + dependent strings + + TOFIX added where NF code is incompatible with CENTURY ON (and RTEs) + + use LOCAL instead of MEMVAR + + * contrib/gtwvg/hbgtwvg.ch + * include/hbgtinfo.ch + * Marked deprecated and unused HB_GTE_* constants with + HB_LEGACY_LEVEL4. INCOMPATIBLE. Use locally defined + constants for these or HB_K_* constants from inkey.ch + or hbgtwvg.ch if you use contrib/GTWVG. + + * contrib/hbnf/doc/en/acctadj.txt + * contrib/hbnf/doc/en/acctmnth.txt + * contrib/hbnf/doc/en/acctqtr.txt + * contrib/hbnf/doc/en/acctweek.txt + * contrib/hbnf/doc/en/acctyear.txt + * contrib/hbnf/doc/en/dayofyr.txt + * contrib/hbnf/doc/en/daytobow.txt + * contrib/hbnf/doc/en/elapsed.txt + * contrib/hbnf/doc/en/firstday.txt + * contrib/hbnf/doc/en/lastday.txt + * contrib/hbnf/doc/en/madd.txt + * contrib/hbnf/doc/en/month.txt + * contrib/hbnf/doc/en/qtr.txt + * contrib/hbnf/doc/en/savearr.txt + * contrib/hbnf/doc/en/setdate.txt + * contrib/hbnf/doc/en/stod.txt + * contrib/hbnf/doc/en/wda.txt + * contrib/hbnf/doc/en/week.txt + * contrib/hbnf/doc/en/workdays.txt + * contrib/hbnf/doc/en/woy.txt + * contrib/hbnf/doc/en/year.txt + ! use STOD() instead of setting dependent (and not Y2K compatible) + CTOD() + 2012-10-14 20:28 UTC+0200 Viktor Szakats (harbour syenar.net) * contrib/hbnetio/tests/netiot03.prg * use Asc( "A" ) instead of 65. (still lot more to do diff --git a/harbour/contrib/gtwvg/hbgtwvg.ch b/harbour/contrib/gtwvg/hbgtwvg.ch index fc25f00282..0b997466fc 100644 --- a/harbour/contrib/gtwvg/hbgtwvg.ch +++ b/harbour/contrib/gtwvg/hbgtwvg.ch @@ -56,7 +56,7 @@ /*-*/ /* Extended GT Manipulation Constants */ /*-*/ -#if 0 /*Already in hbgtinfo.ch */ +#ifndef HB_GTE_ACTIVATE #define HB_GTE_ACTIVATE 1 #define HB_GTE_SETFOCUS 2 #define HB_GTE_KILLFOCUS 3 diff --git a/harbour/contrib/hbnf/datecnfg.prg b/harbour/contrib/hbnf/datecnfg.prg index e31a24fa52..e2e8cc5f54 100644 --- a/harbour/contrib/hbnf/datecnfg.prg +++ b/harbour/contrib/hbnf/datecnfg.prg @@ -28,10 +28,9 @@ FUNCTION FT_DATECNFG( cFYStart, nDow ) - THREAD STATIC t_aDatePar := { "1980.01.01", 1 } + THREAD STATIC t_aDatePar := { SToD( "19800101" ), 1 } LOCAL dCheck - LOCAL cDateFormat IF HB_ISSTRING( cFYStart ) dCheck := CToD( cFYStart ) @@ -42,9 +41,7 @@ FUNCTION FT_DATECNFG( cFYStart, nDow ) dCheck-- ENDIF - cDateFormat := Set( _SET_DATEFORMAT, "yyyy.mm.dd" ) - t_aDatePar[ 1 ] := DToC( dCheck ) - Set( _SET_DATEFORMAT, cDateFormat ) + t_aDatePar[ 1 ] := dCheck ENDIF ENDIF @@ -52,4 +49,4 @@ FUNCTION FT_DATECNFG( cFYStart, nDow ) t_aDatePar[ 2 ] := nDow ENDIF - RETURN AClone( t_aDatePar ) + RETURN { hb_DToC( t_aDatePar[ 1 ], "yyyy.mm.dd" ), t_aDatePar[ 2 ] } diff --git a/harbour/contrib/hbnf/dfile.prg b/harbour/contrib/hbnf/dfile.prg index 5c12c0661c..e0c2c05751 100644 --- a/harbour/contrib/hbnf/dfile.prg +++ b/harbour/contrib/hbnf/dfile.prg @@ -26,7 +26,9 @@ * */ -THREAD STATIC t_nHandle := 0 +#include "fileio.ch" + +THREAD STATIC t_nHandle := F_ERROR FUNCTION FT_DFSETUP( cInFile, nTop, nLeft, nBottom, nRight, ; nStart, nCNormal, nCHighlight, cExitKeys, ; @@ -71,12 +73,12 @@ FUNCTION FT_DFSETUP( cInFile, nTop, nLeft, nBottom, nRight, ; FUNCTION FT_DFCLOSE() - IF t_nHandle > 0 + IF t_nHandle != F_ERROR _FT_DFCLOS() FClose( t_nHandle ) - t_nHandle := 0 + t_nHandle := F_ERROR ENDIF RETURN NIL diff --git a/harbour/contrib/hbnf/dispc.c b/harbour/contrib/hbnf/dispc.c index b3db7cafd2..7deca5e67b 100644 --- a/harbour/contrib/hbnf/dispc.c +++ b/harbour/contrib/hbnf/dispc.c @@ -55,6 +55,7 @@ #include "hbapi.h" #include "hbapifs.h" #include "hbapigt.h" +#include "hbstack.h" #include "inkey.ch" @@ -70,31 +71,36 @@ #define TABSET 8 -static HB_FOFFSET buffoffset; /* offset into buffer of current line */ -static HB_FOFFSET fsize; /* file size in bytes */ -static HB_ISIZ bufftop, buffbot; /* first and last character in buffer */ -static int wintop, winbot; /* first and last character in window */ -static int winrow, wincol; /* row and column of window highlight */ -static int sline, eline; /* start and end line of window */ -static int scol, ecol; /* start and end col of window */ -static int height, width; /* height and width of window */ -static HB_FHANDLE infile; /* input file handle */ -static int maxlin; /* line size */ -static HB_ISIZ buffsize; /* buffer size */ -static int hlight; /* highlight attribute */ -static int norm; /* normal attribute */ -static HB_ISIZ kcount; /* number of keys in terminate key list*/ -static int colinc; /* col increment amount */ -static HB_BOOL bBrowse; /* browse flag */ -static HB_BOOL bRefresh; /* HB_TRUE means refresh screen */ -static char kstr[ 25 ]; /* terminate key string */ -static int keylist[ 24 ]; /* terminate key list */ -static int keytype; /* K_STRING or K_LIST */ +typedef struct +{ + HB_FOFFSET buffoffset; /* offset into buffer of current line */ + HB_FOFFSET fsize; /* file size in bytes */ + HB_ISIZ bufftop, buffbot; /* first and last character in buffer */ + int wintop, winbot; /* first and last character in window */ + int winrow, wincol; /* row and column of window highlight */ + int sline, eline; /* start and end line of window */ + int scol, ecol; /* start and end col of window */ + int height, width; /* height and width of window */ + HB_FHANDLE infile; /* input file handle */ + int maxlin; /* line size */ + HB_ISIZ buffsize; /* buffer size */ + int hlight; /* highlight attribute */ + int norm; /* normal attribute */ + HB_ISIZ kcount; /* number of keys in terminate key list*/ + int colinc; /* col increment amount */ + HB_BOOL bBrowse; /* browse flag */ + HB_BOOL bRefresh; /* HB_TRUE means refresh screen */ + char kstr[ 25 ]; /* terminate key string */ + int keylist[ 24 ]; /* terminate key list */ + int keytype; /* K_STRING or K_LIST */ -static HB_BOOL bIsAllocated; /* if buffers were allocated */ -static char * buffer; /* file buffer pointer */ -static char * lbuff; /* line buffer pointer */ -static char * vseg; /* video segment variable */ + HB_BOOL bIsAllocated; /* if buffers were allocated */ + char * buffer; /* file buffer pointer */ + char * lbuff; /* line buffer pointer */ + char * vseg; /* video segment variable */ +} FT_DISPC, * PFT_DISPC; + +static HB_TSD_NEW( s_dispc, sizeof( FT_DISPC ), NULL, NULL ); /* prototypes */ @@ -118,10 +124,12 @@ static void filebot( void ); static void chattr( int x, int y, int len, int attr ) { - int i; - char * vmem; + PFT_DISPC dispc = ( PFT_DISPC ) hb_stackGetTSD( &s_dispc ); - vmem = vseg + ( y * ( width + 1 ) * 2 ) + ( x * 2 ) + 1; + int i; + char * vmem; + + vmem = dispc->vseg + ( y * ( dispc->width + 1 ) * 2 ) + ( x * 2 ) + 1; /* calc the screen memory coord */ for( i = 0; i <= len; i++, vmem += 2 ) /* write the new attribute value */ @@ -141,6 +149,8 @@ static void chattr( int x, int y, int len, int attr ) static HB_FOFFSET getblock( HB_FOFFSET offset ) { + PFT_DISPC dispc = ( PFT_DISPC ) hb_stackGetTSD( &s_dispc ); + /* set the file pointer to the proper offset and if an error occured then check to see @@ -150,28 +160,28 @@ static HB_FOFFSET getblock( HB_FOFFSET offset ) the beginning of the file. */ - hb_fsSeekLarge( infile, offset, FS_SET ); + hb_fsSeekLarge( dispc->infile, offset, FS_SET ); /* read in the file and set the buffer bottom variable equal */ /* to the number of bytes actually read in. */ - buffbot = hb_fsReadLarge( infile, buffer, buffsize ); + dispc->buffbot = hb_fsReadLarge( dispc->infile, dispc->buffer, dispc->buffsize ); /* if a full buffer's worth was not read in, make it full. */ - if( buffbot != buffsize && fsize > buffsize ) + if( dispc->buffbot != dispc->buffsize && dispc->fsize > dispc->buffsize ) { if( offset > 0 ) - hb_fsSeekLarge( infile, -buffsize, FS_END ); + hb_fsSeekLarge( dispc->infile, -dispc->buffsize, FS_END ); else - hb_fsSeekLarge( infile, buffsize, FS_SET ); + hb_fsSeekLarge( dispc->infile, dispc->buffsize, FS_SET ); - buffbot = hb_fsReadLarge( infile, buffer, buffsize ); + dispc->buffbot = hb_fsReadLarge( dispc->infile, dispc->buffer, dispc->buffsize ); } /* return the actual file position */ - return hb_fsSeekLarge( infile, 0, FS_RELATIVE ) - buffbot; + return hb_fsSeekLarge( dispc->infile, 0, FS_RELATIVE ) - dispc->buffbot; } /* @@ -182,26 +192,28 @@ static HB_FOFFSET getblock( HB_FOFFSET offset ) static void buff_align() { - HB_ISIZ i; + PFT_DISPC dispc = ( PFT_DISPC ) hb_stackGetTSD( &s_dispc ); - bufftop = 0; - buffbot = buffsize; + HB_ISIZ i; - if( buffoffset != 0 ) /* if the buffoffset is otherthan 0 */ + dispc->bufftop = 0; + dispc->buffbot = dispc->buffsize; + + if( dispc->buffoffset != 0 ) /* if the buffoffset is otherthan 0 */ { - i = bufftop; /* start at the top of the file and scan */ - /* forward until a CR is reached. */ + i = dispc->bufftop; /* start at the top of the file and scan */ + /* forward until a CR is reached. */ - while( buffer[ i ] != CR && i < buffbot ) + while( dispc->buffer[ i ] != CR && i < dispc->buffbot ) i++; - bufftop = i + 2; + dispc->bufftop = i + 2; } /* if the buffer offset is not a complete */ /* buffer's length away from the file end */ - if( buffoffset + buffbot != fsize ) + if( dispc->buffoffset + dispc->buffbot != dispc->fsize ) { /* if the file position of the last byte @@ -212,16 +224,16 @@ static void buff_align() the last character of the file. */ - if( buffoffset + buffbot > fsize ) - buffbot = ( HB_ISIZ ) ( fsize - buffoffset ); + if( dispc->buffoffset + dispc->buffbot > dispc->fsize ) + dispc->buffbot = ( HB_ISIZ ) ( dispc->fsize - dispc->buffoffset ); - i = buffbot; /* point the end of the buffer to a valid */ - /* complete text line. */ + i = dispc->buffbot; /* point the end of the buffer to a valid */ + /* complete text line. */ - while( buffer[ i ] != CR && i > bufftop ) + while( dispc->buffer[ i ] != CR && i > dispc->bufftop ) i--; - buffbot = i + 2; + dispc->buffbot = i + 2; } } @@ -235,36 +247,38 @@ static void buff_align() static void win_align() { - int i; + PFT_DISPC dispc = ( PFT_DISPC ) hb_stackGetTSD( &s_dispc ); - winbot = wintop; /* find out if there is enough text for */ - i = 0; /* full window. */ + int i; - while( winbot < buffbot && i < height ) + dispc->winbot = dispc->wintop; /* find out if there is enough text for */ + i = 0; /* full window. */ + + while( dispc->winbot < dispc->buffbot && i < dispc->height ) { - if( buffer[ winbot ] == CR ) + if( dispc->buffer[ dispc->winbot ] == CR ) i++; - winbot++; + dispc->winbot++; } - if( i < height ) /* if there is not a full window, */ + if( i < dispc->height ) /* if there is not a full window, */ { /* then retrofit winbot to the end of a line */ - while( buffer[ winbot ] != LF && winbot > bufftop ) - winbot--; + while( dispc->buffer[ dispc->winbot ] != LF && dispc->winbot > dispc->bufftop ) + dispc->winbot--; - wintop = winbot; - i = 0; /* and setup wintop */ + dispc->wintop = dispc->winbot; + i = 0; /* and setup dispc->wintop */ - while( wintop > bufftop && i <= height ) + while( dispc->wintop > dispc->bufftop && i <= dispc->height ) { - if( buffer[ wintop ] == LF ) + if( dispc->buffer[ dispc->wintop ] == LF ) i++; - wintop--; + dispc->wintop--; } - if( wintop != bufftop ) - wintop += 2; + if( dispc->wintop != dispc->bufftop ) + dispc->wintop += 2; } } @@ -279,13 +293,15 @@ static void win_align() static void disp_update( int offset ) { - int line, col, pos, i; - char * vmem; + PFT_DISPC dispc = ( PFT_DISPC ) hb_stackGetTSD( &s_dispc ); - bRefresh = HB_FALSE; - line = 0; + int line, col, pos, i; + char * vmem; - while( line < height ) + dispc->bRefresh = HB_FALSE; + line = 0; + + while( line < dispc->height ) { /* calculate the initial position, this save execution @@ -293,42 +309,42 @@ static void disp_update( int offset ) from the line start */ - pos = ( line * ( width + 1 ) * 2 ); + pos = ( line * ( dispc->width + 1 ) * 2 ); /* copy string to temp buffer */ - for( i = 0; buffer[ offset ] != CR && offset <= winbot; offset++ ) + for( i = 0; dispc->buffer[ offset ] != CR && offset <= dispc->winbot; offset++ ) { - if( i <= maxlin ) + if( i <= dispc->maxlin ) { - if( buffer[ offset ] == '\t' ) /* check for a tab */ + if( dispc->buffer[ offset ] == '\t' ) /* check for a tab */ { - lbuff[ i++ ] = ' '; /* pad with spaces */ - while( i % TABSET && i <= maxlin ) /* until tab stop */ - lbuff[ i++ ] = ' '; /* is reached or EOL */ + dispc->lbuff[ i++ ] = ' '; /* pad with spaces */ + while( i % TABSET && i <= dispc->maxlin ) /* until tab stop */ + dispc->lbuff[ i++ ] = ' '; /* is reached or EOL */ } else - lbuff[ i++ ] = buffer[ offset ]; + dispc->lbuff[ i++ ] = dispc->buffer[ offset ]; } } - for(; i <= maxlin; i++ ) /* fill out with spaces */ - lbuff[ i ] = ' '; + for(; i <= dispc->maxlin; i++ ) /* fill out with spaces */ + dispc->lbuff[ i ] = ' '; /* place the proper characters onto the screen */ - for( i = wincol, col = 0; col <= width; col++ ) + for( i = dispc->wincol, col = 0; col <= dispc->width; col++ ) { - vmem = vseg + pos + ( col * 2 ); + vmem = dispc->vseg + pos + ( col * 2 ); - *vmem = lbuff[ i++ ]; + *vmem = dispc->lbuff[ i++ ]; } line += 1; offset += 2; } - hb_gtRest( sline, scol, eline, ecol, vseg ); + hb_gtRest( dispc->sline, dispc->scol, dispc->eline, dispc->ecol, dispc->vseg ); } /* @@ -340,39 +356,41 @@ static void disp_update( int offset ) static void winup() { + PFT_DISPC dispc = ( PFT_DISPC ) hb_stackGetTSD( &s_dispc ); + int k; HB_FOFFSET i, j; - bRefresh = HB_TRUE; - k = wintop - 3; + dispc->bRefresh = HB_TRUE; + k = dispc->wintop - 3; - while( buffer[ k ] != CR && k > bufftop ) + while( dispc->buffer[ k ] != CR && k > dispc->bufftop ) k--; - if( k >= bufftop ) + if( k >= dispc->bufftop ) { - if( buffer[ k ] == CR ) + if( dispc->buffer[ k ] == CR ) k += 2; - wintop = k; - k = winbot - 3; + dispc->wintop = k; + k = dispc->winbot - 3; - while( buffer[ k ] != CR ) + while( dispc->buffer[ k ] != CR ) k--; - winbot = k + 2; + dispc->winbot = k + 2; } else - if( bufftop + buffoffset > 0 && fsize > buffsize ) + if( dispc->bufftop + dispc->buffoffset > 0 && dispc->fsize > dispc->buffsize ) { - i = buffoffset + wintop; - j = buffoffset - ( buffsize / 2 ); + i = dispc->buffoffset + dispc->wintop; + j = dispc->buffoffset - ( dispc->buffsize / 2 ); if( j < 0 ) j = 0; - buffoffset = getblock( j ); - wintop = ( int ) ( i - buffoffset ); + dispc->buffoffset = getblock( j ); + dispc->wintop = ( int ) ( i - dispc->buffoffset ); buff_align(); win_align(); @@ -388,40 +406,42 @@ static void winup() static void windown() { + PFT_DISPC dispc = ( PFT_DISPC ) hb_stackGetTSD( &s_dispc ); + int k; HB_FOFFSET i, j; - bRefresh = HB_TRUE; - k = winbot; + dispc->bRefresh = HB_TRUE; + k = dispc->winbot; - while( buffer[ k ] != CR && k <= buffbot ) + while( dispc->buffer[ k ] != CR && k <= dispc->buffbot ) k++; k += 2; - if( k <= buffbot ) + if( k <= dispc->buffbot ) { - winbot = k; - k = wintop; + dispc->winbot = k; + k = dispc->wintop; - while( buffer[ k ] != CR ) + while( dispc->buffer[ k ] != CR ) k++; - wintop = k + 2; + dispc->wintop = k + 2; } else - if( ( buffbot + buffoffset ) < fsize && fsize > buffsize ) + if( ( dispc->buffbot + dispc->buffoffset ) < dispc->fsize && dispc->fsize > dispc->buffsize ) { - i = buffoffset + wintop; + i = dispc->buffoffset + dispc->wintop; j = i; - if( j > fsize ) - j = fsize - buffsize; + if( j > dispc->fsize ) + j = dispc->fsize - dispc->buffsize; - buffoffset = getblock( j ); + dispc->buffoffset = getblock( j ); - if( i < buffoffset ) - wintop = 0; + if( i < dispc->buffoffset ) + dispc->wintop = 0; else - wintop = ( int ) ( i - buffoffset ); + dispc->wintop = ( int ) ( i - dispc->buffoffset ); buff_align(); win_align(); @@ -432,9 +452,11 @@ static void windown() static void linedown() { - if( winrow < eline ) /* if cursor not at last line */ - winrow += 1; - else /* otherwise adjust the window top variable */ + PFT_DISPC dispc = ( PFT_DISPC ) hb_stackGetTSD( &s_dispc ); + + if( dispc->winrow < dispc->eline ) /* if cursor not at last line */ + dispc->winrow += 1; + else /* otherwise adjust the window top variable */ windown(); } @@ -442,8 +464,10 @@ static void linedown() static void lineup() { - if( winrow > sline ) - winrow -= 1; + PFT_DISPC dispc = ( PFT_DISPC ) hb_stackGetTSD( &s_dispc ); + + if( dispc->winrow > dispc->sline ) + dispc->winrow -= 1; else winup(); } @@ -452,17 +476,19 @@ static void lineup() static void filetop() { - if( buffoffset != 0 ) + PFT_DISPC dispc = ( PFT_DISPC ) hb_stackGetTSD( &s_dispc ); + + if( dispc->buffoffset != 0 ) { - buffoffset = getblock( 0 ); + dispc->buffoffset = getblock( 0 ); buff_align(); } - bRefresh = HB_TRUE; - wintop = ( int ) buffoffset; - winrow = sline; - wincol = 0; + dispc->bRefresh = HB_TRUE; + dispc->wintop = ( int ) dispc->buffoffset; + dispc->winrow = dispc->sline; + dispc->wincol = 0; win_align(); } @@ -471,114 +497,118 @@ static void filetop() static void filebot() { - if( ( buffbot + buffoffset ) < fsize && fsize > buffsize ) + PFT_DISPC dispc = ( PFT_DISPC ) hb_stackGetTSD( &s_dispc ); + + if( ( dispc->buffbot + dispc->buffoffset ) < dispc->fsize && dispc->fsize > dispc->buffsize ) { - buffoffset = getblock( fsize + 1 ); + dispc->buffoffset = getblock( dispc->fsize + 1 ); buff_align(); } - bRefresh = HB_TRUE; - wintop = ( int ) buffbot - 3; - winrow = eline; - wincol = 0; + dispc->bRefresh = HB_TRUE; + dispc->wintop = ( int ) dispc->buffbot - 3; + dispc->winrow = dispc->eline; + dispc->wincol = 0; win_align(); } HB_FUNC( _FT_DFINIT ) { - int rval; - HB_ISIZ j; - HB_ISIZ i; - HB_SIZE ulSize; + PFT_DISPC dispc = ( PFT_DISPC ) hb_stackGetTSD( &s_dispc ); - rval = 0; + int rval; + HB_ISIZ j; + HB_ISIZ i; + HB_SIZE ulSize; - sline = hb_parni( 2 ); /* top row of window */ - scol = hb_parni( 3 ); /* left col */ - eline = hb_parni( 4 ); /* bottom row */ - ecol = hb_parni( 5 ); /* right col */ + rval = 0; - width = ecol - scol; /* calc width of window */ - height = eline - sline + 1; /* calc height of window */ + dispc->sline = hb_parni( 2 ); /* top row of window */ + dispc->scol = hb_parni( 3 ); /* left col */ + dispc->eline = hb_parni( 4 ); /* bottom row */ + dispc->ecol = hb_parni( 5 ); /* right col */ - hb_gtRectSize( sline, scol, eline, ecol, &ulSize ); - vseg = ( char * ) hb_xalloc( ulSize ); - if( vseg != NULL ) - hb_gtSave( sline, scol, eline, ecol, vseg ); + dispc->width = dispc->ecol - dispc->scol; /* calc width of window */ + dispc->height = dispc->eline - dispc->sline + 1; /* calc height of window */ - maxlin = hb_parni( 12 ); - buffsize = hb_parns( 13 ); /* yes - load value */ + hb_gtRectSize( dispc->sline, dispc->scol, dispc->eline, dispc->ecol, &ulSize ); + dispc->vseg = ( char * ) hb_xalloc( ulSize ); + if( dispc->vseg != NULL ) + hb_gtSave( dispc->sline, dispc->scol, dispc->eline, dispc->ecol, dispc->vseg ); - buffer = ( char * ) hb_xalloc( buffsize ); /* allocate memory */ - lbuff = ( char * ) hb_xalloc( maxlin + 1 ); /* for buffers */ + dispc->maxlin = hb_parni( 12 ); + dispc->buffsize = hb_parns( 13 ); /* yes - load value */ - bIsAllocated = ! ( buffer == NULL || lbuff == NULL || vseg == NULL ); + dispc->buffer = ( char * ) hb_xalloc( dispc->buffsize ); /* allocate memory */ + dispc->lbuff = ( char * ) hb_xalloc( dispc->maxlin + 1 ); /* for buffers */ + + dispc->bIsAllocated = ! ( dispc->buffer == NULL || dispc->lbuff == NULL || dispc->vseg == NULL ); /* memory allocated? */ - if( ! bIsAllocated ) + if( ! dispc->bIsAllocated ) { rval = 8; /* return error code 8 (memory) */ - if( buffer != NULL ) - hb_xfree( buffer ); - if( lbuff != NULL ) - hb_xfree( lbuff ); - if( vseg != NULL ) - hb_xfree( vseg ); + if( dispc->buffer != NULL ) + hb_xfree( dispc->buffer ); + if( dispc->lbuff != NULL ) + hb_xfree( dispc->lbuff ); + if( dispc->vseg != NULL ) + hb_xfree( dispc->vseg ); } - else /* get parameters */ + else /* get parameters */ { - infile = hb_numToHandle( hb_parnint( 1 ) ); /* file handle */ - j = hb_parni( 6 ); /* starting line value */ - norm = hb_parni( 7 ); /* normal color attribute */ - hlight = hb_parni( 8 ); /* highlight color attribute */ + dispc->infile = hb_numToHandle( hb_parnint( 1 ) ); /* file handle */ + j = hb_parni( 6 ); /* starting line value */ + dispc->norm = hb_parni( 7 ); /* normal color attribute */ + dispc->hlight = hb_parni( 8 ); /* highlight color attribute */ if( HB_ISARRAY( 9 ) ) { - keytype = K_LIST; - kcount = hb_parinfa( 9, 0 ); - if( kcount > 24 ) - kcount = 24; - for( i = 1; i <= kcount; i++ ) - keylist[ i - 1 ] = hb_parvni( 9, i ); /* get exit key list */ + dispc->keytype = K_LIST; + dispc->kcount = hb_parinfa( 9, 0 ); + if( dispc->kcount > 24 ) + dispc->kcount = 24; + for( i = 1; i <= dispc->kcount; i++ ) + dispc->keylist[ i - 1 ] = hb_parvni( 9, i ); /* get exit key list */ } else { - keytype = K_STRING; - kcount = hb_parclen( 9 ); - if( kcount > 24 ) - kcount = 24; - hb_strncpy( kstr, hb_parcx( 9 ), kcount - 1 ); /* get exit key string */ + dispc->keytype = K_STRING; + dispc->kcount = hb_parclen( 9 ); + if( dispc->kcount > 24 ) + dispc->kcount = 24; + hb_strncpy( dispc->kstr, hb_parcx( 9 ), dispc->kcount - 1 ); /* get exit key string */ } - bBrowse = hb_parl( 10 ); /* get browse flag */ + dispc->bBrowse = hb_parl( 10 ); /* get browse flag */ - colinc = hb_parni( 11 ); /* column skip value */ + dispc->colinc = hb_parni( 11 ); /* column skip value */ - bufftop = 0; /* init buffer top pointer */ - buffbot = buffsize; /* init buffer bottom pointer */ - buffoffset = 0; /* curr line offset into buffer */ - winrow = sline; /* init window row */ - wincol = 0; /* init window col */ - wintop = 0; /* init window top pointer */ - winbot = 0; /* init window bottom pointer */ + dispc->bufftop = 0; /* init buffer top pointer */ + dispc->buffbot = dispc->buffsize; /* init buffer bottom pointer */ + dispc->buffoffset = 0; /* curr line offset into buffer */ + dispc->winrow = dispc->sline; /* init window row */ + dispc->wincol = 0; /* init window col */ + dispc->wintop = 0; /* init window top pointer */ + dispc->winbot = 0; /* init window bottom pointer */ /* get file size */ - fsize = hb_fsSeek( infile, 0, FS_END ) - 1; + dispc->fsize = hb_fsSeek( dispc->infile, 0, FS_END ) - 1; /* get the first block */ - hb_fsSeek( infile, 0, FS_SET ); + hb_fsSeek( dispc->infile, 0, FS_SET ); /* if block less than buffsize */ - if( fsize < buffbot ) - buffbot = ( int ) fsize; /* then set buffer bottom */ + if( dispc->fsize < dispc->buffbot ) + dispc->buffbot = ( int ) dispc->fsize; /* then set buffer bottom */ /* set the current lines buffer offset pointer */ - buffoffset = getblock( bufftop ); + dispc->buffoffset = getblock( dispc->bufftop ); /* align buffer and window pointer to valid values */ @@ -590,7 +620,7 @@ HB_FUNC( _FT_DFINIT ) for( i = 1; i < j; i++ ) linedown(); - hb_gtRest( sline, scol, eline, ecol, vseg ); + hb_gtRest( dispc->sline, dispc->scol, dispc->eline, dispc->ecol, dispc->vseg ); } @@ -599,132 +629,136 @@ HB_FUNC( _FT_DFINIT ) HB_FUNC( _FT_DFCLOS ) { - if( bIsAllocated ) + PFT_DISPC dispc = ( PFT_DISPC ) hb_stackGetTSD( &s_dispc ); + + if( dispc->bIsAllocated ) { - if( buffer != NULL ) - hb_xfree( buffer ); /* free up allocated buffer memory */ - if( lbuff != NULL ) - hb_xfree( lbuff ); - if( vseg != NULL ) - hb_xfree( vseg ); + if( dispc->buffer != NULL ) + hb_xfree( dispc->buffer ); /* free up allocated buffer memory */ + if( dispc->lbuff != NULL ) + hb_xfree( dispc->lbuff ); + if( dispc->vseg != NULL ) + hb_xfree( dispc->vseg ); } } HB_FUNC( FT_DISPFILE ) { - int i; - char rval[ 2 ]; - HB_BOOL bDone; + PFT_DISPC dispc = ( PFT_DISPC ) hb_stackGetTSD( &s_dispc ); - int ch; + int i; + char rval[ 2 ]; + HB_BOOL bDone; + + int ch; /* make sure buffers were allocated and file was opened */ - if( bIsAllocated && infile > 0 ) + if( dispc->bIsAllocated && dispc->infile > 0 ) { - bDone = HB_FALSE; - bRefresh = HB_TRUE; + bDone = HB_FALSE; + dispc->bRefresh = HB_TRUE; /* draw inside of window with normal color attribute */ - for( i = 0; i < height; i++ ) - chattr( 0, i, width, norm ); + for( i = 0; i < dispc->height; i++ ) + chattr( 0, i, dispc->width, dispc->norm ); - hb_gtRest( sline, scol, eline, ecol, vseg ); + hb_gtRest( dispc->sline, dispc->scol, dispc->eline, dispc->ecol, dispc->vseg ); /* main processing loop -- terminated by user key press */ do { - if( bRefresh ) /* redraw window contents? */ - disp_update( wintop ); + if( dispc->bRefresh ) /* redraw window contents? */ + disp_update( dispc->wintop ); - hb_gtRest( sline, scol, eline, ecol, vseg ); + hb_gtRest( dispc->sline, dispc->scol, dispc->eline, dispc->ecol, dispc->vseg ); /* if not browse, highlight the current line */ - if( ! bBrowse ) - chattr( 0, winrow - sline, width, hlight ); + if( ! dispc->bBrowse ) + chattr( 0, dispc->winrow - dispc->sline, dispc->width, dispc->hlight ); - hb_gtRest( sline, scol, eline, ecol, vseg ); + hb_gtRest( dispc->sline, dispc->scol, dispc->eline, dispc->ecol, dispc->vseg ); - hb_gtSetPos( winrow, scol ); + hb_gtSetPos( dispc->winrow, dispc->scol ); ch = hb_inkey( HB_TRUE, 0.0, INKEY_ALL ); /* if not browse, then un-highlight current line */ - if( ! bBrowse ) - chattr( 0, winrow - sline, width, norm ); + if( ! dispc->bBrowse ) + chattr( 0, dispc->winrow - dispc->sline, dispc->width, dispc->norm ); - hb_gtRest( sline, scol, eline, ecol, vseg ); + hb_gtRest( dispc->sline, dispc->scol, dispc->eline, dispc->ecol, dispc->vseg ); /* figure out what the user wants to do */ switch( ch ) { - case K_DOWN: if( bBrowse ) /* if browse flag */ - winrow = eline; /* is set, force */ - /* active line to */ + case K_DOWN: if( dispc->bBrowse ) /* if browse flag */ + dispc->winrow = dispc->eline; /* is set, force */ + /* active line to */ linedown(); /* be last line */ break; - case K_UP: if( bBrowse ) /* if browse flag */ - winrow = sline; /* is set, force */ - /* active line to */ + case K_UP: if( dispc->bBrowse ) /* if browse flag */ + dispc->winrow = dispc->sline; /* is set, force */ + /* active line to */ lineup(); /* be first line */ break; - case K_LEFT: wincol -= colinc; /* move cursor */ - bRefresh = HB_TRUE; /* to the left */ + case K_LEFT: dispc->wincol -= dispc->colinc; /* move cursor */ + dispc->bRefresh = HB_TRUE; /* to the left */ - if( wincol < 0 ) - wincol = 0; + if( dispc->wincol < 0 ) + dispc->wincol = 0; break; - case K_RIGHT: wincol += colinc; /* move cursor */ - bRefresh = HB_TRUE; /* to the right */ + case K_RIGHT: dispc->wincol += dispc->colinc; /* move cursor */ + dispc->bRefresh = HB_TRUE; /* to the right */ - if( wincol > ( maxlin - width ) ) - wincol = maxlin - width; + if( dispc->wincol > ( dispc->maxlin - dispc->width ) ) + dispc->wincol = dispc->maxlin - dispc->width; break; - case K_HOME: wincol = 0; /* move cursor */ - bRefresh = HB_TRUE; /* to first col */ + case K_HOME: dispc->wincol = 0; /* move cursor */ + dispc->bRefresh = HB_TRUE; /* to first col */ break; /* move cursor to last col */ - case K_END: wincol = maxlin - width; - bRefresh = HB_TRUE; + case K_END: dispc->wincol = dispc->maxlin - dispc->width; + dispc->bRefresh = HB_TRUE; break; - case K_CTRL_LEFT: wincol -= 16; /* move cursor */ - bRefresh = HB_TRUE; /* 16 col to left */ + case K_CTRL_LEFT: dispc->wincol -= 16; /* move cursor */ + dispc->bRefresh = HB_TRUE; /* 16 col to left */ - if( wincol < 0 ) - wincol = 0; + if( dispc->wincol < 0 ) + dispc->wincol = 0; break; - case K_CTRL_RIGHT: wincol += 16; /* move cursor */ - bRefresh = HB_TRUE; /* 16 col to right */ + case K_CTRL_RIGHT: dispc->wincol += 16; /* move cursor */ + dispc->bRefresh = HB_TRUE; /* 16 col to right */ - if( wincol > ( maxlin - width ) ) - wincol = maxlin - width; + if( dispc->wincol > ( dispc->maxlin - dispc->width ) ) + dispc->wincol = dispc->maxlin - dispc->width; break; - case K_PGUP: for( i = 0; i < height; i++ ) /* move window */ - winup(); /* up one page */ + case K_PGUP: for( i = 0; i < dispc->height; i++ ) /* move window */ + winup(); /* up one page */ break; - case K_PGDN: for( i = 0; i < height; i++ ) /* move window */ - windown(); /* down 1 page */ + case K_PGDN: for( i = 0; i < dispc->height; i++ ) /* move window */ + windown(); /* down 1 page */ break; @@ -742,18 +776,18 @@ HB_FUNC( FT_DISPFILE ) /* scan key list and see if key pressed is there */ - default: if( keytype == K_STRING ) + default: if( dispc->keytype == K_STRING ) { - for( i = 0; i <= kcount; i++ ) + for( i = 0; i <= dispc->kcount; i++ ) if( ch > 0 && ch < 256 ) - if( ( int ) kstr[ i ] == ch ) + if( ( int ) dispc->kstr[ i ] == ch ) bDone = HB_TRUE; break; /* if so terminate */ } else { - for( i = 0; i < kcount; i++ ) - if( keylist[ i ] == ch ) + for( i = 0; i < dispc->kcount; i++ ) + if( dispc->keylist[ i ] == ch ) bDone = HB_TRUE; break; } @@ -768,7 +802,7 @@ HB_FUNC( FT_DISPFILE ) /* return key value to caller */ - if( keytype == K_STRING ) + if( dispc->keytype == K_STRING ) { rval[ 0 ] = ( char ) ch; rval[ 1 ] = '\0'; diff --git a/harbour/contrib/hbnf/doc/en/acctadj.txt b/harbour/contrib/hbnf/doc/en/acctadj.txt index b7d52ac37d..11d11029ed 100644 --- a/harbour/contrib/hbnf/doc/en/acctadj.txt +++ b/harbour/contrib/hbnf/doc/en/acctadj.txt @@ -41,19 +41,19 @@ * $EXAMPLES$ * Beginning of period mode (lIsEnd == .F.) * - * dDate := Ctod( "01/31/91" ) // In last 3 days of work week - * ? FT_ACCTADJ( dDate ) // 02/03/91 (next week's start) + * dDate := SToD( "19910131" ) // In last 3 days of work week + * ? FT_ACCTADJ( dDate ) // 1991.02.03 (next week's start) * - * dDate := Ctod( "03/31/91" ) // Not in last 3 days of work week - * ? FT_ACCTADJ( dDate ) // 03/31/91 (this week's start) + * dDate := SToD( "19910331" ) // Not in last 3 days of work week + * ? FT_ACCTADJ( dDate ) // 1991.03.31 (this week's start) * * End of period mode (lIsEnd == .T.) * - * dDate := Ctod( "01/31/91" ) // In last 4 days of work week - * ? FT_ACCTADJ( dDate, .T. ) // 02/02/91 (this week's end) + * dDate := SToD( "19910131" ) // In last 4 days of work week + * ? FT_ACCTADJ( dDate, .T. ) // 1991.02.02 (this week's end) * - * dDate := Ctod( "03/31/91" ) // Not in last 4 days of work week - * ? FT_ACCTADJ( dDate, .T. ) // 03/30/91 (prior week's end) + * dDate := SToD( "19910331" ) // Not in last 4 days of work week + * ? FT_ACCTADJ( dDate, .T. ) // 1991.03.30 (prior week's end) * $SEEALSO$ * FT_DATECNFG() FT_DAYTOBOW() * $END$ diff --git a/harbour/contrib/hbnf/doc/en/acctmnth.txt b/harbour/contrib/hbnf/doc/en/acctmnth.txt index 01f3b04022..b5b9da7eb6 100644 --- a/harbour/contrib/hbnf/doc/en/acctmnth.txt +++ b/harbour/contrib/hbnf/doc/en/acctmnth.txt @@ -41,13 +41,13 @@ * weeks. * $EXAMPLES$ * // get info about accounting month containing 9/15/90 - * aDateInfo := FT_ACCTMONTH( Ctod("09/15/90") ) + * aDateInfo := FT_ACCTMONTH( SToD("19900915") ) * ? aDateInfo[1] // 199009 (9th month) * ? aDateInfo[2] // 09/02/90 beginning of month 9 * ? aDateInfo[3] // 09/29/90 end of month 9 * * // get info about accounting month 5 in year containing 9/15/90 - * aDateInfo := FT_ACCTMONTH( Ctod("09/15/90"), 5 ) + * aDateInfo := FT_ACCTMONTH( SToD("19900915"), 5 ) * ? aDateInfo[1] // 199005 * ? aDateInfo[2] // 04/29/89 beginning of month 5 * ? aDateInfo[3] // 06/02/90 end of month 5 diff --git a/harbour/contrib/hbnf/doc/en/acctqtr.txt b/harbour/contrib/hbnf/doc/en/acctqtr.txt index 311aa39720..ba8650625a 100644 --- a/harbour/contrib/hbnf/doc/en/acctqtr.txt +++ b/harbour/contrib/hbnf/doc/en/acctqtr.txt @@ -41,16 +41,16 @@ * weeks. * $EXAMPLES$ * // get info about accounting month containing 9/15/90 - * aDateInfo := FT_ACCTQTR( CTOD("09/15/90") ) - * ? aDateInfo[1] // 199003 (3rd quarter) - * ? aDateInfo[2] // 07/01/90 beginning of quarter 3 - * ? aDateInfo[3] // 09/29/90 end of quarter 3 + * aDateInfo := FT_ACCTQTR( SToD( "19900915" ) ) + * ? aDateInfo[ 1 ] // 199003 (3rd quarter) + * ? aDateInfo[ 2 ] // 07/01/90 beginning of quarter 3 + * ? aDateInfo[ 3 ] // 09/29/90 end of quarter 3 * * // get info about accounting qtr. 2 in year containing 9/15/90 - * aDateInfo := FT_ACCTQTR( CTOD("09/15/90"), 2 ) - * ? aDateInfo[1] // 199002 - * ? aDateInfo[2] // 04/01/89 beginning of quarter 2 - * ? aDateInfo[3] // 06/30/90 end of quarter 2 + * aDateInfo := FT_ACCTQTR( SToD( "19900915" ), 2 ) + * ? aDateInfo[ 1 ] // 199002 + * ? aDateInfo[ 2 ] // 04/01/89 beginning of quarter 2 + * ? aDateInfo[ 3 ] // 06/30/90 end of quarter 2 * $SEEALSO$ * FT_DATECNFG() FT_ACCTWEEK() FT_ACCTMONTH() FT_ACCTYEAR() * $END$ diff --git a/harbour/contrib/hbnf/doc/en/acctweek.txt b/harbour/contrib/hbnf/doc/en/acctweek.txt index 2ae5294fd2..3f832f2420 100644 --- a/harbour/contrib/hbnf/doc/en/acctweek.txt +++ b/harbour/contrib/hbnf/doc/en/acctweek.txt @@ -41,16 +41,16 @@ * weeks. * $EXAMPLES$ * // get info about accounting week containing 9/15/90 - * aDateInfo := FT_ACCTWEEK( CTOD("09/15/90") ) - * ? aDateInfo[1] // 199037 (37th week) - * ? aDateInfo[2] // 09/09/90 beginning of week 37 - * ? aDateInfo[3] // 09/15/90 end of week 37 + * aDateInfo := FT_ACCTWEEK( SToD( "19900915" ) ) + * ? aDateInfo[ 1 ] // 199037 (37th week) + * ? aDateInfo[ 2 ] // 09/09/90 beginning of week 37 + * ? aDateInfo[ 3 ] // 09/15/90 end of week 37 * * // get info about accounting week 25 in year containing 9/15/90 - * aDateInfo := FT_ACCTWEEK( CTOD("09/15/90"), 25 ) - * ? aDateInfo[1] // 199025 - * ? aDateInfo[2] // 06/17/89 beginning of week 25 - * ? aDateInfo[3] // 06/23/90 end of week 25 + * aDateInfo := FT_ACCTWEEK( SToD( "19900915" ), 25 ) + * ? aDateInfo[ 1 ] // 199025 + * ? aDateInfo[ 2 ] // 06/17/89 beginning of week 25 + * ? aDateInfo[ 3 ] // 06/23/90 end of week 25 * $SEEALSO$ * FT_DATECNFG() FT_ACCTMONTH() FT_ACCTQTR() FT_ACCTYEAR() * $END$ diff --git a/harbour/contrib/hbnf/doc/en/acctyear.txt b/harbour/contrib/hbnf/doc/en/acctyear.txt index ad3c914d5b..7131c1d8e4 100644 --- a/harbour/contrib/hbnf/doc/en/acctyear.txt +++ b/harbour/contrib/hbnf/doc/en/acctyear.txt @@ -38,10 +38,10 @@ * weeks. * $EXAMPLES$ * // get info about accounting year containing 9/15/90 - * aDateInfo := FT_ACCTYEAR( CTOD("09/15/90") ) - * ? aDateInfo[1] // 1990 - * ? aDateInfo[2] // 12/31/89 beginning of year - * ? aDateInfo[3] // 12/29/90 end of year + * aDateInfo := FT_ACCTYEAR( SToD( "19900915" ) ) + * ? aDateInfo[ 1 ] // 1990 + * ? aDateInfo[ 2 ] // 12/31/89 beginning of year + * ? aDateInfo[ 3 ] // 12/29/90 end of year * $SEEALSO$ * FT_DATECNFG() FT_ACCTWEEK() FT_ACCTMONTH() FT_ACCTQTR() * $END$ diff --git a/harbour/contrib/hbnf/doc/en/dayofyr.txt b/harbour/contrib/hbnf/doc/en/dayofyr.txt index 5440033549..1ede76a5b1 100644 --- a/harbour/contrib/hbnf/doc/en/dayofyr.txt +++ b/harbour/contrib/hbnf/doc/en/dayofyr.txt @@ -43,20 +43,20 @@ * The beginning of year date defaults to January 1st but may be * changed with FT_DATECNFG(). * $EXAMPLES$ - * aDateInfo := FT_DAYOFYR( CTOD("03/31/91") ) - * ? aDateInfo[1] // 1991090 (90th day of year 1991) - * ? aDateInfo[2] // 01/01/91 - * ? aDateInfo[3] // 12/31/91 + * aDateInfo := FT_DAYOFYR( SToD( "19910331" ) ) + * ? aDateInfo[ 1 ] // 1991090 (90th day of year 1991) + * ? aDateInfo[ 2 ] // 01/01/91 + * ? aDateInfo[ 3 ] // 12/31/91 * * aDateInfo := FT_DAYOFYR( , 90 ) // assume current date is 3/31/91 - * ? aDateInfo[1] // 03/31/91 (90th day of year) - * ? aDateInfo[2] // 01/01/91 - * ? aDateInfo[3] // 12/31/91 + * ? aDateInfo[ 1 ] // 03/31/91 (90th day of year) + * ? aDateInfo[ 2 ] // 01/01/91 + * ? aDateInfo[ 3 ] // 12/31/91 * * aDateInfo := FT_DAYOFYR( , 90, .T. ) - * ? aDateInfo[1] // 03/29/91 (90th day of accounting year) - * ? aDateInfo[2] // 12/30/90 (1st day of accounting year) - * ? aDateInfo[3] // 12/28/91 (last day of accounting year) + * ? aDateInfo[ 1 ] // 03/29/91 (90th day of accounting year) + * ? aDateInfo[ 2 ] // 12/30/90 (1st day of accounting year) + * ? aDateInfo[ 3 ] // 12/28/91 (last day of accounting year) * $SEEALSO$ * FT_DATECNFG() * $END$ diff --git a/harbour/contrib/hbnf/doc/en/daytobow.txt b/harbour/contrib/hbnf/doc/en/daytobow.txt index 736c5a3df4..9ecbecd6d6 100644 --- a/harbour/contrib/hbnf/doc/en/daytobow.txt +++ b/harbour/contrib/hbnf/doc/en/daytobow.txt @@ -23,7 +23,7 @@ * day for the beginning of the week has been changed with * FT_DATECNFG(). * $EXAMPLES$ - * dDate := CTOD( "09/15/90" ) + * dDate := SToD( "19900915" ) * * ? DOW( dDate ) // 7 * ? CDOW( dDate ) // Saturday diff --git a/harbour/contrib/hbnf/doc/en/elapsed.txt b/harbour/contrib/hbnf/doc/en/elapsed.txt index cd73634506..f3643d7849 100644 --- a/harbour/contrib/hbnf/doc/en/elapsed.txt +++ b/harbour/contrib/hbnf/doc/en/elapsed.txt @@ -29,17 +29,17 @@ * * It returns an array which contains the following data: * - * aRetVal[1,1] Integer Days aRetVal[1,2] Total Days (nn.nnnn) - * aRetVal[2,1] Integer Hours aRetVal[2,2] Total Hours (nn.nnnn) - * aRetVal[3,1] Integer Minutes aRetVal[3,2] Total Minutes (nn.nnnn) - * aRetVal[4,1] Integer Seconds aRetVal[4,2] Total Seconds (nn) + * aRetVal[ 1, 1 ] Integer Days aRetVal[ 1, 2 ] Total Days (nn.nnnn) + * aRetVal[ 2, 1 ] Integer Hours aRetVal[ 2, 2 ] Total Hours (nn.nnnn) + * aRetVal[ 3, 1 ] Integer Minutes aRetVal[ 3, 2 ] Total Minutes (nn.nnnn) + * aRetVal[ 4, 1 ] Integer Seconds aRetVal[ 4, 2 ] Total Seconds (nn) * $EXAMPLES$ - * FT_ELAPSED(CTOD('11/28/90'), CTOD('11/30/90'), '08:00:00', '12:10:30') + * FT_ELAPSED( SToD( "19901128" ), SToD( "19901130" ), "08:00:00", "12:10:30" ) * will return: * - * aRetVal[1,1] -> 2 (Days) aRetVal[1,2] -> 2.1740 Days - * aRetVal[2,1] -> 4 (Hours) aRetVal[2,2] -> 52.1750 Hours - * aRetVal[3,1] -> 10 (Minutes) aRetVal[3,2] -> 3130.5000 Minutes - * aRetVal[4,1] -> 30 (Seconds) aRetVal[4,2] -> 187830 Seconds + * aRetVal[ 1, 1 ] -> 2 (Days) aRetVal[ 1, 2 ] -> 2.1740 Days + * aRetVal[ 2, 1 ] -> 4 (Hours) aRetVal[ 2, 2 ] -> 52.1750 Hours + * aRetVal[ 3, 1 ] -> 10 (Minutes) aRetVal[ 3, 2 ] -> 3130.5000 Minutes + * aRetVal[ 4, 1 ] -> 30 (Seconds) aRetVal[ 4, 2 ] -> 187830 Seconds * $END$ */ diff --git a/harbour/contrib/hbnf/doc/en/firstday.txt b/harbour/contrib/hbnf/doc/en/firstday.txt index e85ac3190c..28ec1a72ee 100644 --- a/harbour/contrib/hbnf/doc/en/firstday.txt +++ b/harbour/contrib/hbnf/doc/en/firstday.txt @@ -22,7 +22,7 @@ * passed, or the first day of the current month if no argument is * supplied. * $EXAMPLES$ - * dDate := CTOD( "09/15/90" ) + * dDate := SToD( "19900915" ) * ? FT_FDAY( dDate ) // 09/01/90 * ? FT_FDAY() // 03/01/91 (current month) * $SEEALSO$ diff --git a/harbour/contrib/hbnf/doc/en/lastday.txt b/harbour/contrib/hbnf/doc/en/lastday.txt index 418027231b..d86d9d0104 100644 --- a/harbour/contrib/hbnf/doc/en/lastday.txt +++ b/harbour/contrib/hbnf/doc/en/lastday.txt @@ -22,7 +22,7 @@ * passed, or the last day of the current month if no argument is * supplied. * $EXAMPLES$ - * dDate := CTOD( "09/15/90" ) + * dDate := SToD( "19900915" ) * ? FT_LDAY( dDate ) // 09/30/90 * ? FT_LDAY() // 03/31/91 (current month) * $SEEALSO$ diff --git a/harbour/contrib/hbnf/doc/en/madd.txt b/harbour/contrib/hbnf/doc/en/madd.txt index 6b7a6278a7..7ade2b2ee1 100644 --- a/harbour/contrib/hbnf/doc/en/madd.txt +++ b/harbour/contrib/hbnf/doc/en/madd.txt @@ -31,12 +31,12 @@ * it will return the EOM of calculated month. Otherwise it will * return the same day as the day of the passed date. * $EXAMPLES$ - * dDate := CTOD( "09/15/90" ) + * dDate := SToD( "19900915" ) * ? FT_MADD( dDate, 1 ) // 10/15/90 * ? FT_MADD( dDate, -2 ) // 07/15/90 * * // force EOM - * dDate := CTOD( "04/30/91" ) + * dDate := SToD( "19910430" ) * ? FT_MADD( dDate, 1 ) // 05/30/91 * ? FT_MADD( dDate, 1, .T. ) // 05/31/91 <- forced EOM * ? FT_MADD( dDate, 2 ) // 06/30/91 diff --git a/harbour/contrib/hbnf/doc/en/month.txt b/harbour/contrib/hbnf/doc/en/month.txt index 5a580683e0..3328786651 100644 --- a/harbour/contrib/hbnf/doc/en/month.txt +++ b/harbour/contrib/hbnf/doc/en/month.txt @@ -39,22 +39,22 @@ * parameters. * $EXAMPLES$ * // get info about month containing 9/15/90 - * aDateInfo := FT_MONTH( CTOD("09/15/90") ) - * ? aDateInfo[1] // 199009 (9th month) - * ? aDateInfo[2] // 09/01/90 beginning of month 9 - * ? aDateInfo[3] // 09/30/90 end of week month 9 + * aDateInfo := FT_MONTH( SToD( "19900915" ) ) + * ? aDateInfo[ 1 ] // 199009 (9th month) + * ? aDateInfo[ 2 ] // 09/01/90 beginning of month 9 + * ? aDateInfo[ 3 ] // 09/30/90 end of week month 9 * * // get info about month 5 in year containing 9/15/90 - * aDateInfo := FT_MONTH( CTOD("09/15/90"), 5 ) - * ? aDateInfo[1] // 199005 - * ? aDateInfo[2] // 05/01/90 beginning of month 5 - * ? aDateInfo[3] // 05/31/90 end of month 5 + * aDateInfo := FT_MONTH( SToD( "19900915" ), 5 ) + * ? aDateInfo[ 1 ] // 199005 + * ? aDateInfo[ 2 ] // 05/01/90 beginning of month 5 + * ? aDateInfo[ 3 ] // 05/31/90 end of month 5 * * // get info about month 5 in current year (1991) * aDateInfo := FT_MONTH( , 5 ) - * ? aDateInfo[1] // 199105 - * ? aDateInfo[2] // 05/01/91 beginning of month 5 - * ? aDateInfo[3] // 05/31/91 end of month 5 + * ? aDateInfo[ 1 ] // 199105 + * ? aDateInfo[ 2 ] // 05/01/91 beginning of month 5 + * ? aDateInfo[ 3 ] // 05/31/91 end of month 5 * $SEEALSO$ * FT_DATECNFG() FT_WEEK() FT_QTR() FT_YEAR() * $END$ diff --git a/harbour/contrib/hbnf/doc/en/qtr.txt b/harbour/contrib/hbnf/doc/en/qtr.txt index 7ff0103d30..8cc5885c80 100644 --- a/harbour/contrib/hbnf/doc/en/qtr.txt +++ b/harbour/contrib/hbnf/doc/en/qtr.txt @@ -39,22 +39,22 @@ * parameters. * $EXAMPLES$ * // get info about quarter containing 9/15/90 - * aDateInfo := FT_QTR( CTOD("09/15/90") ) - * ? aDateInfo[1] // 199003 (3rd quarter) - * ? aDateInfo[2] // 07/01/90 beginning of quarter 3 - * ? aDateInfo[3] // 09/30/90 end of week quarter 3 + * aDateInfo := FT_QTR( SToD( "19900915" ) ) + * ? aDateInfo[ 1 ] // 199003 (3rd quarter) + * ? aDateInfo[ 2 ] // 07/01/90 beginning of quarter 3 + * ? aDateInfo[ 3 ] // 09/30/90 end of week quarter 3 * * // get info about quarter 2 in year containing 9/15/90 - * aDateInfo := FT_QTR( CTOD("09/15/90"), 2 ) - * ? aDateInfo[1] // 199002 - * ? aDateInfo[2] // 04/01/90 beginning of quarter 2 - * ? aDateInfo[3] // 06/30/90 end of quarter 2 + * aDateInfo := FT_QTR( SToD( "19900915" ), 2 ) + * ? aDateInfo[ 1 ] // 199002 + * ? aDateInfo[ 2 ] // 04/01/90 beginning of quarter 2 + * ? aDateInfo[ 3 ] // 06/30/90 end of quarter 2 * * // get info about quarter 2 in current year (1991) * aDateInfo := FT_QTR( , 2 ) - * ? aDateInfo[1] // 199102 - * ? aDateInfo[2] // 04/01/91 beginning of quarter 2 - * ? aDateInfo[3] // 06/30/91 end of quarter 2 + * ? aDateInfo[ 1 ] // 199102 + * ? aDateInfo[ 2 ] // 04/01/91 beginning of quarter 2 + * ? aDateInfo[ 3 ] // 06/30/91 end of quarter 2 * $SEEALSO$ * FT_DATECNFG() FT_WEEK() FT_MONTH() FT_YEAR() * $END$ diff --git a/harbour/contrib/hbnf/doc/en/savearr.txt b/harbour/contrib/hbnf/doc/en/savearr.txt index 071c1d7181..415aa87bdf 100644 --- a/harbour/contrib/hbnf/doc/en/savearr.txt +++ b/harbour/contrib/hbnf/doc/en/savearr.txt @@ -38,18 +38,18 @@ * * * $EXAMPLES$ - * aArray := { {'Invoice 1',CTOD('04/15/91'),1234.32,.T.},; - * {'Invoice 2',DATE(),234.98,.F.},; - * {'Invoice 3',DATE() + 1,0,.T.} } + * aArray := { { "Invoice 1", SToD( "19910415" ), 1234.32, .T. },; + * { "Invoice 2", Date(), 234.98, .F. },; + * { "Invoice 3", Date() + 1, 0, .T. } } * nErrorCode := 0 - * FT_SAVEARR(aArray,'invoice.dat',@nErrorCode) - * IF nErrorCode = 0 - * aSave := FT_RESTARR('invoice.dat',@nErrorCode) - * IF nErrorCode # 0 - * ? 'Error restoring array' - * ENDIF + * FT_SAVEARR( aArray, "invoice.dat", @nErrorCode ) + * IF nErrorCode == 0 + * aSave := FT_RESTARR( "invoice.dat", @nErrorCode ) + * IF nErrorCode != 0 + * ? "Error restoring array" + * ENDIF * ELSE - * ? 'Error writing array' + * ? "Error writing array" * ENDIF * * $SEEALSO$ @@ -85,18 +85,18 @@ * please do and send it to Glenn Scott 71620,1521.] * * $EXAMPLES$ - * aArray := { {'Invoice 1',CTOD('04/15/91'),1234.32,.T.},; - * {'Invoice 2',DATE(),234.98,.F.},; - * {'Invoice 3',DATE() + 1,0,.T.} } + * aArray := { { "Invoice 1", SToD( "19910415" ), 1234.32, .T. },; + * { "Invoice 2", Date(), 234.98, .F. },; + * { "Invoice 3", Date() + 1, 0, .T. } } * nErrorCode := 0 - * FT_SAVEARR(aArray,'invoice.dat',@nErrorCode) - * IF nErrorCode = 0 - * aSave := FT_RESTARR('invoice.dat',@nErrorCode) - * IF nErrorCode # 0 - * ? 'Error restoring array' - * ENDIF + * FT_SAVEARR( aArray, "invoice.dat", @nErrorCode ) + * IF nErrorCode == 0 + * aSave := FT_RESTARR( "invoice.dat", @nErrorCode ) + * IF nErrorCode != 0 + * ? "Error restoring array" + * ENDIF * ELSE - * ? 'Error writing array' + * ? "Error writing array" * ENDIF * * $SEEALSO$ diff --git a/harbour/contrib/hbnf/doc/en/setdate.txt b/harbour/contrib/hbnf/doc/en/setdate.txt index 0c92c26de4..f764ccad3a 100644 --- a/harbour/contrib/hbnf/doc/en/setdate.txt +++ b/harbour/contrib/hbnf/doc/en/setdate.txt @@ -33,9 +33,9 @@ * * PROCEDURE Main( cDate ) * - * cDate := iif( cDate == NIL, DToC( Date() ), cDate ) + * cDate := iif( cDate == NIL, DToS( Date() ), cDate ) * ? "Setting date to: " + cDate + "... " - * FT_SETDATE( CToD( cDate ) ) + * FT_SETDATE( SToD( cDate ) ) * ? "Today is now: " + DToC( Date() ) * * RETURN diff --git a/harbour/contrib/hbnf/doc/en/stod.txt b/harbour/contrib/hbnf/doc/en/stod.txt index 2135b11b35..e7def305b3 100644 --- a/harbour/contrib/hbnf/doc/en/stod.txt +++ b/harbour/contrib/hbnf/doc/en/stod.txt @@ -4,13 +4,13 @@ /* $DOC$ * $FUNCNAME$ - * FT_STOD() + * FT_SToD() * $CATEGORY$ * Conversion * $ONELINER$ * Convert a date string to a Clipper date data type * $SYNTAX$ - * FT_STOD( ) -> dDateType + * FT_SToD( ) -> dDateType * $ARGUMENTS$ * is a Clipper string in the format "CCYYMMDD". * $RETURNS$ @@ -21,6 +21,6 @@ * function is the converse of the Clipper DTOS() function. * $EXAMPLES$ * LOCAL dMyDate - * dMyDate := FT_STOD( "19901127" ) + * dMyDate := FT_SToD( "19901127" ) * $END$ */ diff --git a/harbour/contrib/hbnf/doc/en/wda.txt b/harbour/contrib/hbnf/doc/en/wda.txt index c14e2373c4..ba19199803 100644 --- a/harbour/contrib/hbnf/doc/en/wda.txt +++ b/harbour/contrib/hbnf/doc/en/wda.txt @@ -26,7 +26,7 @@ * When is the due date? Assuming you are printing the invoices * today, your answer is: * - * dDueDate := DATE() + ft_addWkDay( DATE(), 10 ) + * dDueDate := DATE() + ft_addWkDay( Date(), 10 ) * * A work day is defined as Monday through Friday. Unfortunately * this routine does _not_ account for holidays. @@ -36,9 +36,9 @@ * * $EXAMPLES$ * // Postdate 5 working days from the first of January - * dPost := CTOD("01/01/91") + * dPost := SToD( "19910101" ) * dPost += FT_ADDWKDY( dPost, 5 ) // returns 7 true days - * ? dPost // 01/08/91 + * ? dPost // 01/08/91 * * $SEEALSO$ * FT_WORKDAYS() diff --git a/harbour/contrib/hbnf/doc/en/week.txt b/harbour/contrib/hbnf/doc/en/week.txt index 3e3a9906b4..a06adb58ed 100644 --- a/harbour/contrib/hbnf/doc/en/week.txt +++ b/harbour/contrib/hbnf/doc/en/week.txt @@ -39,22 +39,22 @@ * parameters. * $EXAMPLES$ * // get info about week containing 9/15/90 - * aDateInfo := FT_WEEK( CTOD("09/15/90") ) - * ? aDateInfo[1] // 199037 (37th week) - * ? aDateInfo[2] // 09/09/90 beginning of week 37 - * ? aDateInfo[3] // 09/15/90 end of week 37 + * aDateInfo := FT_WEEK( SToD( "19900915" ) ) + * ? aDateInfo[ 1 ] // 199037 (37th week) + * ? aDateInfo[ 2 ] // 09/09/90 beginning of week 37 + * ? aDateInfo[ 3 ] // 09/15/90 end of week 37 * * // get info about week 25 in year containing 9/15/90 - * aDateInfo := FT_WEEK( CTOD("09/15/90"), 25 ) - * ? aDateInfo[1] // 199025 - * ? aDateInfo[2] // 06/17/90 beginning of week 25 - * ? aDateInfo[3] // 06/23/90 end of week 25 + * aDateInfo := FT_WEEK( SToD( "19900915" ), 25 ) + * ? aDateInfo[ 1 ] // 199025 + * ? aDateInfo[ 2 ] // 06/17/90 beginning of week 25 + * ? aDateInfo[ 3 ] // 06/23/90 end of week 25 * * // get info about week 25 in current year( 1991 ) * aDateInfo := FT_WEEK( , 25 ) - * ? aDateInfo[1] // 199025 - * ? aDateInfo[2] // 06/16/91 beginning of week 25 - * ? aDateInfo[3] // 06/22/91 end of week 25 + * ? aDateInfo[ 1 ] // 199025 + * ? aDateInfo[ 2 ] // 06/16/91 beginning of week 25 + * ? aDateInfo[ 3 ] // 06/22/91 end of week 25 * $SEEALSO$ * FT_DATECNFG() FT_MONTH() FT_QTR() FT_YEAR() FT_DAYTOBOW() * $END$ diff --git a/harbour/contrib/hbnf/doc/en/workdays.txt b/harbour/contrib/hbnf/doc/en/workdays.txt index e3886fde04..985a0680fc 100644 --- a/harbour/contrib/hbnf/doc/en/workdays.txt +++ b/harbour/contrib/hbnf/doc/en/workdays.txt @@ -25,9 +25,9 @@ * (The five day work week none of us Clipper programmers have.) * * $EXAMPLES$ - * ? FT_WorkDays( CTOD("5/16/91"), CTOD("5/20/91") ) // 3 (Th - Mo) - * ? FT_WorkDays( CTOD("5/18/91"), CTOD("5/19/91") ) // 0 (Sa - Su) - * ? FT_WorkDays( CTOD("5/17/91"), CTOD("5/17/91") ) // 1 (Fr - Fr) + * ? FT_WorkDays( SToD( "19910516" ), SToD( "19910520" ) ) // 3 (Th - Mo) + * ? FT_WorkDays( SToD( "19910518" ), SToD( "19910519" ) ) // 0 (Sa - Su) + * ? FT_WorkDays( SToD( "19910517" ), SToD( "19910517" ) ) // 1 (Fr - Fr) * $SEEALSO$ * * $END$ diff --git a/harbour/contrib/hbnf/doc/en/woy.txt b/harbour/contrib/hbnf/doc/en/woy.txt index c006396d64..0b9009f220 100644 --- a/harbour/contrib/hbnf/doc/en/woy.txt +++ b/harbour/contrib/hbnf/doc/en/woy.txt @@ -27,20 +27,20 @@ * These code fragments find the week number, given a date. * * // literal character date - * dDate := CTOD("01/01/91") - * nWkNum := FT_WOY(dDate) // result: 1 + * dDate := SToD( "19910101" ) + * nWkNum := FT_WOY( dDate ) // result: 1 * * // presume DOS date to be 01/06/91 - * nWkNum := FT_WOY(DATE()) // result: 2 + * nWkNum := FT_WOY( Date() ) // result: 2 * * // date input - * cDate := SPACE(8) - * @ 4,10 get cDate PICT "##/##/##" // input 07/04/91 + * dDate := SToD( "" ) + * @ 4, 10 GET cDate // input 1991/07/04 * READ - * nWkNum := FT_WOY(CTOD(cDate)) // result: 27 + * nWkNum := FT_WOY( dDate ) // result: 27 * * // last day of year - * nWkNum := FT_WOY(CTOD("12/31/91")) // result: 53 + * nWkNum := FT_WOY( SToD( "19911231" ) ) // result: 53 * * For a demonstration of this function, compile and link the * program woy.prg in the Nanforum Toolkit source code. @@ -69,20 +69,20 @@ * These code fragments find the day number, given a date. * * // literal character date - * dDate := CTOD("01/01/91") - * nDayNum := FT_DOY(dDate) // result: 1 + * dDate := SToD( "19910101" ) + * nDayNum := FT_DOY( dDate ) // result: 1 * * // presume DOS date to be 01/06/91 - * nDayNum := FT_DOY(DATE()) // result: 6 + * nDayNum := FT_DOY( Date() ) // result: 6 * * // date input - * cDate := SPACE(8) - * @ 4,10 get cDate PICT "##/##/##" // input 07/04/91 + * dDate := SToD( "" ) + * @ 4, 10 GET cDate // input 1991/07/04 * READ - * nDayNum := FT_DOY(CTOD(cDate)) // result: 185 + * nDayNum := FT_DOY( dDate ) // result: 185 * * // last day of year - * nDayNum := FT_DOY(CTOD("12/31/91")) // result: 365 + * nDayNum := FT_DOY( SToD( "19911231" ) ) // result: 365 * * For a demonstration of this function, compile and link the * program woy.prg in the Nanforum Toolkit source code. diff --git a/harbour/contrib/hbnf/doc/en/year.txt b/harbour/contrib/hbnf/doc/en/year.txt index 7a7692d3c5..8876bf6fd3 100644 --- a/harbour/contrib/hbnf/doc/en/year.txt +++ b/harbour/contrib/hbnf/doc/en/year.txt @@ -36,16 +36,16 @@ * $EXAMPLES$ * // Get info about year containing 9/15/90, assuming default * // beginning of year is January 1st. - * aDateInfo := FT_YEAR( Ctod("09/15/90") ) - * ? aDateInfo[1] // 1990 - * ? aDateInfo[2] // 01/01/90 beginning of year - * ? aDateInfo[3] // 12/31/90 end of year + * aDateInfo := FT_YEAR( SToD( "19900915" ) ) + * ? aDateInfo[ 1 ] // 1990 + * ? aDateInfo[ 2 ] // 01/01/90 beginning of year + * ? aDateInfo[ 3 ] // 12/31/90 end of year * * // get info about current year (1991). * aDateInfo := FT_YEAR() - * ? aDateInfo[1] // 1991 - * ? aDateInfo[2] // 01/01/91 beginning of year - * ? aDateInfo[3] // 12/31/91 end of year + * ? aDateInfo[ 1 ] // 1991 + * ? aDateInfo[ 2 ] // 01/01/91 beginning of year + * ? aDateInfo[ 3 ] // 12/31/91 end of year * $SEEALSO$ * FT_DATECNFG() FT_WEEK() FT_MONTH() FT_QTR() * $END$ diff --git a/harbour/contrib/hbnf/pegs.prg b/harbour/contrib/hbnf/pegs.prg index 84a351edd2..f9a1152f1e 100644 --- a/harbour/contrib/hbnf/pegs.prg +++ b/harbour/contrib/hbnf/pegs.prg @@ -31,8 +31,6 @@ #include "inkey.ch" #include "setcurs.ch" -#translate SINGLEBOX( , , , ) => ; - hb_DispBox( , , , , hb_UTF8ToStrBox( "┌─┐│┘─└│ " ) ) #translate DOUBLEBOX( , , , ) => ; hb_DispBox( , , , , hb_UTF8ToStrBox( "╔═╗║╝═╚║ " ) ) @@ -44,41 +42,6 @@ board_[xx, 4] - is the location occupied or not? .T. -> Yes, .F. -> No */ -THREAD STATIC t_board_ := {; - { { 0, 29, 2, 34 }, { 2, 4 }, { 3, 9 }, .T. } , ; - { { 0, 37, 2, 42 }, { 5 }, { 10 }, .T. } , ; - { { 0, 45, 2, 50 }, { 2, 6 }, { 1, 11 }, .T. } , ; - { { 3, 29, 5, 34 }, { 5, 9 }, { 6, 16 }, .T. } , ; - { { 3, 37, 5, 42 }, { 10 }, { 17 }, .T. } , ; - { { 3, 45, 5, 50 }, { 5, 11 }, { 4, 18 }, .T. } , ; - { { 6, 13, 8, 18 }, { 8, 14 }, { 9, 21 }, .T. } , ; - { { 6, 21, 8, 26 }, { 9, 15 }, { 10, 22 }, .T. } , ; - { { 6, 29, 8, 34 }, { 4, 8, 10, 16 }, { 1, 7, 11, 23 }, .T. } , ; - { { 6, 37, 8, 42 }, { 5, 9, 11, 17 }, { 2, 8, 12, 24 }, .T. } , ; - { { 6, 45, 8, 50 }, { 6, 10, 12, 18 }, { 3, 9, 13, 25 }, .T. } , ; - { { 6, 53, 8, 58 }, { 11, 19 }, { 10, 26 }, .T. } , ; - { { 6, 61, 8, 66 }, { 12, 20 }, { 11, 27 }, .T. } , ; - { { 9, 13, 11, 18 }, { 15 }, { 16 }, .T. } , ; - { { 9, 21, 11, 26 }, { 16 }, { 17 }, .T. } , ; - { { 9, 29, 11, 34 }, { 9, 15, 17, 23 }, { 4, 14, 18, 28 }, .T. } , ; - { { 9, 37, 11, 42 }, { 10, 16, 18, 24 }, { 5, 15, 19, 29 }, .F. } , ; - { { 9, 45, 11, 50 }, { 11, 17, 19, 25 }, { 6, 16, 20, 30 }, .T. } , ; - { { 9, 53, 11, 58 }, { 18 }, { 17 }, .T. } , ; - { { 9, 61, 11, 66 }, { 19 }, { 18 }, .T. } , ; - { { 12, 13, 14, 18 }, { 14, 22 }, { 7, 23 }, .T. } , ; - { { 12, 21, 14, 26 }, { 15, 23 }, { 8, 24 }, .T. } , ; - { { 12, 29, 14, 34 }, { 16, 22, 24, 28 }, { 9, 21, 25, 31 }, .T. } , ; - { { 12, 37, 14, 42 }, { 17, 23, 25, 29 }, { 10, 22, 26, 32 }, .T. } , ; - { { 12, 45, 14, 50 }, { 18, 24, 26, 30 }, { 11, 23, 27, 33 }, .T. } , ; - { { 12, 53, 14, 58 }, { 19, 25 }, { 12, 24 }, .T. } , ; - { { 12, 61, 14, 66 }, { 20, 26 }, { 13, 25 }, .T. } , ; - { { 15, 29, 17, 34 }, { 23, 29 }, { 16, 30 }, .T. } , ; - { { 15, 37, 17, 42 }, { 24 }, { 17 }, .T. } , ; - { { 15, 45, 17, 50 }, { 25, 29 }, { 18, 28 }, .T. } , ; - { { 18, 29, 20, 34 }, { 28, 32 }, { 23, 33 }, .T. } , ; - { { 18, 37, 20, 42 }, { 29 }, { 24 }, .T. } , ; - { { 18, 45, 20, 50 }, { 30, 32 }, { 25, 31 }, .T. } } - FUNCTION FT_PEGS() LOCAL XX, MOVE, MPOS, POSSIBLE_, BUFFER, TOPROW, OLDSCORE, MOVE2 @@ -86,6 +49,41 @@ FUNCTION FT_PEGS() LOCAL oldscrn := SaveScreen( 0, 0, MaxRow(), MaxCol() ) LOCAL GetList + LOCAL board_ := {; + { { 0, 29, 2, 34 }, { 2, 4 }, { 3, 9 }, .T. } , ; + { { 0, 37, 2, 42 }, { 5 }, { 10 }, .T. } , ; + { { 0, 45, 2, 50 }, { 2, 6 }, { 1, 11 }, .T. } , ; + { { 3, 29, 5, 34 }, { 5, 9 }, { 6, 16 }, .T. } , ; + { { 3, 37, 5, 42 }, { 10 }, { 17 }, .T. } , ; + { { 3, 45, 5, 50 }, { 5, 11 }, { 4, 18 }, .T. } , ; + { { 6, 13, 8, 18 }, { 8, 14 }, { 9, 21 }, .T. } , ; + { { 6, 21, 8, 26 }, { 9, 15 }, { 10, 22 }, .T. } , ; + { { 6, 29, 8, 34 }, { 4, 8, 10, 16 }, { 1, 7, 11, 23 }, .T. } , ; + { { 6, 37, 8, 42 }, { 5, 9, 11, 17 }, { 2, 8, 12, 24 }, .T. } , ; + { { 6, 45, 8, 50 }, { 6, 10, 12, 18 }, { 3, 9, 13, 25 }, .T. } , ; + { { 6, 53, 8, 58 }, { 11, 19 }, { 10, 26 }, .T. } , ; + { { 6, 61, 8, 66 }, { 12, 20 }, { 11, 27 }, .T. } , ; + { { 9, 13, 11, 18 }, { 15 }, { 16 }, .T. } , ; + { { 9, 21, 11, 26 }, { 16 }, { 17 }, .T. } , ; + { { 9, 29, 11, 34 }, { 9, 15, 17, 23 }, { 4, 14, 18, 28 }, .T. } , ; + { { 9, 37, 11, 42 }, { 10, 16, 18, 24 }, { 5, 15, 19, 29 }, .F. } , ; + { { 9, 45, 11, 50 }, { 11, 17, 19, 25 }, { 6, 16, 20, 30 }, .T. } , ; + { { 9, 53, 11, 58 }, { 18 }, { 17 }, .T. } , ; + { { 9, 61, 11, 66 }, { 19 }, { 18 }, .T. } , ; + { { 12, 13, 14, 18 }, { 14, 22 }, { 7, 23 }, .T. } , ; + { { 12, 21, 14, 26 }, { 15, 23 }, { 8, 24 }, .T. } , ; + { { 12, 29, 14, 34 }, { 16, 22, 24, 28 }, { 9, 21, 25, 31 }, .T. } , ; + { { 12, 37, 14, 42 }, { 17, 23, 25, 29 }, { 10, 22, 26, 32 }, .T. } , ; + { { 12, 45, 14, 50 }, { 18, 24, 26, 30 }, { 11, 23, 27, 33 }, .T. } , ; + { { 12, 53, 14, 58 }, { 19, 25 }, { 12, 24 }, .T. } , ; + { { 12, 61, 14, 66 }, { 20, 26 }, { 13, 25 }, .T. } , ; + { { 15, 29, 17, 34 }, { 23, 29 }, { 16, 30 }, .T. } , ; + { { 15, 37, 17, 42 }, { 24 }, { 17 }, .T. } , ; + { { 15, 45, 17, 50 }, { 25, 29 }, { 18, 28 }, .T. } , ; + { { 18, 29, 20, 34 }, { 28, 32 }, { 23, 33 }, .T. } , ; + { { 18, 37, 20, 42 }, { 29 }, { 24 }, .T. } , ; + { { 18, 45, 20, 50 }, { 30, 32 }, { 25, 31 }, .T. } } + /* the following code block is used in conjunction with ASCAN() to validate entry when there is more than one possible move @@ -94,10 +92,10 @@ FUNCTION FT_PEGS() scanblock := {| a | a[ 2 ] == move2 } CLS SetColor( "w/r" ) - SINGLEBOX( 22, 31, 24, 48 ) + hb_DispBox( 22, 31, 24, 48, hb_UTF8ToStrBox( "┌─┐│┘─└│ " ) ) hb_DispOutAt( 23, 33, "Your move:" ) - AEval( t_board_, {| a, x | HB_SYMBOL_UNUSED( a ), drawbox( x ) } ) - DO WHILE LastKey() != K_ESC .AND. moremoves() + AEval( board_, {| a, x | HB_SYMBOL_UNUSED( a ), drawbox( board_, x ) } ) + DO WHILE LastKey() != K_ESC .AND. moremoves( board_ ) move := 1 SetColor( "w/n" ) @@ -108,25 +106,25 @@ FUNCTION FT_PEGS() IF move > 0 DO CASE - CASE ! t_board_[ move ][ 4 ] + CASE ! board_[ move ][ 4 ] err_msg( "No piece there!" ) OTHERWISE possible_ := {} - FOR xx := 1 TO Len( t_board_[ move ][ 2 ] ) - IF t_board_[ t_board_[ move ][ 2, xx ] ][ 4 ] .AND. ; - ! t_board_[ t_board_[ move ][ 3, xx ] ][ 4 ] - AAdd( possible_, { t_board_[ move ][ 2, xx ], t_board_[ move ][ 3, xx ] } ) + FOR xx := 1 TO Len( board_[ move ][ 2 ] ) + IF board_[ board_[ move ][ 2, xx ] ][ 4 ] .AND. ; + ! board_[ board_[ move ][ 3, xx ] ][ 4 ] + AAdd( possible_, { board_[ move ][ 2, xx ], board_[ move ][ 3, xx ] } ) ENDIF NEXT // only one available move -- do it DO CASE CASE Len( possible_ ) == 1 // clear out original position and the position you jumped over - t_board_[ move ][ 4 ] := t_board_[ possible_[ 1, 1 ] ][ 4 ] := .F. - t_board_[ possible_[ 1, 2 ] ][ 4 ] := .T. - drawbox( move, t_board_[move] ) - drawbox( possible_[ 1, 1 ] ) - drawbox( possible_[ 1, 2 ] ) + board_[ move ][ 4 ] := board_[ possible_[ 1, 1 ] ][ 4 ] := .F. + board_[ possible_[ 1, 2 ] ][ 4 ] := .T. + drawbox( board_, move ) + drawbox( board_, possible_[ 1, 1 ] ) + drawbox( board_, possible_[ 1, 2 ] ) CASE Len( possible_ ) == 0 err_msg( "Illegal move!" ) OTHERWISE @@ -149,11 +147,11 @@ FUNCTION FT_PEGS() Set( _SET_SCOREBOARD, oldscore ) mpos := AScan( possible_, {| a | move2 == a[ 2 ] } ) // clear out original position and the position you jumped over - t_board_[ move ][ 4 ] := t_board_[ possible_[ mpos, 1 ] ][ 4 ] := .F. - t_board_[ move2 ][ 4 ] := .T. - drawbox( move ) - drawbox( possible_[ mpos, 1 ] ) - drawbox( move2 ) + board_[ move ][ 4 ] := board_[ possible_[ mpos, 1 ] ][ 4 ] := .F. + board_[ move2 ][ 4 ] := .T. + drawbox( board_, move ) + drawbox( board_, possible_[ mpos, 1 ] ) + drawbox( board_, move2 ) ENDCASE ENDCASE @@ -167,17 +165,17 @@ FUNCTION FT_PEGS() //--------------------------------------------------------------------* -STATIC FUNCTION DrawBox( nelement ) +STATIC FUNCTION DrawBox( board_, nelement ) - SetColor( iif( t_board_[ nelement ][ 4 ], "+w/rb", "w/n" ) ) + SetColor( iif( board_[ nelement ][ 4 ], "+w/rb", "w/n" ) ) - hb_DispBox( t_board_[ nelement ][ 1, 1 ], ; - t_board_[ nelement ][ 1, 2 ], ; - t_board_[ nelement ][ 1, 3 ], ; - t_board_[ nelement ][ 1, 4 ], hb_UTF8ToStrBox( "┌─┐│┘─└│ " ) ) + hb_DispBox( board_[ nelement ][ 1, 1 ], ; + board_[ nelement ][ 1, 2 ], ; + board_[ nelement ][ 1, 3 ], ; + board_[ nelement ][ 1, 4 ], hb_UTF8ToStrBox( "┌─┐│┘─└│ " ) ) - hb_DispOutAt( t_board_[ nelement ][ 1, 1 ] + 1, ; - t_board_[ nelement ][ 1, 2 ] + 2, hb_ntos( nelement ) ) + hb_DispOutAt( board_[ nelement ][ 1, 1 ] + 1, ; + board_[ nelement ][ 1, 2 ] + 2, hb_ntos( nelement ) ) RETURN NIL @@ -198,21 +196,21 @@ STATIC FUNCTION err_msg( msg ) //--------------------------------------------------------------------* -STATIC FUNCTION moremoves() +STATIC FUNCTION moremoves( board_ ) LOCAL xx, yy, canmove := .F. , piecesleft := 0, buffer FOR xx := 1 TO 33 - FOR yy := 1 TO Len( t_board_[ xx ][ 2 ] ) - IF t_board_[ xx ][ 4 ] .AND. ; // if current location is filled - t_board_[ t_board_[ xx ][ 2, yy ] ][ 4 ] .AND. ; // adjacent must be filled - ! t_board_[ t_board_[ xx ][ 3, yy ] ][ 4 ] // target must be empty + FOR yy := 1 TO Len( board_[ xx ][ 2 ] ) + IF board_[ xx ][ 4 ] .AND. ; // if current location is filled + board_[ board_[ xx ][ 2, yy ] ][ 4 ] .AND. ; // adjacent must be filled + ! board_[ board_[ xx ][ 3, yy ] ][ 4 ] // target must be empty canmove := .T. EXIT ENDIF NEXT // increment number of pieces left - IF t_board_[ xx ][ 4 ] + IF board_[ xx ][ 4 ] piecesleft++ ENDIF NEXT diff --git a/harbour/contrib/hbnf/savearr.prg b/harbour/contrib/hbnf/savearr.prg index 25918b5b57..b87ecf987b 100644 --- a/harbour/contrib/hbnf/savearr.prg +++ b/harbour/contrib/hbnf/savearr.prg @@ -30,8 +30,6 @@ * */ -MEMVAR lRet - FUNCTION FT_SAVEARR( aArray, cFileName, nErrorCode ) LOCAL nHandle, lRet @@ -54,9 +52,9 @@ FUNCTION FT_SAVEARR( aArray, cFileName, nErrorCode ) STATIC FUNCTION _ftsavesub( xMemVar, nHandle, nErrorCode ) LOCAL cValType, nLen, cString - PRIVATE lRet // accessed in code block - lRet := .T. + LOCAL lRet := .T. + cValType := ValType( xMemVar ) FWrite( nHandle, cValType, 1 ) IF FError() == 0 @@ -134,7 +132,7 @@ STATIC FUNCTION _ftrestsub( nHandle, nErrorCode ) CASE cValType == "D" cMemVar := Space( 8 ) FRead( nHandle, @cMemVar, 8 ) - xMemVar := CToD( cMemVar ) + xMemVar := CToD( cMemVar ) /* TOFIX: It's not Y2K compatible, and it needs same _SET_DATEFORMAT on save and load */ CASE cValType == "L" cMemVar := " " FRead( nHandle, @cMemVar, 1 ) diff --git a/harbour/contrib/hbnf/tests/calendar.prg b/harbour/contrib/hbnf/tests/calendar.prg index 441900aa23..f245cb4676 100644 --- a/harbour/contrib/hbnf/tests/calendar.prg +++ b/harbour/contrib/hbnf/tests/calendar.prg @@ -10,6 +10,9 @@ PROCEDURE Main() LOCAL aRet + SET DATE ANSI + SET CENTURY ON + SetColor( "w+/b" ) CLS IF ft_numlock() diff --git a/harbour/contrib/hbnf/tests/datecnfg.prg b/harbour/contrib/hbnf/tests/datecnfg.prg index ba0d0f422b..502065513c 100644 --- a/harbour/contrib/hbnf/tests/datecnfg.prg +++ b/harbour/contrib/hbnf/tests/datecnfg.prg @@ -53,6 +53,9 @@ PROCEDURE Main() LOCAL nNum, dDate, aTestData, aTemp, cFY_Start, nDOW_Start SET DATE ANSI // User's normal date format + SET CENTURY ON + hb_langSelect( "EN" ) + aTemp := FT_DATECNFG() // Get/Set cFY_Start & nDOW_Start. // aTemp := FT_DATECNFG( "1980.01.03", 1 ) // Date string in user's format. cFY_Start := aTemp[ 1 ] // See FT_DATECNFG() in ft_date0.prg diff --git a/harbour/contrib/hbnf/tests/menu1.prg b/harbour/contrib/hbnf/tests/menu1.prg index f776fb0f93..ab44d84776 100644 --- a/harbour/contrib/hbnf/tests/menu1.prg +++ b/harbour/contrib/hbnf/tests/menu1.prg @@ -24,6 +24,9 @@ PROCEDURE Main( cCmdLine ) LOCAL nMaxRow + SET DATE ANSI + SET CENTURY ON + AEval( aBar, {| x, i | HB_SYMBOL_UNUSED( x ), aOptions[ i ] := { {}, {}, {} } } ) cCmdLine := iif( cCmdLine == NIL, "", cCmdLine ) diff --git a/harbour/contrib/hbnf/tests/savearr.prg b/harbour/contrib/hbnf/tests/savearr.prg index 7b04703e54..a211b4096c 100644 --- a/harbour/contrib/hbnf/tests/savearr.prg +++ b/harbour/contrib/hbnf/tests/savearr.prg @@ -12,6 +12,9 @@ PROCEDURE Main() { "Invoice 3", Date() + 1, 0, .T. } }, aSave LOCAL nErrorCode := 0 + SET DATE ANSI + SET CENTURY OFF /* TOFIX: RTEs with ON */ + FT_SAVEARR( aArray, "invoice.dat", @nErrorCode ) IF nErrorCode == 0 CLS diff --git a/harbour/contrib/hbnf/tests/setdate.prg b/harbour/contrib/hbnf/tests/setdate.prg index 597c7d17b2..fb210f28f1 100644 --- a/harbour/contrib/hbnf/tests/setdate.prg +++ b/harbour/contrib/hbnf/tests/setdate.prg @@ -6,9 +6,12 @@ PROCEDURE Main( cDate ) - cDate := iif( cDate == NIL, DToC( Date() ), cDate ) + SET DATE ANSI + SET CENTURY ON + + cDate := iif( cDate == NIL, DToS( Date() ), cDate ) ? "Setting date to: " + cDate + "... " - FT_SETDATE( CToD( cDate ) ) + FT_SETDATE( SToD( cDate ) ) ? "Today is now: " + DToC( Date() ) RETURN diff --git a/harbour/contrib/hbnf/tests/tbwhile.prg b/harbour/contrib/hbnf/tests/tbwhile.prg index 5482a3b00f..b438f1c27e 100644 --- a/harbour/contrib/hbnf/tests/tbwhile.prg +++ b/harbour/contrib/hbnf/tests/tbwhile.prg @@ -19,8 +19,9 @@ PROCEDURE Main() LOCAL nFreeze := 1, lSaveScrn := .T. , nRecSel LOCAL cColorList := "N/W, N/BG, B/W, B/BG, B/W, B/BG, R/W, B/R" LOCAL cColorShad := "N/N" + LOCAL GetList := {} + FIELD last, first - MEMVAR GetList IF ! hb_FileExists( "tbnames.dbf" ) MAKE_DBF() diff --git a/harbour/contrib/hbnf/tests/wda.prg b/harbour/contrib/hbnf/tests/wda.prg index 6fd3f6dd96..192598d721 100644 --- a/harbour/contrib/hbnf/tests/wda.prg +++ b/harbour/contrib/hbnf/tests/wda.prg @@ -6,9 +6,9 @@ PROCEDURE Main( cDate, cDays ) - LOCAL nDays := ft_addWkDy( CToD( cDate ), Val( cDays ) ) + LOCAL nDays := ft_addWkDy( SToD( cDate ), Val( cDays ) ) ? "Num days to add: " + Str( nDays ) - ? "New date: " + DToC( CToD( cDate ) + nDays ) + ? "New date: " + DToC( SToD( cDate ) + nDays ) RETURN diff --git a/harbour/contrib/hbnf/tests/workdays.prg b/harbour/contrib/hbnf/tests/workdays.prg index bb4c3b983f..3a8179d8ee 100644 --- a/harbour/contrib/hbnf/tests/workdays.prg +++ b/harbour/contrib/hbnf/tests/workdays.prg @@ -6,6 +6,6 @@ PROCEDURE Main( cStart, cStop ) - ? ft_workdays( CToD( cStart ), CToD( cStop ) ) + ? ft_workdays( SToD( cStart ), SToD( cStop ) ) RETURN diff --git a/harbour/contrib/hbnf/tests/woy.prg b/harbour/contrib/hbnf/tests/woy.prg index 45a8af3cbc..943175520a 100644 --- a/harbour/contrib/hbnf/tests/woy.prg +++ b/harbour/contrib/hbnf/tests/woy.prg @@ -4,49 +4,32 @@ #require "hbnf" -// ADD PARAMETER "CENTURY" ON COMMAND LINES TO TEST 4-DIGIT YEARS +PROCEDURE Main() -PROCEDURE Main( cCent ) + LOCAL dDate + LOCAL GetList := {} - LOCAL lCentOn := .F. , cDate - MEMVAR getlist - - IF HB_ISSTRING( cCent ) .AND. "CENT" $ Upper( cCent ) - SET CENTURY ON - lCentOn := .T. - ENDIF + SET DATE ANSI + SET CENTURY ON DO WHILE .T. - CLEAR + @ 2, 10 SAY "Date to Test" - IF lCentOn - cDate := Space( 10 ) - @ 2, 24 GET cDate PICTURE "##/##/####" - ELSE - cDate := Space( 8 ) - @ 2, 24 GET cDate PICTURE "##/##/##" - ENDIF + dDate := SToD( "" ) + @ 2, 24 GET dDate READ - IF Empty( cDate ) + IF Empty( dDate ) EXIT ENDIF - IF Left( DToC( CToD( cDate ) ), 1 ) == " " - Tone( 800, 1 ) - @ 4, 24 SAY "INVALID DATE" - Inkey( 2 ) - LOOP - ENDIF - - @ 4, 10 SAY "Is Day Number " + Str( FT_DOY( CToD( cDate ) ), 3 ) - - @ 6, 10 SAY "Is in Week Number " + Str( FT_WOY( CToD( cDate ) ), 2 ) + @ 4, 10 SAY "Is Day Number " + Str( FT_DOY( dDate ), 10 ) + @ 6, 10 SAY "Is in Week Number " + Str( FT_WOY( dDate ), 10 ) @ 7, 0 + WAIT + ENDDO - CLEAR - RETURN diff --git a/harbour/contrib/hbnf/woy.prg b/harbour/contrib/hbnf/woy.prg index edcbb879c7..47517d161c 100644 --- a/harbour/contrib/hbnf/woy.prg +++ b/harbour/contrib/hbnf/woy.prg @@ -28,27 +28,19 @@ FUNCTION FT_WOY( dInDate ) LOCAL nFirstDays, nDayOffset, nWkNumber, cCentury - IF ! HB_ISDATE( dInDate ) - nWkNumber := NIL - ELSE + IF HB_ISDATE( dInDate ) - // resolve century issue - IF Len( DToC( dInDate ) ) > 8 // CENTURY is on - cCentury := SubStr( DToC( dInDate ), 7, 4 ) - ELSE - cCentury := SubStr( DToC( dInDate ), 7, 2 ) - ENDIF + cCentury := Left( DToS( dInDate ), 4 ) // find number of days in first week of year - nFirstDays := 8 - ( DOW( CToD( "01/01/" + cCentury ) ) ) + nFirstDays := 8 - DOW( SToD( cCentury + "0101" ) ) - nWkNumber := 1 + nWkNumber := 1 // find how many days after first week till dInDate - nDayOffset := ( dInDate - ; - CToD( "01/01/" + cCentury ) ) - nFirstDays + 1 + nDayOffset := ( dInDate - SToD( cCentury + "0101" ) ) - nFirstDays + 1 // count weeks in offset period @@ -57,28 +49,20 @@ FUNCTION FT_WOY( dInDate ) nDayOffset -= 7 ENDDO + ELSE + nWkNumber := NIL ENDIF RETURN nWkNumber FUNCTION FT_DOY( dInDate ) - LOCAL nDayNum, cCentury + LOCAL nDayNum - IF ! HB_ISDATE( dInDate ) - nDayNum := NIL + IF HB_ISDATE( dInDate ) + nDayNum := ( dInDate - SToD( Left( DToS( dInDate ), 4 ) + "0101" ) ) + 1 ELSE - - // resolve century issue - IF Len( DToC( dInDate ) ) > 8 // CENTURY is on - cCentury := SubStr( DToC( dInDate ), 7, 4 ) - ELSE - cCentury := SubStr( DToC( dInDate ), 7, 2 ) - ENDIF - - // calculate - nDayNum := ( dInDate - CToD( "01/01/" + cCentury ) ) + 1 - + nDayNum := NIL ENDIF RETURN nDayNum diff --git a/harbour/contrib/hbnf/year.prg b/harbour/contrib/hbnf/year.prg index 4035f8b8b5..642ca486eb 100644 --- a/harbour/contrib/hbnf/year.prg +++ b/harbour/contrib/hbnf/year.prg @@ -28,21 +28,19 @@ FUNCTION FT_YEAR( dGivenDate ) - LOCAL aRetVal[ 3 ], cFY_Start, cDateFormat + LOCAL aRetVal[ 3 ] - cFY_Start := FT_DATECNFG()[ 1 ] - cDateFormat := Set( _SET_DATEFORMAT, "yyyy.mm.dd" ) + LOCAL cFY_Start := FT_DATECNFG()[ 1 ] IF ! HB_ISDATE( dGivenDate ) dGivenDate := Date() ENDIF - aRetVal[ 2 ] := CToD( Str( Year( dGivenDate ) - iif( Month( dGivenDate ) < ; - Month( CToD( cFY_Start ) ), 1, 0 ), 4 ) + ; - SubStr( cFY_Start, 5, 6 ) ) + aRetVal[ 2 ] := SToD( ; + StrZero( Year( dGivenDate ) - iif( Month( dGivenDate ) < Month( hb_CToD( cFY_Start, "yyyy.mm.dd" ) ), 1, 0 ), 4 ) + ; + SubStr( cFY_Start, 6, 2 ) + ; + SubStr( cFY_Start, 9, 6 ) ) aRetval[ 3 ] := FT_MADD( aRetVal[ 2 ], 12 ) - 1 aRetVal[ 1 ] := Str( Year( aRetVal[ 3 ] ), 4 ) // End of Year - Set( _SET_DATEFORMAT, cDateFormat ) - RETURN aRetVal diff --git a/harbour/include/hbgtinfo.ch b/harbour/include/hbgtinfo.ch index b4e7b9b164..1f2498daf8 100644 --- a/harbour/include/hbgtinfo.ch +++ b/harbour/include/hbgtinfo.ch @@ -126,7 +126,7 @@ #define HB_GTI_CLOSABLE 50 /* toggles ability to close window (supported by: GTWVT) */ /* Additional constants to enhance GT */ -#define HB_GTI_NOTIFIERBLOCK 51 /* This optional codeblock gets called whenever certain events occur. See HB_GTE_* */ +#define HB_GTI_NOTIFIERBLOCK 51 /* Deprecated. Use HB_K_* inkey.ch events instead. */ #define HB_GTI_SCREENSIZE 52 /* Get/Set height/width of application window in pixels */ #define HB_GTI_PALETTE 53 /* Get/Set console colors 0 - 15 given an array of 16 elements containing RGB colors */ @@ -192,12 +192,14 @@ #define HB_GTI_KBD_LALT 0x100000 #define HB_GTI_KBD_RALT 0x200000 +#ifdef HB_LEGACY_LEVEL4 /* Harbour GT callback events - WORK IN PROGRESS */ #define HB_GTE_ACTIVATE 1 #define HB_GTE_SETFOCUS 2 #define HB_GTE_KILLFOCUS 3 #define HB_GTE_CLOSE 4 #define HB_GTE_RESIZED 5 +#endif /* Harbour GT Reszing mode constants */ #define HB_GTI_RESIZEMODE_FONT 0 /* Default */