19990823-01:11 GMT+1

This commit is contained in:
Viktor Szakats
1999-08-22 23:33:48 +00:00
parent d42d38bafe
commit ec4db6ced1
14 changed files with 101 additions and 659 deletions

View File

@@ -1,3 +1,34 @@
19990823-01:11 GMT+1 Victor Szel <info@szelvesz.hu>
* source/rtl/alert.prg
! PreExt/PostExt code moved inside Alert(), then the STATIC variable
could be removed, so that it will work even in nested calls.
* source/compiler/harbour.y
! Extern "DEBUGGER" changed to "__DBGENTRY"
* config/win32/gcc.cf
tests/working/Makefile
source/runner/stdalone/Makefile
! Removed the -( -) parameter, RDD lib added a second time after
the VM lib to resolve circular dependency. (Thanks to Paul Tucker)
* include/extend.h
include/hbdefs.h
* Standard #include files included from hbdefs.h instead of extend.h
* source/compiler/genobj32.c
! Some types changed to BOOL
% Some #includes removed.
* source/runner/runner.c
- Removed (runlib.c is the new name)
* runner.b32
+ Added (missed from the previous CVS session)
* source/vm/hvm.c
% Removed some unneeded HARBOUR prototypes.
% Removed #include "init.h"
* source/rtl/strings.c
+ Put #include "init.h" between guards
* tests/working/transfrm.prg
tests/working/Makefile
- Removed since all its content has been moved to rtl_test.prg
previously.
19990822-16:20 EDT Paul Tucker <ptucker@sympatico.ca>
* source/rtl/alert.prg
+ PreExt() and PostExt()

View File

@@ -28,7 +28,7 @@ endif
# The -( option could be appropriate to link against libraries with
# cyclic dependencies, but I think it is not really necessary if the
# libraries are kept in proper order.
LINKLIBS += -Wl,-(
# LINKLIBS += -Wl,-(
LINKLIBS += $(foreach lib, $(LIBS), -l$(lib))
@@ -44,7 +44,7 @@ endif
# The -) option could be appropriate to link against libraries with
# cyclic dependencies, but I think it is not really necessary if the
# libraries are kept in proper order.
LINKLIBS += -Wl,-)
# LINKLIBS += -Wl,-)
LDFLAGS = $(LINKPATHS)

View File

@@ -27,11 +27,6 @@
#ifndef HB_EXTEND_H_
#define HB_EXTEND_H_
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hbsetup.h"
#include "hbdefs.h"
#include "hb_vmpub.h"

View File

@@ -5,6 +5,10 @@
#ifndef HB_DEFS_H_
#define HB_DEFS_H_
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#if defined(__IBMCPP__)

37
harbour/runner.b32 Normal file
View File

@@ -0,0 +1,37 @@
# makefile for Borland C/C++ 32 bits
.path.c = source\runner
.path.h = include
.path.exe = bin
.path.lib = libs\b32
.path.obj = obj;source\runner;source\runner\stdalone
.path.prg = source\runner\stdalone
PROJECT: runner.exe runner.lib
runlib.obj : runlib.c
runner.c : runner.prg
external.c : external.prg
.prg.c:
bin\harbour $< /n /osource\runner /iinclude /p
.c.obj:
bcc32 -c -O2 -I.\include -v -o$@ -DHARBOUR_USE_GTAPI $<
tlib .\libs\b32\runner.lib -+$@,,
runner.exe : runner.c external.c runlib.c
echo -v -O2 > bld.32
echo -ebin\runner.exe >> bld.32
echo -Iinclude >> bld.32
echo source\runner\stdalone\runner.c >> bld.32
echo source\runner\stdalone\external.c >> bld.32
echo libs\b32\harbour.lib >> bld.32
echo libs\b32\terminal.lib >> bld.32
echo libs\b32\hbgt.lib >> bld.32
echo libs\b32\hbpp.lib >> bld.32
echo libs\b32\rdd.lib >> bld.32
echo libs\b32\runner.lib >> bld.32
bcc32 @bld.32
del bld.32

View File

