2000-05-31 23:43 UTC+0100 Victor Szakats <info@szelvesz.hu>

This commit is contained in:
Viktor Szakats
2000-05-31 21:47:19 +00:00
parent b39d909ac4
commit cc8e3b98d6
20 changed files with 1364 additions and 27 deletions

View File

@@ -1,3 +1,33 @@
2000-05-31 23:43 UTC+0100 Victor Szakats <info@szelvesz.hu>
* contrib/hbclip/make_clp.bat
* Minor enh.
* source/lang/msgpt.c
! Updated by Felipe
+ contrib/sample/Makefile
+ GNU-Makefile for samples
by Jose Lalin:
+ contrib/sample/test*.prg
+ Tests added.
+ contrib/sample/date.c
+ Mdy, Dmy(), DateAsAge(), AddMonth()
+ DateAsArray(), ArrayAsDate(), DateIsLeap(), NToD()
+ contrib/sample/dbf.c
+ Dbf()
+ contrib/sample/environ.c
+ FilePath(), FileBase(), FileExt(), FileDrive()
+ contrib/sample/gauge.c
+ contrib/sample/stack.c
+ contrib/sample/status.c
+ contrib/sample/num.c
+ Ceiling(), DToR(), Floor()
+ NumAsLog10(), NumGetDecimals(), NumGetLen()
+ RToD(), Sign(), NumAsCurrency()
20000531-22:15 GMT+2 Maurilio Longo <maurilio.longo@libero.it>
* contrib/msql/tmsql.prg

View File

@@ -3,10 +3,10 @@ rem
rem $Id$
rem
clipper hbclip.prg /n
clipper hbkeyput.prg /n
clipper hbshadow.prg /n
clipper hbvaltoc.prg /n
clipper hbclip.prg /n /w
clipper hbkeyput.prg /n /w
clipper hbshadow.prg /n /w
clipper hbvaltoc.prg /n /w
cl /c /AL /Zl /Oalt /Gs /W3 hbarg.c
cl /c /AL /Zl /Oalt /Gs /W3 hbcolind.c

View File

@@ -0,0 +1,21 @@
#
# $Id$
#
ROOT = ../../
C_SOURCES=\
date.c \
dbf.c \
environ.c \
gauge.c \
num.c \
stack.c \
status.c \
time.c \
PRG_SOURCES=\
LIBNAME=samples
include $(TOP)$(ROOT)config/lib.cf

View File

