2001-11-02 22:50 GMT+1 Martin Vogel <vogel@inttec.de>
This commit is contained in:
@@ -1,3 +1,20 @@
|
||||
2001-11-02 22:50 GMT+1 Martin Vogel <vogel@inttec.de>
|
||||
|
||||
+ contrib/libct/keyset.c
|
||||
+ key switch functions KSETINS, KSETCAPS, KSETNUM, KSETSCROLL
|
||||
+ contrib/libct/print.c
|
||||
+ printer functions PRINTSTAT, PRINTREADY
|
||||
+ contrib/libct/numconv.prg
|
||||
+ number manipulation functions NTOC, CTON
|
||||
|
||||
all provided by Walter Negro - FOEESITRA <waltern@foeesitra.org.ar>
|
||||
|
||||
* contrib/libct/Makefile
|
||||
* contrib/libct/makefile.bc
|
||||
* contrib/libct/makefile.vc
|
||||
* contrib/libct/ctflist.txt
|
||||
* changes according to the above
|
||||
|
||||
2001-11-01 05:10 UTC-0800 Brian Hays <bhays@abacuslaw.com>
|
||||
|
||||
* harbour/include/hbsetup.h
|
||||
|
||||
@@ -29,9 +29,10 @@ C_SOURCES = \
|
||||
ctchksum.c \
|
||||
ctcolton.c \
|
||||
ctcrypt.c \
|
||||
files.c \
|
||||
finan.c \
|
||||
justify.c \
|
||||
files.c \
|
||||
keyset.c \
|
||||
math.c \
|
||||
num1.c \
|
||||
numat.c \
|
||||
@@ -39,6 +40,7 @@ C_SOURCES = \
|
||||
pos1.c \
|
||||
pos2.c \
|
||||
posdiff.c \
|
||||
print.c \
|
||||
range.c \
|
||||
relation.c \
|
||||
remove.c \
|
||||
@@ -54,6 +56,7 @@ PRG_SOURCES= \
|
||||
ct.prg \
|
||||
ctmisc.prg \
|
||||
datetime.prg \
|
||||
numconv.prg \
|
||||
|
||||
LIBNAME=libct
|
||||
|
||||
|
||||
@@ -275,7 +275,7 @@ CELSIUS ;R;
|
||||
CLEARBIT ;N;
|
||||
CTOBIT ;N;
|
||||
CTOF ;N;
|
||||
CTON ;N;
|
||||
CTON ;S;
|
||||
EXPONENT ;N;
|
||||
FAHRENHEIT ;R;
|
||||
FTOC ;N;
|
||||
@@ -285,7 +285,7 @@ INTPOS ;N;
|
||||
ISBIT ;N;
|
||||
LTON ;N;
|
||||
MANTISSA ;N;
|
||||
NTOC ;N;
|
||||
NTOC ;S;
|
||||
NUMAND ;N;
|
||||
NUMCOUNT ;N;
|
||||
NUMHIGH ;N;
|
||||
@@ -426,11 +426,11 @@ VOLUME ;N;
|
||||
NUMPRINTER ;N;
|
||||
PRINTFILE ;N;
|
||||
PRINTINIT ;N;
|
||||
PRINTREADY ;N;
|
||||
PRINTREADY ;S;dos
|
||||
PRINTSCR ;N;
|
||||
PRINTSCRX ;N;
|
||||
PRINTSEND ;N;
|
||||
PRINTSTAT ;N;
|
||||
PRINTSTAT ;S;dos
|
||||
SPOOLACTIV ;N;
|
||||
SPOOLADD ;N;
|
||||
SPOOLCOUNT ;N;
|
||||
@@ -522,10 +522,10 @@ CSETSOFT ;N;
|
||||
CSETUNIQ ;N;
|
||||
CSETWRAP ;N;
|
||||
ISDEBUG ;N;
|
||||
KSETCAPS ;N;
|
||||
KSETINS ;N;
|
||||
KSETNUM ;N;
|
||||
KSETSCROLL ;N;
|
||||
KSETCAPS ;S;dos
|
||||
KSETINS ;S;dos
|
||||
KSETNUM ;S;dos
|
||||
KSETSCROLL ;S;dos
|
||||
LASTKFUNC ;N;
|
||||
LASTKLINE ;N;
|
||||
LASTKPROC ;N;
|
||||
|
||||
249
harbour/contrib/libct/keyset.c
Normal file
249
harbour/contrib/libct/keyset.c
Normal file
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* CT3 Printer functions: - KSETINS()
|
||||
* - KSETCAPS()
|
||||
* - KSETNUM()
|
||||
* - KSETSCROLL()
|
||||
*
|
||||
* Copyright 2001 Walter Negro - FOEESITRA" <waltern@foeesitra.org.ar>
|
||||
* 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, 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries 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 Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ct.h"
|
||||
|
||||
#if defined (HB_OS_DOS)
|
||||
|
||||
#if defined(__DJGPP__)
|
||||
#include "pc.h"
|
||||
#include "sys\exceptn.h"
|
||||
#include "sys\farptr.h"
|
||||
#elif defined(__MSC_VER)
|
||||
#include "signal.h"
|
||||
#endif
|
||||
|
||||
static void SetGet( char cKey );
|
||||
|
||||
|
||||
/* $DOC$
|
||||
* $FUNCNAME$
|
||||
* KSETINS()
|
||||
* $CATEGORY$
|
||||
* CT3 switch and state functions
|
||||
* $ONELINER$
|
||||
* $SYNTAX$
|
||||
* KSETINS ([<lNewSwitch>]) -> lOldSwitch
|
||||
* $ARGUMENTS$
|
||||
* $RETURNS$
|
||||
* $DESCRIPTION$
|
||||
* TODO: add documentation
|
||||
* $EXAMPLES$
|
||||
* $TESTS$
|
||||
* $STATUS$
|
||||
* Started
|
||||
* $COMPLIANCE$
|
||||
* $PLATFORMS$
|
||||
* DOS
|
||||
* $FILES$
|
||||
* Source is keyset.c, library is libct.
|
||||
* $SEEALSO$
|
||||
* $END$
|
||||
*/
|
||||
|
||||
HB_FUNC (KSETINS)
|
||||
{
|
||||
|
||||
char cKey = 0x80;
|
||||
|
||||
SetGet( cKey );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* $DOC$
|
||||
* $FUNCNAME$
|
||||
* KSETCAPS()
|
||||
* $CATEGORY$
|
||||
* CT3 switch and state functions
|
||||
* $ONELINER$
|
||||
* $SYNTAX$
|
||||
* KSETCAPS ([<lNewSwitch>]) -> lOldSwitch
|
||||
* $ARGUMENTS$
|
||||
* $RETURNS$
|
||||
* $DESCRIPTION$
|
||||
* TODO: add documentation
|
||||
* $EXAMPLES$
|
||||
* $TESTS$
|
||||
* $STATUS$
|
||||
* Started
|
||||
* $COMPLIANCE$
|
||||
* $PLATFORMS$
|
||||
* DOS
|
||||
* $FILES$
|
||||
* Source is keyset.c, library is libct.
|
||||
* $SEEALSO$
|
||||
* $END$
|
||||
*/
|
||||
|
||||
HB_FUNC (KSETCAPS)
|
||||
{
|
||||
|
||||
char cKey = 0x40;
|
||||
|
||||
SetGet( cKey );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* $DOC$
|
||||
* $FUNCNAME$
|
||||
* KSETNUM()
|
||||
* $CATEGORY$
|
||||
* CT3 switch and state functions
|
||||
* $ONELINER$
|
||||
* $SYNTAX$
|
||||
* KSETNUM ([<lNewSwitch>]) -> lOldSwitch
|
||||
* $ARGUMENTS$
|
||||
* $RETURNS$
|
||||
* $DESCRIPTION$
|
||||
* TODO: add documentation
|
||||
* $EXAMPLES$
|
||||
* $TESTS$
|
||||
* $STATUS$
|
||||
* Started
|
||||
* $COMPLIANCE$
|
||||
* $PLATFORMS$
|
||||
* DOS
|
||||
* $FILES$
|
||||
* Source is keyset.c, library is libct.
|
||||
* $SEEALSO$
|
||||
* $END$
|
||||
*/
|
||||
|
||||
HB_FUNC (KSETNUM)
|
||||
{
|
||||
|
||||
char cKey = 0x20;
|
||||
|
||||
SetGet( cKey );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* $DOC$
|
||||
* $FUNCNAME$
|
||||
* KSETSCROLL()
|
||||
* $CATEGORY$
|
||||
* CT3 switch and state functions
|
||||
* $ONELINER$
|
||||
* $SYNTAX$
|
||||
* KSETSCROLL ([<lNewSwitch>]) -> lOldSwitch
|
||||
* $ARGUMENTS$
|
||||
* $RETURNS$
|
||||
* $DESCRIPTION$
|
||||
* TODO: add documentation
|
||||
* $EXAMPLES$
|
||||
* $TESTS$
|
||||
* $STATUS$
|
||||
* Started
|
||||
* $COMPLIANCE$
|
||||
* $PLATFORMS$
|
||||
* DOS
|
||||
* $FILES$
|
||||
* Source is keyset.c, library is libct.
|
||||
* $SEEALSO$
|
||||
* $END$
|
||||
*/
|
||||
|
||||
HB_FUNC (KSETSCROLL)
|
||||
{
|
||||
|
||||
char cKey = 0x10;
|
||||
|
||||
SetGet( cKey );
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void SetGet( char cKey )
|
||||
{
|
||||
|
||||
#if defined(__WATCOMC__) && defined(__386__)
|
||||
|
||||
hb_retl( *( ( char * ) 0x0417 ) & cKey );
|
||||
|
||||
#elif defined(__DJGPP__)
|
||||
|
||||
hb_retl( _farpeekb( 0x0040, 0x0017 ) & cKey );
|
||||
|
||||
#else
|
||||
|
||||
hb_retl( *( ( char FAR * ) MK_FP( 0x0040, 0x0017 ) ) & cKey );
|
||||
|
||||
#endif
|
||||
|
||||
if ( hb_pcount() >= 1 )
|
||||
{
|
||||
cKey = hb_parl( 1 ) * cKey;
|
||||
|
||||
#if defined(__WATCOMC__) && defined(__386__)
|
||||
|
||||
*( ( char * ) 0x0417 ) = ( *( ( char * ) 0x0417 ) & ( !cKey ) ) | cKey );
|
||||
|
||||
#elif defined(__DJGPP__)
|
||||
|
||||
_farpokeb( 0x0040, 0x0017, ( _farpeekb( 0x0040, 0x0017 ) & ( !cKey ) ) | cKey );
|
||||
|
||||
#else
|
||||
|
||||
*( ( char FAR * ) MK_FP( 0x0040, 0x0017 ) ) = ( *( ( char FAR * ) MK_FP( 0x0040, 0x0017 ) ) & ( !cKey ) ) | cKey );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif /* #if defined (HB_OS_DOS) */
|
||||
@@ -114,9 +114,10 @@ TOOLS_LIB_OBJS = \
|
||||
$(OBJ_DIR)\ctchksum.obj \
|
||||
$(OBJ_DIR)\ctcolton.obj \
|
||||
$(OBJ_DIR)\ctcrypt.obj \
|
||||
$(OBJ_DIR)\finan.obj \
|
||||
$(OBJ_DIR)\files.obj \
|
||||
$(OBJ_DIR)\finan.obj \
|
||||
$(OBJ_DIR)\justify.obj \
|
||||
$(OBJ_DIR)\keyset.obj \
|
||||
$(OBJ_DIR)\math.obj \
|
||||
$(OBJ_DIR)\num1.obj \
|
||||
$(OBJ_DIR)\numat.obj \
|
||||
@@ -124,6 +125,7 @@ TOOLS_LIB_OBJS = \
|
||||
$(OBJ_DIR)\pos1.obj \
|
||||
$(OBJ_DIR)\pos2.obj \
|
||||
$(OBJ_DIR)\posdiff.obj \
|
||||
$(OBJ_DIR)\print.obj \
|
||||
$(OBJ_DIR)\range.obj \
|
||||
$(OBJ_DIR)\relation.obj \
|
||||
$(OBJ_DIR)\remove.obj \
|
||||
@@ -138,6 +140,7 @@ TOOLS_LIB_OBJS = \
|
||||
$(OBJ_DIR)\ct.obj \
|
||||
$(OBJ_DIR)\ctmisc.obj \
|
||||
$(OBJ_DIR)\datetime.obj \
|
||||
$(OBJ_DIR)\numconv.obj \
|
||||
|
||||
#
|
||||
# Our default target
|
||||
@@ -252,18 +255,22 @@ $(OBJ_DIR)\ctcrypt.obj : $(TOOLS_DIR)\ctcrypt.c
|
||||
$(CC) $(CLIBFLAGS) -o$@ $**
|
||||
tlib $(TOOLS_LIB) $(ARFLAGS) -+$@,,
|
||||
|
||||
$(OBJ_DIR)\finan.obj : $(TOOLS_DIR)\finan.c
|
||||
$(CC) $(CLIBFLAGS) -o$@ $**
|
||||
tlib $(TOOLS_LIB) $(ARFLAGS) -+$@,,
|
||||
|
||||
$(OBJ_DIR)\files.obj : $(TOOLS_DIR)\files.c
|
||||
$(CC) $(CLIBFLAGS) -o$@ $**
|
||||
tlib $(TOOLS_LIB) $(ARFLAGS) -+$@,,
|
||||
|
||||
$(OBJ_DIR)\finan.obj : $(TOOLS_DIR)\finan.c
|
||||
$(CC) $(CLIBFLAGS) -o$@ $**
|
||||
tlib $(TOOLS_LIB) $(ARFLAGS) -+$@,,
|
||||
|
||||
$(OBJ_DIR)\justify.obj : $(TOOLS_DIR)\justify.c
|
||||
$(CC) $(CLIBFLAGS) -o$@ $**
|
||||
tlib $(TOOLS_LIB) $(ARFLAGS) -+$@,,
|
||||
|
||||
$(OBJ_DIR)\keyset.obj : $(TOOLS_DIR)\keyset.c
|
||||
$(CC) $(CLIBFLAGS) -o$@ $**
|
||||
tlib $(TOOLS_LIB) $(ARFLAGS) -+$@,,
|
||||
|
||||
$(OBJ_DIR)\math.obj : $(TOOLS_DIR)\math.c
|
||||
$(CC) $(CLIBFLAGS) -o$@ $**
|
||||
tlib $(TOOLS_LIB) $(ARFLAGS) -+$@,,
|
||||
@@ -292,6 +299,10 @@ $(OBJ_DIR)\posdiff.obj : $(TOOLS_DIR)\posdiff.c
|
||||
$(CC) $(CLIBFLAGS) -o$@ $**
|
||||
tlib $(TOOLS_LIB) $(ARFLAGS) -+$@,,
|
||||
|
||||
$(OBJ_DIR)\print.obj : $(TOOLS_DIR)\print.c
|
||||
$(CC) $(CLIBFLAGS) -o$@ $**
|
||||
tlib $(TOOLS_LIB) $(ARFLAGS) -+$@,,
|
||||
|
||||
$(OBJ_DIR)\range.obj : $(TOOLS_DIR)\range.c
|
||||
$(CC) $(CLIBFLAGS) -o$@ $**
|
||||
tlib $(TOOLS_LIB) $(ARFLAGS) -+$@,,
|
||||
@@ -352,3 +363,10 @@ $(OBJ_DIR)\datetime.c : $(TOOLS_DIR)\datetime.prg
|
||||
$(OBJ_DIR)\datetime.obj : $(OBJ_DIR)\datetime.c
|
||||
$(CC) $(CLIBFLAGS) -o$@ $**
|
||||
tlib $(TOOLS_LIB) $(ARFLAGS) -+$@,,
|
||||
|
||||
$(OBJ_DIR)\numconv.c : $(TOOLS_DIR)\numconv.prg
|
||||
$(HARBOUR_EXE) $(HARBOURFLAGS) $** -o$@
|
||||
|
||||
$(OBJ_DIR)\numconv.obj : $(OBJ_DIR)\numconv.c
|
||||
$(CC) $(CLIBFLAGS) -o$@ $**
|
||||
tlib $(TOOLS_LIB) $(ARFLAGS) -+$@,,
|
||||
|
||||
@@ -136,6 +136,7 @@ TOOLS_LIB_OBJS = \
|
||||
$(OBJ_DIR)\ctcrypt.obj \
|
||||
$(OBJ_DIR)\finan.obj \
|
||||
$(OBJ_DIR)\justify.obj \
|
||||
$(OBJ_DIR)\keyset.obj \
|
||||
$(OBJ_DIR)\math.obj \
|
||||
$(OBJ_DIR)\num1.obj \
|
||||
$(OBJ_DIR)\numat.obj \
|
||||
@@ -143,6 +144,7 @@ TOOLS_LIB_OBJS = \
|
||||
$(OBJ_DIR)\pos1.obj \
|
||||
$(OBJ_DIR)\pos2.obj \
|
||||
$(OBJ_DIR)\posdiff.obj \
|
||||
$(OBJ_DIR)\print.obj \
|
||||
$(OBJ_DIR)\range.obj \
|
||||
$(OBJ_DIR)\relation.obj \
|
||||
$(OBJ_DIR)\remove.obj \
|
||||
@@ -157,6 +159,7 @@ TOOLS_LIB_OBJS = \
|
||||
$(OBJ_DIR)\ct.obj \
|
||||
$(OBJ_DIR)\ctmisc.obj \
|
||||
$(OBJ_DIR)\datetime.obj \
|
||||
$(OBJ_DIR)\numconv.obj \
|
||||
|
||||
#
|
||||
# Our default target
|
||||
|
||||
161
harbour/contrib/libct/numconv.prg
Normal file
161
harbour/contrib/libct/numconv.prg
Normal file
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* CT3 Number and bit manipulation functions: - NTOC()
|
||||
* - CTON()
|
||||
*
|
||||
* Copyright 2001 Walter Negro - FOEESITRA" <waltern@foeesitra.org.ar>
|
||||
* 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, 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries 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 Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common.ch"
|
||||
|
||||
/* $DOC$
|
||||
* $FUNCNAME$
|
||||
* NTOC()
|
||||
* $CATEGORY$
|
||||
* CT3 number and bit manipulation functions
|
||||
* $ONELINER$
|
||||
* $SYNTAX$
|
||||
* NTOC (<xNumber>[, <nBase>][,<nLength>][,<cPadChar>]) -> <cNumber>
|
||||
* $ARGUMENTS$
|
||||
* $RETURNS$
|
||||
* $DESCRIPTION$
|
||||
* TODO: add documentation
|
||||
* $EXAMPLES$
|
||||
* $TESTS$
|
||||
* $STATUS$
|
||||
* Started
|
||||
* $COMPLIANCE$
|
||||
* $PLATFORMS$
|
||||
* All
|
||||
* $FILES$
|
||||
* Source is numconv.prg, library is libct.
|
||||
* $SEEALSO$
|
||||
* CTON()
|
||||
* $END$
|
||||
*/
|
||||
|
||||
FUNCTION NTOC( xNum, nBase, nLenght, cPad )
|
||||
LOCAL cNum
|
||||
|
||||
Default cPad to "0"
|
||||
|
||||
IF VALTYPE( xNum ) == "C"
|
||||
xNum = ALLTRIM( xNum )
|
||||
xNum = UPPER( xNum )
|
||||
xNum = CTON( xNum, 16 )
|
||||
ENDIF
|
||||
IF nBase > 36 .OR. nBase < 2
|
||||
RETURN ""
|
||||
ENDIF
|
||||
|
||||
cNum = B10TOBN( xNum, @nBase )
|
||||
|
||||
IF ISNUMBER( nLenght ) .AND. LEN( cNum ) < nLenght
|
||||
cNum = REPLICATE( cPad, nLenght - LEN( cNum ) ) + cNum
|
||||
ENDIF
|
||||
|
||||
RETURN cNum
|
||||
|
||||
|
||||
/* $DOC$
|
||||
* $FUNCNAME$
|
||||
* CTON()
|
||||
* $CATEGORY$
|
||||
* CT3 number and bit manipulation functions
|
||||
* $ONELINER$
|
||||
* $SYNTAX$
|
||||
* CTON (<xNumber>[, <nBase>][,<lMode>]) -> <nNumber>
|
||||
* $ARGUMENTS$
|
||||
* $RETURNS$
|
||||
* $DESCRIPTION$
|
||||
* TODO: add documentation
|
||||
* $EXAMPLES$
|
||||
* $TESTS$
|
||||
* $STATUS$
|
||||
* Started
|
||||
* $COMPLIANCE$
|
||||
* $PLATFORMS$
|
||||
* All
|
||||
* $FILES$
|
||||
* Source is numconv.prg, library is libct.
|
||||
* $SEEALSO$
|
||||
* NTOC()
|
||||
* $END$
|
||||
*/
|
||||
|
||||
FUNCTION CTON( xNum, nBase, lMode )
|
||||
LOCAL i, nNum:=0, cWorld := '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
|
||||
Default lMode TO .F.
|
||||
|
||||
xNum = ALLTRIM(xNum)
|
||||
|
||||
FOR i=LEN( xNum ) TO 1 STEP -1
|
||||
nNum += (nBase ** i) * AT(SUBSTR(xNum,i,1),cWorld)
|
||||
NEXT
|
||||
|
||||
IF lMode
|
||||
IF nNum > 32767
|
||||
nNum = nNum - 65536
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
RETURN nNum
|
||||
|
||||
|
||||
STATIC FUNCTION B10TOBN( xNum, nBase )
|
||||
LOCAL nParcial, cWorld := '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
|
||||
IF xNum > 0
|
||||
|
||||
nParcial = xNum % nBase
|
||||
RETURN B10TOBN( INT(xNum/nBase), @nBase ) + SUBSTR( cWorld, nParcial, 1 )
|
||||
|
||||
ENDIF
|
||||
RETURN ""
|
||||
|
||||
155
harbour/contrib/libct/print.c
Normal file
155
harbour/contrib/libct/print.c
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* CT3 Printer functions: - PRINTSTAT() / PRINTREADY()
|
||||
*
|
||||
* Copyright 2001 Walter Negro - FOEESITRA" <waltern@foeesitra.org.ar>
|
||||
* 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, 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 software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries 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 Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapifs.h"
|
||||
|
||||
|
||||
/* $DOC$
|
||||
* $FUNCNAME$
|
||||
* PRINTSTAT()
|
||||
* $CATEGORY$
|
||||
* CT3 printer functions
|
||||
* $ONELINER$
|
||||
* $SYNTAX$
|
||||
* PRINTSTAT ([<nPrinter>]) -> nState
|
||||
* $ARGUMENTS$
|
||||
* $RETURNS$
|
||||
* $DESCRIPTION$
|
||||
* TODO: add documentation
|
||||
* $EXAMPLES$
|
||||
* $TESTS$
|
||||
* $STATUS$
|
||||
* Started
|
||||
* $COMPLIANCE$
|
||||
* $PLATFORMS$
|
||||
* DOS
|
||||
* $FILES$
|
||||
* Source is print.c, library is libct.
|
||||
* $SEEALSO$
|
||||
* $END$
|
||||
*/
|
||||
|
||||
HB_FUNC( PRINTSTAT )
|
||||
{
|
||||
USHORT uiPort = ISNUM( 1 ) ? hb_parni( 1 ) : 1;
|
||||
int Status = 0;
|
||||
|
||||
#if defined(HB_OS_DOS)
|
||||
|
||||
/* NOTE: DOS specific solution, using BIOS interrupt */
|
||||
|
||||
union REGS regs;
|
||||
|
||||
regs.h.ah = 2;
|
||||
regs.HB_XREGS.dx = uiPort - 1;
|
||||
|
||||
HB_DOS_INT86( 0x17, ®s, ®s );
|
||||
|
||||
Status = regs.h.ah;
|
||||
|
||||
#endif
|
||||
|
||||
hb_retni( Status );
|
||||
}
|
||||
|
||||
|
||||
/* $DOC$
|
||||
* $FUNCNAME$
|
||||
* PRINTREADY()
|
||||
* $CATEGORY$
|
||||
* CT3 printer functions
|
||||
* $ONELINER$
|
||||
* $SYNTAX$
|
||||
* PRINTREADY ([<nPrinter>]) -> lPrinterReady
|
||||
* $ARGUMENTS$
|
||||
* $RETURNS$
|
||||
* $DESCRIPTION$
|
||||
* TODO: add documentation
|
||||
* $EXAMPLES$
|
||||
* $TESTS$
|
||||
* $STATUS$
|
||||
* Started
|
||||
* $COMPLIANCE$
|
||||
* $PLATFORMS$
|
||||
* DOS
|
||||
* $FILES$
|
||||
* Source is print.c, library is libct.
|
||||
* $SEEALSO$
|
||||
* $END$
|
||||
*/
|
||||
|
||||
HB_FUNC( PRINTREADY )
|
||||
{
|
||||
USHORT uiPort = ISNUM( 1 ) ? hb_parni( 1 ) : 1;
|
||||
int Status = 0;
|
||||
|
||||
#if defined(HB_OS_DOS)
|
||||
|
||||
/* NOTE: DOS specific solution, using BIOS interrupt */
|
||||
|
||||
union REGS regs;
|
||||
|
||||
regs.h.ah = 2;
|
||||
regs.HB_XREGS.dx = uiPort - 1;
|
||||
|
||||
HB_DOS_INT86( 0x17, ®s, ®s );
|
||||
|
||||
Status = regs.h.ah;
|
||||
|
||||
#endif
|
||||
|
||||
hb_retl( (Status == 0x90) );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user