@@ -25,11 +25,8 @@
*
*/
#include <stdio.h>
#include <string.h>
#include "hbdefs.h"
#include "compiler.h"
#include "extend.h"
#include "compiler.h"
#include "pcode.h"
static void CompiledFileName( FILE * hObjFile, char * szFileName );
@@ -56,7 +53,8 @@ static void GenerateSymbolsSegment( FILE * hObjFile );
extern FUNCTIONS functions, funcalls;
extern SYMBOLS symbols;
extern int _bQuiet, _bStartProc;
extern BOOL _bQuiet;
extern BOOL _bStartProc;
static BYTE prgFunction[] = { 0x68, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00,
0x00, 0xE8, 0x00, 0x00, 0x00, 0x00, 0x83, 0xC4, 0x08, 0xC3 };

View File

@@ -3176,7 +3176,7 @@ void GenExterns( void ) /* generates the symbols for the EXTERN names */
PEXTERN pDelete;
if( _bDebugInfo )
AddExtern( yy_strdup( "DEBUGGER" ) );
AddExtern( yy_strdup( "__DBGENTRY" ) );
while( pExterns )
{

View File

@@ -13,8 +13,6 @@
#include "box.ch"
#include "inkey.ch"
Static snDcount
// ; TOFIX: Clipper defines a clipped window for Alert()
// ; Clipper will return NIL if the first parameter is not a string, but
// this is not documented. This implementation converts the first parameter
@@ -36,6 +34,9 @@ FUNCTION Alert(xMessage, aOptions, cColorNorm, nDelay)
LOCAL nOldCursor
LOCAL cOldScreen
LOCAL nOldDispCount
LOCAL nCount
/* TOFIX: Clipper decides at runtime, whether the GT is linked in, */
/* if it is not, the console mode is choosed here */
LOCAL lConsole := .F.
@@ -148,8 +149,6 @@ FUNCTION Alert(xMessage, aOptions, cColorNorm, nDelay)
nCurrent := nInitCol + Int((nWidth - nOpWidth) / 2) + 2
AEval(aOptionsOK, { |x| AAdd(aPos, nCurrent), AAdd(aHotKey, Upper(Left(x, 1))), nCurrent += Len(x) + 4 })
PreExt()
IF lConsole
FOR iEval := 1 TO Len(aSay)
@@ -170,6 +169,13 @@ FUNCTION Alert(xMessage, aOptions, cColorNorm, nDelay)
ELSE
/* PreExt */
nCount := nOldDispCount := DispCount()
DO WHILE nCount-- != 0
DispEnd()
ENDDO
/* save status */
nOldRow := Row()
nOldCol := Col()
@@ -245,22 +251,11 @@ FUNCTION Alert(xMessage, aOptions, cColorNorm, nDelay)
SetCursor(nOldCursor)
SetPos(nOldRow, nOldCol)
/* PostExt */
DO WHILE nOldDispCount-- != 0
DispBegin()
ENDDO
ENDIF
PostExt()
RETURN nChoice
Proc PreExt
Local nCount := snDCount := DispCount()
while ncount-- != 0
DispEnd()
Enddo
Proc PostExt
Local nCount
While snDcount-- != 0
DispBegin()
Enddo

View File

@@ -39,26 +39,25 @@
#include "itemapi.h"
#include "errorapi.h"
#include "set.h"
#include "init.h"
#ifdef HARBOUR_STRICT_CLIPPER_COMPATIBILITY
static double infinity = 0;
#endif
#define HB_ISSPACE(c) ((c) == 9 || (c) == 10 || (c) == 13 || (c) == 32)
/* DJGPP can sprintf a float that is almost 320 digits long */
#define HB_MAX_DOUBLE_LENGTH 320
/* The rest of functions is pulled automatically by initsymb.c */
#ifdef HARBOUR_STRICT_CLIPPER_COMPATIBILITY
#include "init.h"
static double infinity = 0;
HB_CALL_ON_STARTUP_BEGIN( Strings_InitInfinity )
infinity = -log( 0 );
HB_CALL_ON_STARTUP_END( Strings_InitInfinity )
#if ! defined(__GNUC__)
#pragma startup Strings_InitInfinity
#endif
#endif
BOOL hb_strEmpty( char * szText, ULONG ulLen )

View File

@@ -1,473 +0,0 @@
/*
* $Id$
*/
/*
* Runner.c contains the .HRB object system
*
* Copyright(C) 1999 by Eddie Runia <eddie@runia.com>
*
* 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.
*
* 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.
*/
#include "extend.h"
#include "pcode.h"
#include "errorapi.h"
#include "ctoharb.h"
#include "init.h"
#include "initsymd.h"
/* #if INTEL32 */
static BYTE prgFunction[] = { 0x68, 0x00, 0x00, 0x00, 0x00,
0x68, 0x00, 0x00, 0x00, 0x00,
0xE8, 0x00, 0x00, 0x00, 0x00,
0x83, 0xC4, 0x08,
0xC3 };
/* push offset pcode
push offset symbols
call near relative hb_vmExecute
add esp, 8
ret near */
/* This is the assembler output from : hb_vmExecute(pcode,symbols). */
/* #elseif INTEL16 */
/* #elseif MOTOROLA */
/* #elseif ... */
/* #endif */
typedef union
{
BYTE * pAsmData; /* The assembler bytes */
PHB_FUNC pFunPtr; /* The (dynamic) harbour
function */
} ASM_CALL, *PASM_CALL;
typedef struct
{
char *szName; /* Name of the function */
PASM_CALL pAsmCall; /* Assembler call */
BYTE * pCode; /* P-code */
} DYNFUNC, *PDYNFUNC;
#define SYM_NOLINK 0 /* Symbol does not have to
be linked */
#define SYM_FUNC 1 /* Defined function */
#define SYM_EXTERN 2 /* Prev. defined function */
#define SYM_NOT_FOUND 0xFFFFFFFF /* Symbol not found.
FindSymbol */
#ifndef HARBOUR_START_PROCEDURE
HARBOUR HB_HB_RUN();
#else
HARBOUR HB_MAIN();
#endif
static PASM_CALL CreateFun( PHB_SYMB, BYTE * ); /* Create a dynamic function*/
static ULONG FindSymbol( char *, PDYNFUNC, ULONG );
static void HRB_FileClose( FILE * );
static void HRB_FileRead ( char *, int, int, FILE * );
static FILE *HRB_FileOpen ( char * );
BYTE ReadByte( FILE * );
char *ReadId ( FILE * );
long ReadLong( FILE * );
/*
* This file contains the extra exportable functions available to the Harbour
* program
*/
#include "run_exp.h"
#if !defined( __GNUC__ )
static void InitRunnerTable( void )
{
#include "initsymc.h" /* Include default symbols */
}
#pragma startup InitRunnerTable
#else
HB_CALL_ON_STARTUP_BEGIN( InitRunnerTable )
#include "initsymc.h"
HB_CALL_ON_STARTUP_END( InitRunnerTable );
#endif
ULONG ulSymEntry = 0; /* Link enhancement */
/*
HB_Run( <cFile> )
This program will get the data from the .HRB file and run the p-code
contained in it.
In due time it should also be able to collect the data from the
binary/executable itself
*/
#ifndef HARBOUR_START_PROCEDURE
HARBOUR HB_HB_RUN( void )
#else
HARBOUR HB_MAIN( void )
#endif
{
char *szFileName;
FILE *file;
ULONG ulSymbols; /* Number of symbols */
ULONG ulFuncs; /* Number of functions */
ULONG ulSize; /* Size of function */
ULONG ul, ulPos;
int i;
PHB_SYMB pSymRead; /* Symbols read */
PDYNFUNC pDynFunc; /* Functions read */
PHB_DYNS pDynSym;
if( hb_pcount() == 0 )
printf( "\nPlease give HRB file name\n" );
else
{
szFileName = hb_parc( 1 );
file = HRB_FileOpen( szFileName ); /* Open as binary */
if( file )
{
ulSymbols = ReadLong( file );
pSymRead = ( PHB_SYMB )hb_xgrab( ulSymbols * sizeof( HB_SYMB ) );
for( ul=0; ul < ulSymbols; ul++) /* Read symbols in .HRB */
{
pSymRead[ ul ].szName = ReadId( file );
pSymRead[ ul ].cScope = ReadByte( file );
pSymRead[ ul ].pFunPtr = ( PHB_FUNC ) (ULONG) ReadByte( file );
pSymRead[ ul ].pDynSym = NULL;
}
ulFuncs = ReadLong( file ); /* Read number of functions */
pDynFunc = ( PDYNFUNC ) hb_xgrab( ulFuncs * sizeof( DYNFUNC ) );
for( ul=0; ul < ulFuncs; ul++) /* Read symbols in .HRB */
{
pDynFunc[ ul ].szName = ReadId( file );
ulSize = ReadLong( file ); /* Read size of function */
pDynFunc[ ul ].pCode = ( BYTE * )hb_xgrab( ulSize );
HRB_FileRead( pDynFunc[ ul ].pCode, 1, ulSize, file );
/* Read the block */
pDynFunc[ ul ].pAsmCall = CreateFun( pSymRead,
pDynFunc[ ul ].pCode );
/* Create matching dynamic */
/* function */
}
ulSymEntry = 0;
for( ul = 0; ul < ulSymbols; ul++ ) /* Linker */
{
if( ( (ULONG) pSymRead[ ul ].pFunPtr ) == SYM_FUNC )
{
ulPos = FindSymbol( pSymRead[ ul ].szName, pDynFunc, ulFuncs );
if( ulPos != SYM_NOT_FOUND )
{
/* if( hb_dynsymFind( pSymRead[ ul ].szName ) &&
!( pSymRead[ ul ].cScope & FS_STATIC ) )
{ */ /* Exists and NOT static ? */
/* printf( "\nDuplicate identifier '%s' %i.",
pSymRead[ ul ].szName, pSymRead[ul].cScope );
exit( 1 );
} */
pSymRead[ ul ].pFunPtr = pDynFunc[ ulPos ].pAsmCall->pFunPtr;
}
else
pSymRead[ ul ].pFunPtr = ( PHB_FUNC ) SYM_EXTERN;
}
if( ( (ULONG) pSymRead[ ul ].pFunPtr ) == SYM_EXTERN )
{ /* External function */
pDynSym = hb_dynsymFind( pSymRead[ ul ].szName );
if( !pDynSym )
{
printf( "\nUnknown or unregistered function '%s'.",
pSymRead[ ul ].szName );
exit( 1 );
}
pSymRead[ ul ].pFunPtr = pDynSym->pFunPtr;
}
}
hb_vmProcessSymbols( pSymRead, ulSymbols );
/* Initialize static variables first
*/
for( ul = 0; ul < ulSymbols; ul++ ) /* Check INIT functions */
{
if( (pSymRead[ ul ].cScope & FS_INITEXIT) == FS_INITEXIT )
{
/* call (_INITSTATICS) function. This function assigns
* literal values to static variables only. There is no need
* to pass any parameters to this function because they
* cannot be used to initialize static variable.
*/
pSymRead[ ul ].pFunPtr();
}
}
for( ul = 0; ul < ulSymbols; ul++ ) /* Check INIT functions */
{
if( (pSymRead[ ul ].cScope & FS_INITEXIT) == FS_INIT )
{
hb_vmPushSymbol( pSymRead + ul );
hb_vmPushNil();
for( i = 0; i < (hb_pcount() - 1); i++ )
hb_vmPush( hb_param( i + 2, IT_ANY ) );
/* Push other cmdline params*/
hb_vmDo( hb_pcount() - 1 ); /* Run init function */
}
}
hb_vmPushSymbol( pSymRead );
hb_vmPushNil();
for( i = 0; i < (hb_pcount() - 1); i++ )
hb_vmPush( hb_param( i + 2, IT_ANY ) ); /* Push other cmdline params*/
hb_vmDo( hb_pcount() - 1 ); /* Run the thing !!! */
for( ul = 0; ul < ulSymbols; ul++ ) /* Check EXIT functions */
{
if( ( pSymRead[ ul ].cScope & FS_INITEXIT ) == FS_EXIT )
{
hb_vmPushSymbol( pSymRead + ul );
hb_vmPushNil();
hb_vmDo( 0 ); /* Run exit function */
pSymRead[ ul ].cScope = pSymRead[ ul ].cScope & (~FS_EXIT);
/* Exit function cannot be
handled by main in hvm.c */
}
}
for( ul = 0; ul < ulFuncs; ul++ )
{
hb_xfree( pDynFunc[ ul ].pAsmCall->pAsmData );
hb_xfree( pDynFunc[ ul ].pAsmCall );
hb_xfree( pDynFunc[ ul ].pCode );
hb_xfree( pDynFunc[ ul ].szName );
}
for( ul = 0; ul < ulSymbols; ul++ )
{
hb_xfree( pSymRead[ ul ].szName );
}
hb_xfree( pDynFunc );
hb_xfree( pSymRead );
HRB_FileClose( file );
}
else
{
printf( "\nCannot open %s\n", szFileName );
}
}
}
static ULONG FindSymbol( char *szName, PDYNFUNC pDynFunc, ULONG ulLoaded )
{
ULONG ulRet;
BYTE bFound;
if( ( ulSymEntry < ulLoaded ) && /* Is it a normal list ? */
!strcmp( szName, pDynFunc[ ulSymEntry ].szName ) )
ulRet = ulSymEntry++;
else
{
bFound = FALSE;
ulRet = 0;
while( !bFound && ulRet < ulLoaded )
{
if( !strcmp( szName, pDynFunc[ ulRet ].szName ) )
bFound = TRUE;
else
ulRet++;
}
if( !bFound )
ulRet = SYM_NOT_FOUND;
}
return( ulRet );
}
/* ReadId
Read the next (zero terminated) identifier */
char *ReadId( FILE *file )
{
char *szTemp; /* Temporary buffer */
char *szIdx;
char *szRet;
BYTE bCont = TRUE;
szTemp = ( char * )hb_xgrab( 256 );
szIdx = szTemp;
do
{
HRB_FileRead( szIdx, 1, 1, file );
if( *szIdx )
szIdx++;
else
bCont = FALSE;
} while( bCont );
szRet = (char *) hb_xgrab( szIdx - szTemp + 1 );
strcpy( szRet, szTemp );
hb_xfree( szTemp );
return( szRet );
}
BYTE ReadByte( FILE *file )
{
BYTE bRet;
HRB_FileRead( &bRet, 1, 1, file );
return( bRet );
}
long ReadLong( FILE *file )
{
char cLong[4]; /* Temporary long */
HRB_FileRead( cLong, 4, 1, file );
if( cLong[3] ) /* Convert to long if ok */
{
PHB_ITEM pError = hb_errNew();
hb_errPutDescription(pError, "Error reading .HRB file");
hb_errLaunch(pError);
hb_errRelease(pError);
return( 0L );
}
else
return( ( (BYTE) cLong[0] ) +
( (BYTE) cLong[1] ) * 0x100 +
( (BYTE) cLong[2] ) * 0x10000 +
( (BYTE) cLong[3] ) * 0x1000000 );
}
/* HRB_FileRead
Controlled read from file. If errornous -> Break */
static void HRB_FileRead( char *cBuffer, int iSize, int iCount, FILE *fStream )
{
if( iCount != (int) fread( cBuffer, iSize, iCount, fStream ) )
{ /* Read error */
PHB_ITEM pError = hb_errNew();
hb_errPutDescription(pError, "Error reading .HRB file");
hb_errLaunch(pError);
hb_errRelease(pError);
exit(1);
}
}
/* HRB_FileOpen
Open an .HRB file */
static FILE *HRB_FileOpen( char *szFileName )
{
return( fopen( szFileName, "rb" ) );
}
/* HRB_FileClose
Close an .HRB file */
static void HRB_FileClose( FILE *file )
{
fclose( file );
}
/* Patch an address of the dynamic function */
static void Patch( BYTE * pCode, ULONG ulOffset, void *Address )
{
/* #if 32 bits and low byte first */
pCode[ ulOffset ] = ( (ULONG) Address ) & 0xFF;
pCode[ ulOffset + 1 ] = ( (ULONG) Address >> 8 ) & 0xFF;
pCode[ ulOffset + 2 ] = ( (ULONG) Address >> 16 ) & 0xFF;
pCode[ ulOffset + 3 ] = ( (ULONG) Address >> 24 ) & 0xFF;
/* #elseif 16 bits and low byte first */
/* #elseif 32 bits and high byte first */
/* #elseif ... */
/* #endif */
}
/* Intel specific ?? Patch an address relative to the next instruction */
static void PatchRelative( BYTE * pCode, ULONG ulOffset,
void *Address, ULONG ulNext )
{
/* #if 32 bits and low byte first */
ULONG ulBase = (ULONG) pCode + ulNext;
/* Relative to next instruction */
ULONG ulRelative = (ULONG) Address - ulBase;
pCode[ ulOffset ] = ( ulRelative ) & 0xFF;
pCode[ ulOffset + 1 ] = ( ulRelative >> 8 ) & 0xFF;
pCode[ ulOffset + 2 ] = ( ulRelative >> 16 ) & 0xFF;
pCode[ ulOffset + 3 ] = ( ulRelative >> 24 ) & 0xFF;
/* #elseif 16 bits and low byte first */
/* #elseif 32 bits and high byte first */
/* #elseif ... */
/* #endif */
}
/*
Create dynamic function.
This function is needed, since it will allow the existing strategy of
function pointers to work properly.
For each Harbour function a little program calling the virtual machine
should be present (see : *.c)
Since these programs no longer exists when using this system, they should
be create dynamically at run-time.
If a .PRG contains 10 functions, 10 dynamic functions are created which
are all the same :-) except for 2 pointers.
*/
static PASM_CALL CreateFun( PHB_SYMB pSymbols, BYTE * pCode )
{
PASM_CALL asmRet = (PASM_CALL) hb_xgrab( sizeof( ASM_CALL ) );
asmRet->pAsmData = (BYTE * ) hb_xgrab( sizeof( prgFunction ) );
memcpy( asmRet->pAsmData, prgFunction, sizeof( prgFunction ) );
/* Copy new assembler code in */
/* #if INTEL32 */
Patch( asmRet->pAsmData, 1, pSymbols ); /* Insert pointer to testsym */
Patch( asmRet->pAsmData, 6, pCode); /* Insert pointer to testcode */
PatchRelative( asmRet->pAsmData, 11, &hb_vmExecute, 15 );
/* Insert pointer to hb_vmExecute() */
/* #elseif INTEL16 */
/* #elseif MOTOROLA */
/* #elseif ... */
/* #endif */
return( asmRet );
}

View File

@@ -16,6 +16,7 @@ LIBS=\
debug \
rdd \
vm \
rdd \
rtl \
hbpp \

View File

@@ -39,7 +39,6 @@
#include "pcode.h"
#include "set.h"
#include "inkey.h"
#include "init.h"
extern void hb_consoleInitialize( void );
extern void hb_consoleRelease( void );
@@ -58,18 +57,6 @@ typedef struct _SYMBOLS
extern HARBOUR HB_ERRORSYS( void );
extern HARBOUR HB_ERRORNEW( void );
HARBOUR HB_EVAL( void ); /* Evaluates a codeblock from Harbour */
HARBOUR HB_LEN( void ); /* Evaluates a codeblock from Harbour */
HARBOUR HB_EMPTY( void ); /* fixed entry point by now */
HARBOUR HB_VALTYPE( void ); /* returns a string description of a value */
HARBOUR HB_ERRORBLOCK( void );
HARBOUR HB_PROCNAME( void );
HARBOUR HB_PROCLINE( void );
HARBOUR HB___QUIT( void );
HARBOUR HB_ERRORLEVEL( void );
HARBOUR HB_PCOUNT( void );
HARBOUR HB_PVALUE( void );
static void hb_vmAliasPop( void ); /* pops the workarea number form the eval stack */
static void hb_vmAliasPush( void ); /* pushes the current workarea number */
static void hb_vmAliasSwap( void ); /* swaps items on the eval stack and pops the workarea number */

View File

@@ -10,6 +10,7 @@ LIBS=\
rtl \
rdd \
vm \
rdd \
rtl \
hbpp \
runner \
@@ -142,7 +143,6 @@ PRG_SOURCES=\
testwarn.prg \
tstcolor.prg \
transdef.prg \
transfrm.prg \
val.prg \
version.prg \
while.prg \

View File

@@ -1,132 +0,0 @@
//
// $Id$
//
#include "set.ch"
/*
* Test of the transform function
*
* Written by Eddie Runia <eddie@runia.comu>
* www - http://www.harbour-project.org
*
* Placed in the public domain
*/
function Main()
__SetCentury(.T.)
Set(_SET_DATEFORMAT, "dd/mm/yyyy")
QOut( "Hallo ", "!!!!! ", transform( "Hallo ", "!!!!!" ) )
QOut( "Hallo ", "!!A!! ", transform( "Hallo ", "!!A!!" ) )
QOut( "Hallo ", "!!A9! ", transform( "Hallo ", "!!A9!" ) )
QOut( "Hallo ", "!QA9! ", transform( "Hallo ", "!QA9!" ) )
QOut( "Hallo ", "ZQA9! ", transform( "Hallo ", "ZQA9!" ) )
QOut( "Hall ", "ZQA9! ", transform( "Hall" , "ZQA9!" ) )
QOut( "Hallo ", "!AAA ", transform( "Hallo ", "!AAA" ) )
QOut( "Hallo ", "@! ", transform( "Hallo ", "@!" ) )
QOut( "Hallo ", "@! AA ", transform( "Hallo ", "@! AA" ) )
QOut( "Hallo ", "@R ", transform( "Hallo ", "@R" ) )
QOut( "Hallo ", "@Z ", transform( "Hallo ", "@Z" ) )
QOut( "Hallo ", "@R !! ", transform( "Hallo ", "@R !!" ) )
QOut( "Hi ", "@R !!! ", transform( "Hi" , "@R !!!" ) )
QOut( "Hallo ", " ", transform( "Hallo ", "" ) )
Pause()
QOut( ".T. ", " ", transform( .T. , "" ) )
QOut( ".F. ", " ", transform( .F. , "" ) )
QOut( ".T. ", "L ", transform( .T. , "L" ) )
QOut( ".F. ", "L ", transform( .F. , "L" ) )
QOut( ".T. ", "Y ", transform( .T. , "Y" ) )
QOut( ".F. ", "Y ", transform( .F. , "Y" ) )
QOut( ".T. ", "X ", transform( .T. , "X" ) )
QOut( ".F. ", "# ", transform( .F. , "#" ) )
QOut( ".T. ", "X! ", transform( .T. , "X!" ) )
QOut( ".F. ", "@R Y ", transform( .F. , "@R Y" ) )
QOut( ".T. ", "@R X! ", transform( .T. , "@R X!" ) )
Pause()
QOut( "15 ", "9999 ", transform( 15 , "9999" ) )
QOut( "1.5 ", "99.99 ", transform( 1.5 , "99.99" ) )
QOut( "1.5 ", "9999 ", transform( 1.5 , "9999" ) )
QOut( "15 ", "#### ", transform( 15 , "####" ) )
QOut( "1.5 ", "##.## ", transform( 1.5 , "##.##" ) )
QOut( "1.5 ", "#### ", transform( 1.5 , "####" ) )
QOut( "15 ", " AX## " ,transform( 15 , " AX##" ) )
QOut( "1.5 ", "!9XPA.9 " ,transform( 1.5 , "!9XPA.9" ) )
QOut( "-15 ", "9999 ", transform( -15 , "9999" ) )
QOut( "-1.5 ", "99.99 ", transform( -1.5 , "99.99" ) )
QOut( "-15 ", "$999 ", transform( -15 , "$999" ) )
QOut( "-1.5 ", "*9.99 ", transform( -1.5 , "*9.99" ) )
QOut( "41 ", "$$$9 ", transform( 41 , "$$$9" ) )
QOut( "41 ", "***9 ", transform( 41 , "***9" ) )
QOut( "15000 ", "9999 ", transform( 15000 , "9999" ) )
QOut( "15000 ", "99,999 ", transform( 15000 , "99,999" ) )
Pause()
QOut( "1500 ", "99,999 ", transform( 1500 , "99,999" ) )
QOut( "150 ", "99,999 ", transform( 150 , "99,999" ) )
QOut( "150 ", "99,99 ", transform( 150 , "99,99" ) )
QOut( "41 ", "@Z 9999 ", transform( 41 , "@Z 9999" ) )
QOut( "0 ", "@Z 9999 ", transform( 0 , "@Z 9999" ) )
QOut( "41 ", "@0 9999 ", transform( 41 , "@0 9999" ), " (Harbour Power !)" )
QOut( "0 ", "@0 9999 ", transform( 0 , "@0 9999" ), " (Harbour Power !)" )
QOut( "41 ", "@B 9999 ", transform( 41 , "@B 9999" ) )
QOut( "41 ", "@B 99.9 ", transform( 41 , "@B 99.9" ) )
Pause()
QOut( "7 ", "@B 99.9 ", transform( 7 , "@B 99.9" ) )
QOut( "7 ", "@C 99.9 ", transform( 7 , "@C 99.9" ) )
QOut( "-7 ", "@C 99.9 ", transform( -7 , "@C 99.9" ) )
QOut( "7 ", "@X 99.9 ", transform( 7 , "@X 99.9" ) )
QOut( "-7 ", "@X 99.9 ", transform( -7 , "@X 99.9" ) )
QOut( "7 ", "@( 99.9 ", transform( 7 , "@( 99.9" ) )
QOut( "-7 ", "@( 99.9 ", transform( -7 , "@( 99.9" ) )
QOut( "7 ", "9X9Z5.9 ", transform( 7 , "9X9Z5.9" ) )
QOut( "-7 ", "@R 9X9^ ", transform( -7 , "@R 9X9^" ) )
QOut( "-7 ", "9X9^ ", transform( -7 , "9X9^" ) )
QOut( "1 ", "@R 9HI! ", transform( 1 , "@R 9HI!" ) )
QOut( "1 ", "9HI! ", transform( 1 , "9HI!" ) )
QOut( "-12 ", "@( 99 ", transform( -12 , "@( 99" ), " (BUG Fix)" )
QOut( "12 ", "@( 99 ", transform( 12 , "@( 99" ) )
Pause()
QOut( "1 ", " ", transform( 1 , "" ) )
QOut( "32768 ", " ", transform( 32768 , "" ) )
QOut( "-20 ", " ", transform( -20 , "" ) )
QOut( "1048576 ", " ", transform( 1048576 , "" ) )
QOut( "21.65 ", " ", transform( 21.65 , "" ) )
QOut( "-3.33 ", " ", transform( -3.33 , "" ) )
Pause()
QOut( "-1234 ", "@( 9999 ", transform( -1234 , "@( 9999" ), " (BUG Fix)" )
QOut( "-1234 ", "@B 9999 ", transform( -1234 , "@B 9999" ) )
QOut( "-1234 ", "@B( 9999 ", transform( -1234 , "@B( 9999" ) )
QOut( "1234 ", "@E 9,999.99 ", transform( 1234 , "@E 9,999.99" ) )
QOut( "12.2 ", "@E 9,999.99 ", transform( 12.2 , "@E 9,999.99" ) )
QOut( "-1234 ", "@X 9999 ", transform( -1234 , "@X 9999" ) )
QOut( "-1234 ", "@BX 9999 ", transform( -1234 , "@BX 9999" ) )
QOut( "1234 ", "@X 9999 ", transform( 1234 , "@B 9999" ) )
QOut( "1234 ", "@BX 9999 ", transform( 1234 , "@BX 9999" ) )
QOut( "1234 ", "@D 9999 ", transform( 1234 , "@D 9999" ), " (BUG Fix)" )
QOut( "1234 ", "@BD 9999 ", transform( 1234 , "@BD 9999" ), " (BUG Fix)" )
QOut( "0 ", "@Z 9999 ", transform( 0 , "@Z 9999" ) )
QOut( "0 ", "@BZ 9999 ", transform( 0 , "@BZ 9999" ) )
// QOut( "NIL ", "9 ", transform( NIL , "9" ) )
// ^ Generates error ^
Pause()
QOut( "12/12/1990 ", "99/99/9999 ", transform( ctod("12/12/1990") , "99/99/9999" ) )
QOut( "02/12/1990 ", "99.99.9999 ", transform( ctod("02/12/1990") , "99.99.9999" ) )
QOut( " / / ", "99/99/9999 ", transform( ctod(" / / ") , "99/99/9999" ) )
QOut( "02/12/1990 ", "99/99/99 ", transform( ctod("02/12/1990") , "99/99/99" ) )
QOut( "12/12/1990 ", "99-99-99 ", transform( ctod("12/12/1990") , "99-99-99" ) )
QOut( "30/04/2004 ", "99.99.99 ", transform( ctod("30/04/2004") , "99.99.99" ) )
QOut( " / / ", "99/99/99 ", transform( ctod(" / / ") , "99/99/99" ) )
QOut( "01/01/1992 ", "THISWRNG ", transform( ctod("01/01/1992") , "THISWRNG" ) )
QOut( "05/06/1935 ", "999/99/9 ", transform( ctod("05/06/1935") , "999/99/9" ) )
QOut( "12/11/1910 ", "9#-9#/## ", transform( ctod("12/11/1910") , "9#-9#/##" ) )
QOut( "01/01/1992 ", " ", transform( ctod("01/01/1992") , "" ) )
QOut( "01/01/1992 ", "DO THIS ", transform( ctod("01/01/1992") , "DO THIS " ) )
QOut( "02/01/1992 ", "@E ", transform( ctod("02/01/1992") , "@E" ) )
QOut("")
return nil
function Pause()
QOut("")
__Accept( "Pause:" )
return nil