@@ -0,0 +1,234 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Sample date functions rewritten in C
*
* Copyright 2000 Jose Lalin <dezac@corevia.com>
* 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 "hbapi.h"
#include "hbapiitm.h"
#include "hbset.h"
#include "hbdate.h"
/* MDY( <dDate> ) --> "month dd, yyyy"
*/
HB_FUNC( MDY )
{
long lYear, lMonth, lDay;
char * szFormat = "MM/DD/YYYY";
char szDate[ 9 ];
char szFormatted[ 11 ];
char * szReturn;
int iBufferLen;
int iLen;
hb_dateDecode( hb_parnl( 1 ), &lYear, &lMonth, &lDay );
hb_dateFormat( hb_pardsbuff( szDate, 1 ), szFormatted, szFormat );
iLen = strlen( hb_dateCMonth( lMonth ) );
iBufferLen = iLen + ( hb_set.hb_set_century ? 9 : 7 );
szReturn = hb_xgrab( iBufferLen );
memset( szReturn, ' ', iBufferLen + 1 );
memcpy( szReturn, hb_dateCMonth( lMonth ), iLen );
memcpy( szReturn + iLen + 1, szFormatted + 3, 2 );
szReturn[ iLen + 3 ] = ',';
memcpy( szReturn + iLen + 5, szFormatted + 6 + ( hb_set.hb_set_century ? 0 : 2 ), 2 + ( hb_set.hb_set_century ? 2 : 0 ) );
hb_retclen( szReturn, iBufferLen );
hb_xfree( szReturn );
}
/* DMY( <dDate> ) --> "dd month yyyy" (european date format)
*/
HB_FUNC( DMY )
{
long lYear, lMonth, lDay;
char * szFormat = "MM/DD/YYYY";
char szDate[ 9 ];
char szFormatted[ 11 ];
char * szReturn;
int iBufferLen;
int iLen;
hb_dateDecode( hb_parnl( 1 ), &lYear, &lMonth, &lDay );
hb_dateFormat( hb_pardsbuff( szDate, 1 ), szFormatted, szFormat );
iLen = strlen( hb_dateCMonth( lMonth ) );
iBufferLen = iLen + ( hb_set.hb_set_century ? 9 : 7 );
szReturn = hb_xgrab( iBufferLen );
memset( szReturn, ' ', iBufferLen );
memcpy( szReturn, szFormatted + 3, 2 );
memcpy( szReturn + 3, hb_dateCMonth( lMonth ), iLen );
memcpy( szReturn + iLen + 4, szFormatted + 6 + ( hb_set.hb_set_century ? 0 : 2 ), 2 + ( hb_set.hb_set_century ? 2 : 0 ) );
hb_retclen( szReturn, iBufferLen );
hb_xfree( szReturn );
}
/* DATEASAGE( <dDate> ) --> <nYears>
*/
HB_FUNC( DATEASAGE )
{
long lAge = 0;
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
if( pDate )
{
long lYear, lMonth, lDay;
long lThisYear, lThisMonth, lThisDay;
hb_dateToday( &lThisYear, &lThisMonth, &lThisDay );
hb_dateDecode( hb_itemGetDL( pDate ), &lYear, &lMonth, &lDay );
if( lThisYear > lYear )
{
lAge = lThisYear - lYear;
if( lThisMonth < lMonth || ( lThisMonth == lMonth && lThisDay < lDay ) )
--lAge;
}
}
hb_retnl( lAge );
}
/* ADDMONTH( <dDate>, <nMonths> ) --> <dNewDate>
NOTE: Caller must validate dNewDate.
*/
HB_FUNC( ADDMONTH )
{
long lMonths = hb_parnl( 2 );
long lYear, lMonth, lDay;
int iLimit, iMonthAdd, iYearAdd;
long lNew;
hb_dateDecode( hb_parnl( 1 ), &lYear, &lMonth, &lDay );
iLimit = 12 - lMonth + 1;
iYearAdd = lMonths / 12;
lMonths %= 12;
if( lMonths >= iLimit )
iYearAdd++;
lYear += iYearAdd;
iMonthAdd = lMonths % 12;
lMonth = ( lMonth + iMonthAdd ) % 12;
if( lMonth == 0 )
lMonth = 12;
lNew = hb_dateEncode( lYear, lMonth, lDay );
if( !lNew )
{
lMonth = ( lMonth + 1 ) % 12;
lDay = 1;
lYear = lYear + ( ( lMonth + 1 ) / 12 );
}
hb_retd( lYear, lMonth, lDay );
}
/* DATEASARRAY( <dDate> ) --> { Year, Month, Day }
NOTE: Returns an empty array if <dDate> is not a valid date.
*/
HB_FUNC( DATEASARRAY )
{
PHB_ITEM pReturn = hb_itemArrayNew( 3 ); /* Create array */
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
if( pDate )
{
PHB_ITEM pItem;
long lYear, lMonth, lDay;
hb_dateDecode( hb_itemGetDL( pDate ), &lYear, &lMonth, &lDay );
pItem = hb_itemPutNL( NULL, lYear );
hb_itemArrayPut( pReturn, 1, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutNL( NULL, lMonth );
hb_itemArrayPut( pReturn, 2, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutNL( NULL, lDay );
hb_itemArrayPut( pReturn, 3, pItem );
hb_itemRelease( pItem );
}
hb_itemReturn( pReturn );
hb_itemRelease( pReturn );
}
/* ARRAYASDATE( { <Year>, <Month>, <Day> } ) --> <dDate>
*/
HB_FUNC( ARRAYASDATE )
{
PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
if( pArray )
hb_retd( hb_arrayGetNL( pArray, 1 ), hb_arrayGetNL( pArray, 2 ), hb_arrayGetNL( pArray, 3 ) );
else
hb_retdl( 0 );
}
/* DATEISLEAP( <dDate> ) --> <lIsLeapYear>
*/
HB_FUNC( DATEISLEAP )
{
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
if( pDate )
{
long lYear, lMonth, lDay;
hb_dateDecode( hb_itemGetDL( pDate ), &lYear, &lMonth, &lDay );
hb_retl( ( lYear % 4 == 0 && lYear % 100 != 0 ) || ( lYear % 400 == 0 ) );
}
else
hb_retl( FALSE );
}
/* NTOD( <nMonth>, <nDay>, <nYear> ) --> <dDate>
*/
HB_FUNC( NTOD )
{
hb_retd( hb_parnl( 3 ), hb_parnl( 1 ), hb_parnl( 2 ) );
}

View File

@@ -0,0 +1,44 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* DBF() function (compatible with Summer'87)
*
* Copyright 2000 Jose Lalin <dezac@corevia.com>
* 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 "hbapi.h"
#include "hbapiitm.h"
extern HB_FUNC( ALIAS );
HB_FUNC( DBF )
{
HB_FUNCNAME( ALIAS );
}

View File

@@ -0,0 +1,95 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Sample file functions
*
* Copyright 2000 Jose Lalin <dezac@corevia.com>
* 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 "hbapi.h"
#include "hbapifs.h"
/* FilePath( <cFile> ) --> cFilePath
Extract the full path name from a complete file name
* FilePath( "c:\harbour\bin\harbour.exe" ) --> "c:\harbour\bin\"
*/
HB_FUNC( FILEPATH )
{
if( ISCHAR( 1 ) )
{
PHB_FNAME pFileName = hb_fsFNameSplit( hb_parc( 1 ) );
hb_retc( pFileName->szPath );
hb_xfree( pFileName );
}
else
hb_retc( "" );
}
/* FileBase( <cFile> ) --> cFileBase
*/
HB_FUNC( FILEBASE )
{
if( ISCHAR( 1 ) )
{
PHB_FNAME pFileName = hb_fsFNameSplit( hb_parc( 1 ) );
hb_retc( pFileName->szName );
hb_xfree( pFileName );
}
else
hb_retc( "" );
}
/* FileExt( <cFile> ) --> cFileExt
*/
HB_FUNC( FILEEXT )
{
if( ISCHAR( 1 ) )
{
PHB_FNAME pFileName = hb_fsFNameSplit( hb_parc( 1 ) );
hb_retc( ( pFileName->szExtension ) + 1 ); /* Skip the dot */
hb_xfree( pFileName );
}
else
hb_retc( "" );
}
/* FileDrive( <cFile> ) --> cFileDrive
*/
HB_FUNC( FILEDRIVE )
{
if( ISCHAR( 1 ) )
{
PHB_FNAME pFileName = hb_fsFNameSplit( hb_parc( 1 ) );
hb_retclen( pFileName->szDrive, 1 ); /* Only the drive letter */
hb_xfree( pFileName );
}
else
hb_retc( "" );
}

View File

@@ -0,0 +1,198 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Gauge functions
*
* Copyright 2000 Jose Lalin <dezac@corevia.com>
* 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 "hbapi.h"
#include "hbapiitm.h"
#include "hbapigt.h"
// Box array definitions
#define B_TOP 1
#define B_LEFT 2
#define B_BOTTOM 3
#define B_RIGHT 4
#define B_BACKCOLOR 5
#define B_BARCOLOR 6
#define B_DISPLAYNUM 7
#define B_BARCHAR 8
#define B_PERCENT 9
#define B_LEN B_PERCENT
#define B_BOXLINES "ÚÄ¿³ÙÄÀ³"
static void hb_gaugeUpdate( PHB_ITEM pArray, float fPercent );
/* GaugeNew( <nRowTop>, <nColumnTop>, <nRowBottom>, <nColumnBottom>,
[<cBackgroundColor>],
[<cGaugeColor>],
[<cGaugeCharacter>] ) --> aGauge
*/
HB_FUNC( GAUGENEW )
{
PHB_ITEM pReturn = hb_itemArrayNew( B_LEN ); /* Create array */
PHB_ITEM pItem;
pItem = hb_itemPutNL( NULL, ( ISNUM( B_TOP ) ? hb_parni( B_TOP ) : 0 ) );
hb_itemArrayPut( pReturn, B_TOP, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutNL( NULL, ( ISNUM( B_LEFT ) ? hb_parni( B_LEFT ) : 0 ) );
hb_itemArrayPut( pReturn, B_LEFT, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutNL( NULL,
( ISNUM( B_BOTTOM ) ?
( hb_parni( B_BOTTOM ) < hb_parni( B_TOP ) + 2 ?
hb_parni( B_TOP ) + 2 : hb_parni( B_BOTTOM ) ) : 0 ) );
hb_itemArrayPut( pReturn, B_BOTTOM, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutNL( NULL,
( ISNUM( B_RIGHT ) ?
( hb_parni( B_RIGHT ) < hb_parni( B_LEFT ) + 4 ?
hb_parni( B_LEFT ) + 4 : hb_parni( B_RIGHT ) ) : 0 ) );
hb_itemArrayPut( pReturn, B_RIGHT, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutC( NULL, ( ISCHAR( B_BACKCOLOR ) ? hb_parc( B_BACKCOLOR ) : "W/N" ) );
hb_itemArrayPut( pReturn, B_BACKCOLOR, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutC( NULL, ( ISCHAR( B_BARCOLOR ) ? hb_parc( B_BARCOLOR ) : "W+/N" ) );
hb_itemArrayPut( pReturn, B_BARCOLOR, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutL( NULL, !( ISNUM( B_RIGHT ) &&
ISNUM( B_LEFT ) &&
( hb_parni( B_RIGHT ) < hb_parni( B_LEFT ) + 9 ) ) );
hb_itemArrayPut( pReturn, B_DISPLAYNUM, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutC( NULL, ( ISCHAR( B_BARCHAR ) ? hb_parc( B_BARCHAR ) : ( char * ) '\xdb') );
hb_itemArrayPut( pReturn, B_BARCHAR, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutNL( NULL, 0 );
hb_itemArrayPut( pReturn, B_PERCENT, pItem );
hb_itemRelease( pItem );
hb_itemReturn( pReturn );
hb_itemRelease( pReturn );
}
/* GaugeDisplay( aGauge ) --> aGauge
*/
HB_FUNC( GAUGEDISPLAY )
{
PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
if( pArray )
{
int iCenter = ( ( hb_arrayGetNL( pArray, B_RIGHT ) - hb_arrayGetNL( pArray, B_LEFT ) ) / 2 ) + 1;
char szOldColor[ CLR_STRLEN ];
char * szStr = " ";
hb_gtGetColorStr( szOldColor );
hb_gtSetColorStr( hb_arrayGetCPtr( pArray, B_BACKCOLOR ) );
hb_gtBox( hb_arrayGetNL( pArray, B_TOP ), hb_arrayGetNL( pArray, B_LEFT ),
hb_arrayGetNL( pArray, B_BOTTOM ), hb_arrayGetNL( pArray, B_RIGHT ),
( BYTE * ) szStr );
hb_gtBox( hb_arrayGetNL( pArray, B_TOP ), hb_arrayGetNL( pArray, B_LEFT ),
hb_arrayGetNL( pArray, B_BOTTOM ), hb_arrayGetNL( pArray, B_RIGHT ),
B_BOXLINES );
if( hb_arrayGetL( pArray, B_DISPLAYNUM ) )
hb_gtWriteAt( hb_arrayGetNL( pArray, B_TOP ), iCenter, ( BYTE * ) "[ ]", 8 );
hb_gtSetColorStr( szOldColor );
hb_gaugeUpdate( pArray, hb_arrayGetNL( pArray, B_PERCENT ) );
hb_itemReturn( pArray );
}
}
/* GaugeUpdate( aGauge, nPercent ) --> aGauge
*/
HB_FUNC( GAUGEUPDATE )
{
PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
if( pArray )
{
hb_gaugeUpdate( pArray, ISNUM( 2 ) ? hb_parnd( 2 ) : 0 );
hb_itemReturn( pArray );
}
}
static void hb_gaugeUpdate( PHB_ITEM pArray, float fPercent )
{
int iCenter = ( ( hb_arrayGetNL( pArray, B_RIGHT ) - hb_arrayGetNL( pArray, B_LEFT ) ) / 2 ) + 1;
int iRatio = hb_arrayGetNL( pArray, B_RIGHT ) - hb_arrayGetNL( pArray, B_LEFT ) - 1;
int iRow;
int iCols;
int iMax;
char szOldColor[ CLR_STRLEN ];
char * szStr = " ";
char szPct[ 4 ];
hb_gtGetColorStr( szOldColor );
hb_gtSetColorStr( hb_arrayGetCPtr( pArray, B_BARCOLOR ) );
fPercent = ( fPercent < 0 ? 0 : ( fPercent > 1 ? 1 : fPercent ) );
iCols = fPercent * iRatio;
if( hb_arrayGetL( pArray, B_DISPLAYNUM ) )
{
sprintf( szPct, "%3.0f\%", fPercent * 100 );
hb_gtWriteAt( hb_arrayGetNL( pArray, B_TOP ), iCenter + 2, szPct, 4 );
}
hb_gtBox( hb_arrayGetNL( pArray, B_TOP ) + 1, hb_arrayGetNL( pArray, B_LEFT ) + 1,
hb_arrayGetNL( pArray, B_BOTTOM ) - 1, hb_arrayGetNL( pArray, B_RIGHT ) - 1,
( BYTE * ) szStr );
iMax = hb_arrayGetNL( pArray, B_BOTTOM ) - hb_arrayGetNL( pArray, B_TOP ) - 1;
for( iRow = 1; iRow <= iMax; iRow++ )
{
hb_gtRepChar( iRow + hb_arrayGetNL( pArray, B_TOP ),
hb_arrayGetNL( pArray, B_LEFT ) + 1,
( BYTE ) * hb_arrayGetCPtr( pArray, B_BARCHAR ), iCols );
}
hb_gtSetColorStr( szOldColor );
}

View File

@@ -0,0 +1,191 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Number manipulation
*
* Copyright 2000 Jose Lalin <dezac@corevia.com>
* 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 <math.h>
#include "hbapi.h"
#include "hbapiitm.h"
#define PI ( 3.1415926535897932384626433 )
/* Ceiling( <nNumber> ) --> nInteger
Return the smallest integer that is greater than or equal to <nNumber>
*/
HB_FUNC( CEILING )
{
hb_retnl( ceil( hb_parnd( 1 ) ) );
}
/* DtoR( <nDegrees> ) --> nRadians
Convert an angle size specified in radians to degrees
*/
HB_FUNC( DTOR )
{
hb_retndlen( ( hb_parnd( 1 ) / 180 ) * PI, 10, 9 );
}
/* Floor( <nNumber> ) --> nInteger
Return the largest integer that is less than or equal to <nNumber>
*/
HB_FUNC( FLOOR )
{
hb_retnl( floor( hb_parnd( 1 ) ) );
}
/* NumAsLog10( <nNumber> ) --> nLog10
Convert a positive number to log base 10
*/
HB_FUNC( NUMASLOG10 )
{
if( ISNUM( 1 ) )
{
hb_retnd( log10( hb_parnd(1) ) );
}
}
/* NumGetDecimals( <nNumber> ) --> nDecimals
Determine the number of decimal digits
*/
HB_FUNC( NUMGETDECIMALS )
{
int iDec = 0;
if( ISNUM( 1 ) )
{
hb_itemGetNLen( hb_param( 1, HB_IT_NUMERIC ), NULL, &iDec );
}
hb_retnl( iDec );
}
/* NumGetLen( <nNumber> ) --> nDigits
Determine the number of whole number digits
*/
HB_FUNC( NUMGETLEN )
{
ULONG ulLen = 0;
if( ISNUM( 1 ) )
{
char * szBuffer = hb_itemStr( hb_param( 1, HB_IT_NUMERIC ), NULL, NULL );
char * ptr = szBuffer;
while( HB_ISSPACE( *ptr ) )
ptr++;
if( !strchr( ptr, '.' ) )
{
while( *ptr )
{
ptr++;
ulLen++;
}
}
else
{
while( *ptr != '.' )
{
ptr++;
ulLen++;
}
}
if( szBuffer )
hb_xfree( szBuffer );
}
hb_retnl( ulLen );
}
/* RtoD( <nRadians> ) --> nDegrees
Convert an angle size specified in radians to degrees
*/
HB_FUNC( RTOD )
{
hb_retnd( 180 * ( hb_parnd( 1 ) / PI ) );
}
/* Sign( <nNumber> ) --> nSign
Return the sign of a number as follows:
0 - <nNumber> is zero
1 - <nNumber> is positive
-1 - <nNumber> is negative
*/
HB_FUNC( SIGN )
{
if( ISNUM( 1 ) )
{
long lNumber = hb_parnl( 1 );
hb_retni( lNumber == 0 ? 0 : ( lNumber > 0 ? 1 : -1 ) );
}
}
/* NumAsCurrency( <nNumber>, <cSymbol>, <nSide> ) --> cCurrency
Convert number to currency format, floating dollar symbol
*/
HB_FUNC( NUMASCURRENCY )
{
char * szBuffer = hb_itemStr( hb_param( 1, HB_IT_NUMERIC ), NULL, NULL );
long ulSymbolLen = hb_itemGetCLen( hb_param( 2, HB_IT_STRING ) );
char * ptr = szBuffer;
char * szCurrency;
ULONG ulLen;
ulLen = strlen( ptr );
szCurrency = ( char * ) hb_xgrab( ulLen + ulSymbolLen ) ;
if( hb_parni( 3 ) < 0 )
{
while( HB_ISSPACE( *ptr ) )
ptr++;
ulLen = strlen( ptr );
memcpy( szCurrency, hb_parc( 2 ), ulSymbolLen );
memcpy( szCurrency + ulSymbolLen, ptr, ulLen );
}
else
{
memcpy( szCurrency, ptr, ulLen );
memcpy( szCurrency + ulLen, hb_parc( 2 ), ulSymbolLen );
}
if( szBuffer )
hb_xfree( szBuffer );
hb_retclen( szCurrency, ulLen + ulSymbolLen );
hb_xfree( szCurrency );
}

View File

@@ -0,0 +1,101 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Stack structure
*
* Copyright 2000 Jose Lalin <dezac@corevia.com>
* 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 "hbapi.h"
#include "hbapiitm.h"
/* StackNew() --> <aStack>
*/
HB_FUNC( STACKNEW )
{
PHB_ITEM pReturn = hb_itemArrayNew( 0 ); /* Create array */
hb_itemReturn( pReturn );
hb_itemRelease( pReturn );
}
/* StackPush( <aStack>, <xValue> ) --> <aStack>
*/
HB_FUNC( STACKPUSH )
{
PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
PHB_ITEM pAny = hb_param( 2, HB_IT_ANY );
hb_arrayAdd( pArray, pAny );
}
/* StackPop( <aStack> ) --> <xValue>
Returns NIL if the stack is empty
*/
HB_FUNC( STACKPOP )
{
PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
long ulLen = hb_arrayLen( pArray );
PHB_ITEM pLast = hb_itemNew( NULL );
if( ulLen )
{
hb_arrayLast( pArray, pLast );
hb_arrayDel( pArray, ulLen );
--ulLen;
hb_arraySize( pArray, HB_MAX( ulLen, 0 ) );
}
hb_itemReturn( pLast );
hb_itemRelease( pLast );
}
/* StackIsEmpty( <aStack> ) --> <lEmpty>
*/
HB_FUNC( STACKISEMPTY )
{
PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
hb_retl( hb_arrayLen( pArray ) == 0 );
}
/* StackTop( <aStack> ) --> <xValue>
Returns the top item
*/
HB_FUNC( STACKTOP )
{
PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
PHB_ITEM pLast = hb_itemNew( NULL );
hb_arrayLast( pArray, pLast );
hb_itemReturn( pLast );
hb_itemRelease( pLast );
}

View File

@@ -0,0 +1,101 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Moving indicator for large processes
*
* Copyright 2000 Jose Lalin <dezac@corevia.com>
* 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 <ctype.h>
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbapigt.h"
#define ST_ROW 1 // Status item display row
#define ST_COL 2 // Status item display column
#define ST_COLOR 3 // Status item color
#define ST_CURRENT 4 // Status item current position in aDisplay
#define ST_LEN ST_CURRENT // Length of status array
/* StatusNew( [<nRow>], [<nCol>], [<cColor>] ) --> <aStat>
*/
HB_FUNC( STATUSNEW )
{
PHB_ITEM pReturn = hb_itemArrayNew( ST_LEN ); /* Create array */
PHB_ITEM pItem;
pItem = hb_itemPutNL( NULL, ( ISNUM( ST_ROW ) ? hb_parni( ST_ROW ) : 0 ) );
hb_itemArrayPut( pReturn, ST_ROW, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutNL( NULL, ( ISNUM( ST_COL ) ? hb_parni( ST_COL ) : 0 ) );
hb_itemArrayPut( pReturn, ST_COL, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutC( NULL, ( ISCHAR( ST_COLOR ) ? hb_parc( ST_COLOR ) : "W+/N" ) );
hb_itemArrayPut( pReturn, ST_COLOR, pItem );
hb_itemRelease( pItem );
pItem = hb_itemPutNL( NULL, 1 );
hb_itemArrayPut( pReturn, ST_CURRENT, pItem );
hb_itemRelease( pItem );
hb_itemReturn( pReturn );
hb_itemRelease( pReturn );
}
/* StatusUpdate( <aStat> ) --> nil
*/
HB_FUNC( STATUSUPDATE )
{
PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
if( pArray )
{
char * szDisplay = "|/-\\";
long lCurrent = hb_arrayGetNL( pArray, ST_CURRENT );
char * szOldColor[ CLR_STRLEN ];
PHB_ITEM pCurrent = hb_itemNew( NULL );
lCurrent = ( ++lCurrent > 4 ? 1 : lCurrent );
hb_itemArrayPut( pArray, ST_CURRENT, hb_itemPutNL( pCurrent, lCurrent ) );
hb_gtGetColorStr( szOldColor );
hb_gtSetColorStr( hb_arrayGetCPtr( pArray, ST_COLOR ) );
hb_gtWriteAt( hb_arrayGetNL( pArray, ST_ROW ), hb_arrayGetNL( pArray, ST_COL ),
( BYTE * ) szDisplay + lCurrent - 1, 1 );
hb_gtSetColorStr( szOldColor );
hb_itemRelease( pCurrent );
}
}

View File

@@ -0,0 +1,37 @@
/*
* $Id$
*/
function Test()
local dDate
local aDate
SET DATE FORMAT "dd/mm/yyyy"
dDate := CTOD( "19/07/71" )
SET CENTURY OFF
? "[" + MDY( dDate ) + "]"
? "[" + DMY( dDate ) + "]"
? DateAsAge( dDate )
aDate := DateAsArray( dDate )
? aDate[1], aDate[2], aDate[3]
? ArrayAsDate( aDate )
? DateIsLeap( dDate )
? NtoD( aDate[2], aDate[3], aDate[1] )
? AddMonth( dDate, 12 )
? AddMonth( dDate, 18 )
SET CENTURY ON
? "[" + MDY( dDate ) + "]"
? "[" + DMY( dDate ) + "]"
? DateAsAge( dDate )
aDate := DateAsArray( dDate )
? aDate[1], aDate[2], aDate[3]
? ArrayAsDate( aDate )
? DateIsLeap( dDate )
? NtoD( aDate[2], aDate[3], aDate[1] )
? AddMonth( dDate, 12 )
? AddMonth( dDate, 18 )
return nil

View File

@@ -0,0 +1,18 @@
/*
* $Id$
*/
#include "common.ch"
function Test( cParam )
LOCAL cFile := "c:\harbour\bin\harbour.exe"
DEFAULT cParam TO cFile
? FilePath( cParam )
? FileBase( cParam )
? FileExt( cParam )
? FileDrive( cParam )
return nil

View File

@@ -0,0 +1,54 @@
/*
* $Id$
*/
/* Testing Harbour's Gauge */
#include "Inkey.ch"
#include "SetCurs.ch"
function Test()
LOCAL aGauge
LOCAL i := 0
LOCAL nPercent := 0
CLS
SetCursor( SC_NONE )
aGauge := GaugeNew( 5, 5, 7, MaxCol() - 5, "W/B", "W+/B" )
@ 1, 0 SAY PadC( "Harbour Gauge Demo", MaxCol() ) COLOR "W+/N"
@ 3, 0 SAY PadC( "Use , , PgUp and PgDn to move gauge, Esc to exit", MaxCol() ) COLOR "W/N"
GaugeDisplay( aGauge )
while i <> K_ESC
i := Inkey( 0 )
do case
case i == K_UP
nPercent += .01
case i == K_DOWN
nPercent -= .01
case i == K_PGUP
nPercent += .1
case i == K_PGDN
nPercent -= .1
end case
if nPercent < 0
Tone( 300, 1 )
nPercent := 0
endif
if nPercent > 1
Tone( 300, 1 )
nPercent := 1
endif
GaugeUpdate( aGauge, nPercent )
end do
SetCursor( SC_NORMAL )
return nil

View File

@@ -0,0 +1,24 @@
/*
* $Id$
*/
function Test()
? Ceiling( 3.2 )
? DToR( 180 )
? Floor( 3.2 )
? NumAsCurrency( 3000, "$", -1 )
? NumAsCurrency( 3000, "$", 1 )
? NumAsCurrency( 3000, "Euro", -1 )
? NumAsCurrency( 3000, "Euro", 1 )
? NumAsLog10( 1 )
? NumGetDecimals( 1 )
? NumGetDecimals( 1.2345 )
? NumGetLen( 1 )
? NumGetLen( 1.2345 )
? RToD( 180 )
? Sign( 0 )
? Sign( 33 )
? Sign( -33 )
return nil

View File

@@ -0,0 +1,16 @@
/*
* $Id$
*/
function test()
local aStat := StatusNew( 10, 5, "R/N" )
local i
CLS
for i := 1 to 40
StatusUpdate( aStat )
Inkey( .1 )
next
return nil

View File

@@ -0,0 +1,25 @@
/*
* $Id$
*/
function Test()
? Days( 145604 )
? SecondsAsDays( 145604 )
? AMPM( "01:02:03" )
? TIMEASAMPM( "01:02:03" )
? SECS( "01:02:03" )
? TIMEASSECONDS( "01:02:03" )
? TSTRING( 2000 )
? TIMEASSTRING( 2000 )
? ELAPTIME( "01:02:03", "01:12:03" )
? TIMEDIFF( "01:02:03", "01:12:03" )
? TIMEISVALID( "01:02:03" )
? TIMEISVALID( "25:02:03" )
return nil

View File

@@ -0,0 +1,100 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Time functions
*
* Copyright 2000 Jose Lalin <dezac@corevia.com>
* 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 <ctype.h>
#include "hbapi.h"
#include "hbapiitm.h"
extern HB_FUNC( DAYS );
extern HB_FUNC( AMPM );
extern HB_FUNC( SECS );
extern HB_FUNC( TSTRING );
extern HB_FUNC( ELAPTIME );
/* SECONDSASDAYS( <nSeconds> ) --> <nDays>
*/
HB_FUNC( SECONDSASDAYS )
{
HB_FUNCNAME( DAYS )();
}
/* TIMEASAMPM( <cTime> ) --> <cTime> + " am" / " pm"
*/
HB_FUNC( TIMEASAMPM )
{
HB_FUNCNAME( AMPM )();
}
/* TIMEASSECONDS( <cTime> ) --> <nSecondsFromMidnight>
*/
HB_FUNC( TIMEASSECONDS )
{
HB_FUNCNAME( SECS )();
}
/* TIMEASSTRING( <nSeconds> ) --> <cTime>
*/
HB_FUNC( TIMEASSTRING )
{
HB_FUNCNAME( TSTRING )();
}
/* TIMEDIFF( <cStartTime>, <cEndTime> ) --> <cDiffTime>
*/
HB_FUNC( TIMEDIFF )
{
HB_FUNCNAME( ELAPTIME )();
}
/* TIMEISVALID( <cTime> ) --> <lValid>
*/
HB_FUNC( TIMEISVALID )
{
char * pszTime = hb_parc( 1 );
BOOL bRet = FALSE;
if( pszTime )
{
if( atol( pszTime ) < 24 &&
atol( pszTime + 3 ) < 60 &&
atol( pszTime + 6 ) < 60 )
{
bRet = TRUE;
}
}
hb_retl( bRet );
}

View File

@@ -0,0 +1,10 @@
/*
* $Id$
*/
#translate Days( <nSeconds> ) => SecondsAsDays( <nSeconds> )
#translate AmPm( <cTime> ) => TimeAsAMPM( <cTime> )
#translate Secs( <cTime> ) => TimeAsSeconds( <cTime> )
#translate TString( <nSeconds> ) => TimeAsString( <nSeconds> )
#translate Elaptime( <cStartTime>, <cEndTime> ) => TimeDiff( <cStartTime>, <cEndTime> )
#translate ValidTime( <cTime> ) => TimeIsValid( <cTime> )

View File

@@ -0,0 +1,26 @@
/*
* $Id$
*/
function Test()
LOCAL a := StackNew()
? Valtype( a )
? Len( a ) // 0
StackPush( a, "POWER" )
? Len( a ) // 1
StackPush( a, "HARBOUR" )
? Len( a ) // 2
? StackPop( a ) // HARBOUR
? Len( a ) // 1
? StackPop( a ) // POWER
? Len( a ) // 0
? StackPop( a ) // NIL
? Len( a ) // 0
? StackIsEmpty( a ) // TRUE
StackPush( a, "HARBOUR" )
? StackTop( a ) // HARBOUR
? StackIsEmpty( a ) // FALSE
return nil

View File

@@ -33,6 +33,18 @@
*
*/
/*
* The following parts are Copyright of the individual authors.
* www - http://www.harbour-project.org
*
* Copyright 2000 Felipe Coury <fcoury@creation.com.br>
* Small fixes
* Internal error names
*
* See doc/license.txt for licensing terms.
*
*/
/* Language name: Portuguese */
/* ISO language code (2 chars): PT */
/* Codepage: 850 */
@@ -86,8 +98,8 @@ static HB_LANG s_lang =
"*** Total ***",
"Ins",
" ",
"Data invalida",
"Range: ",
"Data inv lida",
"Faixa: ",
" - ",
"S/N",
"EXPRESSÇO INVALIDA",
@@ -148,28 +160,28 @@ static HB_LANG s_lang =
/* Internal error names */
"Unrecoverable error %lu: ",
"Error recovery failure",
"No ERRORBLOCK() for error",
"Too many recursive error handler calls",
"RDD invalid or failed to load",
"Invalid method type from %s",
"hb_xgrab can't allocate memory",
"hb_xrealloc called with a NULL pointer",
"hb_xrealloc called with an invalid pointer",
"hb_xrealloc can't reallocate memory",
"hb_xfree called with an invalid pointer",
"hb_xfree called with a NULL pointer",
"Can\'t locate the starting procedure: \'%s\'",
"No starting procedure",
"Unsupported VM opcode",
"Symbol item expected from %s",
"Invalid symbol type for self from %s",
"Codeblock expected from %s",
"Incorrect item type on the stack trying to pop from %s",
"Erro irrecuper vel %lu: ",
"Erro na recupera‡ao do erro",
"ERRORBLOCK() para erro ausente",
"Muitas chamadas recursivas ao manipulador de erros",
"Falha ao carregar ou RDD inv lido",
"Mtodo de %s inv lido",
"hb_xgrab nao pode alocar mem¢ria",
"hb_xrealloc chamado com ponteiro NULL",
"hb_xrealloc chamado com ponteiro inv lido",
"hb_xrealloc nao pode realocar mem¢ria",
"hb_xfree chamado com ponteiro inv lido",
"hb_xfree chamado com ponteiro NULL",
"Impossivel localizar procedure de in¡cializa‡ao: \'%s\'",
"Nao ha procedure de inicializa‡ao",
"VM opcode nao suportado",
"Item de s¡mbolo esperado de %s",
"Tipo de s¡mbolo inv lido para self em %s",
"Codeblock esperado em %s",
"Tipo incorreto de item na pilha tentando executar um pop de %s",
"Stack underflow",
"An item was going to be copied to itself from %s",
"Invalid symbol item passed as memvar %s",
"Um item iria ser copiado para ele mesmo em %s",
"Symbol item inv lido passado como memvar %s",
/* Texts */