home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Boston 2
/
boston-2.iso
/
DOS
/
PROGRAM
/
CLIPPER
/
NFTROFF
/
2.TR
< prev
next >
Wrap
Text File
|
1993-12-01
|
16KB
|
1,064 lines
.de }n
.bp
.sp .5i
..
.wh -.8i }n
.sp .5i
.po -.4i
.ll 7.5i
.ps 9
.vs 9
.in 0i
.ta 1.63265i
.sp 2
.ne 20
.ps +3
.vs +3
FT_BYT2BIT() Convert byte to string of 1\'s and 0\'s
.br
.ta
.in 0.08i
.ps -3
.vs -3
.sp 2
\fBFT_BYT2BIT()
Convert byte to string of 1\'s and 0\'s
.in 0i
.br
\l'6.24i'
.br
.sp
.in 0.08i
\fBSyntax
.sp
.in 0.4i
\fBFT_BYT2BIT( <cByte> ) -> cBitPattern
.sp
.in 0.08i
\fBArguments
.sp
.in 0.4i
\fB<cByte>\fR is the byte to convert\.
.sp
.in 0.08i
\fBReturns
.sp
.in 0.4i
9-character string, consisting of 1\'s and 0\'s, representing bits 0
through 7 of parameter byte, with space between bits 3 and 4\. Returns
NIL if parameters are faulty\.
.sp
.in 0.08i
\fBDescription
.sp
.in 0.4i
Can be used to show results of bit manipulation, both before and after\.
Binary representation follows right-to-left convention of bit position
numbering, 0 through 7\. Space between high and low nibbles for clarity
and easy comparison to hexadecimal notation\.
.sp
This function is presented to illustrate that bit-wise operations
are possible with Clipper code\. For greater speed, write \.C or
\.ASM versions and use the Clipper Extend system\.
.sp
.in 0.08i
\fBExamples
.sp
.in 0.4i
These three code lines perform a bitwise AND on bytes with values of
CHR(20) and CHR(36), and deliver the result as a string in binary (bit)
format\.
.sp
.in 0.8i
.ta 2.4i
? FT_BYT2BIT(CHR(20)) // byte1: \'0001 0100\'
.br
.ta
.ta 2.4i
? FT_BYT2BIT(CHR(36)) // byte2: \'0010 0100\'
.br
.ta
.sp
? FT_BYT2BIT(FT_BYTEAND(CHR(20), CHR(36)))
.in 2.32i
// result: \'0000 0100\'
.sp
.in 0.4i
For a demonstration of Clipper bit manipulations, compile and
link the program BITTEST\.PRG in the Nanforum Toolkit source code\.
.sp
.in 0.08i
\fBSource:\fR BYT2BIT\.PRG
.sp
\fBAuthor:\fR Forest Belt, Computer Diagnostic Services, Inc\.
.in 0i
.sp
.in 1.5i
.ti -1.5i
.ta 1.5i
.ft B
See Also:
.ft R
FT_BYT2HEX()
.ta 1.63265i
.in 0i
.sp 2
.ne 20
.ps +3
.vs +3
FT_BYT2HEX() Convert byte to hexadecimal version of its binary value
.br
.ta
.in 0.08i
.ps -3
.vs -3
.sp 2
\fBFT_BYT2HEX()
Convert byte to hexadecimal version of its binary value
.in 0i
.br
\l'6.24i'
.br
.sp
.in 0.08i
\fBSyntax
.sp
.in 0.4i
\fBFT_BYT2HEX( cByte ) -> cHexValue
.sp
.in 0.08i
\fBArguments
.sp
.in 0.4i
\fB<cByte>\fR is the byte to convert\.
.sp
.in 0.08i
\fBReturns
.sp
.in 0.4i
Three-character string, consisting of two digits of hexadecimal
notation and letter \'h\' to signify hex\. Returns NIL if parameters are
faulty\.
.sp
.in 0.08i
\fBDescription
.sp
.in 0.4i
Can be used to show results of bit manipulation, both before and after\.
.sp
This function is presented to illustrate that bit-wise operations
are possible with Clipper code\. For greater speed, write \.C or
\.ASM versions and use the Clipper Extend system\.
.sp
.in 0.08i
\fBExamples
.sp
.in 0.4i
These three code lines perform a bitwise AND on bytes with values of
CHR(20) and CHR(36), and deliver the result as a string in hexadecimal
format, using \'h\' to signify hexadecimal\.
.sp
.in 0.8i
.ta 2.4i
? FT_BYT2HEX(CHR(20)) // byte1: \'14h\'
.br
.ta
.ta 2.4i
? FT_BYT2HEX(CHR(36)) // byte2: \'24h\'
.br
.ta
.sp
? FT_BYT2HEX(FT_BYTEAND(CHR(20), CHR(36)))
.in 2.32i
// result: \'04h\'
.sp
.in 0.4i
For a demonstration of Clipper bit manipulations, compile and
link the program BITTEST\.PRG in the Nanforum Toolkit source code\.
.sp
.in 0.08i
\fBSource:\fR BYT2HEX\.PRG
.sp
\fBAuthor:\fR Forest Belt, Computer Diagnostic Services, Inc\.
.in 0i
.sp
.in 1.5i
.ti -1.5i
.ta 1.5i
.ft B
See Also:
.ft R
FT_BYT2BIT()
.ta 1.63265i
.in 0i
.sp 2
.ne 20
.ps +3
.vs +3
FT_D2E() Convert decimal to scientific notation
.br
.ta
.in 0.08i
.ps -3
.vs -3
.sp 2
\fBFT_D2E()
Convert decimal to scientific notation
.in 0i
.br
\l'6.24i'
.br
.sp
.in 0.08i
\fBSyntax
.sp
.in 0.96i
.ta 2.56i
\fBFT_D2E( <nDec>, <nPrecision> ) -> <cNumE>
.br
.ta
.sp
.in 0.08i
\fBArguments
.sp
.in 1.28i
.ta 1.2i
\fB<nDec>\fR Decimal number to convert
.br
.ta
.sp
.ta 1.2i
\fB<nPrecision>\fR Number of decimal places in result\.
.br
.ta
.in 1.68i
Defaults to 6 decimal places\.
.sp
.in 0.08i
\fBReturns
.sp
.in 1.28i
.ta 1.2i
<cNumE> A string representing a number in
.br
.ta
.in 1.68i
scientific notation
.sp
.in 0.08i
\fBDescription
.sp
.in 1.28i
Given a decimal number and the desired precision,
a string representing the equivalent in scientific
notation is returned\.
.sp
.in 0.08i
\fBExamples
.sp
.in 1.28i
? FT_D2E( 12\.345, 2 )
.in 1.44i
-> 1\.23E1
.sp
.in 1.28i
? FT_D2E( -12\.345, 3 )
.in 1.44i
-> -1\.235E1
.sp
.in 1.28i
? FT_D2E( 0\.00000543, 2 )
.in 1.44i
-> 5\.43E-6
.sp
.in 0.08i
\fBSource:\fR D2E\.PRG
.sp
\fBAuthor:\fR Gary Baren
.in 0i
.sp
.in 1.5i
.ti -1.5i
.ta 1.5i
.ft B
See Also:
.ft R
FT_E2D()
.ta 1.63265i
.in 0i
.sp 2
.ne 20
.ps +3
.vs +3
FT_DEC2BIN() Convert decimal to binary
.br
.ta
.in 0.08i
.ps -3
.vs -3
.sp 2
\fBFT_DEC2BIN()
Convert decimal to binary
.in 0i
.br
\l'6.24i'
.br
.sp
.in 0.08i
\fBSyntax
.sp
.in 0.4i
\fBFT_DEC2BIN( <nNum> ) -> cBinaryNumber
.sp
.in 0.08i
\fBArguments
.sp
.in 0.4i
\fB<nNum>\fR is the numeric expression to be converted\.
.sp
.in 0.08i
\fBReturns
.sp
.in 0.4i
A character string representing <nNum> in binary format\.
.sp
.in 0.08i
\fBDescription
.sp
.in 0.4i
This function can be used in conjunction with any bit-wise
operations\.
.sp
.in 0.08i
\fBExamples
.sp
.in 0.4i
.ta 2.48i
QOut( FT_DEC2BIN(255) ) // "11111111"
.br
.ta
.ta 2.48i
QOut( FT_DEC2BIN(2) ) // "00000010"
.br
.ta
.sp
.in 0.08i
\fBSource:\fR DECTOBIN\.PRG
.sp
\fBAuthor:\fR Greg Lief
.in 0i
.ta 1.63265i
.sp 2
.ne 20
.ps +3
.vs +3
FT_E2D() Convert scientific notation string to a decimal
.br
.ta
.in 0.08i
.ps -3
.vs -3
.sp 2
\fBFT_E2D()
Convert scientific notation string to a decimal
.in 0i
.br
\l'6.24i'
.br
.sp
.in 0.08i
\fBSyntax
.sp
.in 0.96i
.ta 1.52i
\fBFT_E2D( <cNumE> ) -> <nDec>
.br
.ta
.sp
.in 0.08i
\fBArguments
.sp
.in 1.28i
.ta 0.8i
\fB<cNumE>\fR Scientific notation string to convert
.br
.ta
.sp
.in 0.08i
\fBReturns
.sp
.in 1.28i
.ta 0.8i
<nDec> Decimal number
.br
.ta
.sp
.in 0.08i
\fBDescription
.sp
.in 1.28i
.ta 2.4i
Given a string in the format x\.yEz, the decimal
.br
.ta
equivalent is returned\.
.sp
.in 0.08i
\fBExamples
.sp
.in 1.28i
? FT_E2D( "1\.23E1" )
.in 1.44i
-> 12\.3
.sp
.in 1.28i
? FT_E2D( "-1\.235E1" )
.in 1.44i
-> -12\.35
.sp
.in 1.28i
? ft_d2e( "5\.43E-6" )
.in 1.44i
-> 0\.0000543
.sp
.in 0.08i
\fBSource:\fR E2D\.PRG
.sp
\fBAuthor:\fR Gary Baren
.in 0i
.sp
.in 1.5i
.ti -1.5i
.ta 1.5i
.ft B
See Also:
.ft R
FT_D2E()
.ta 1.63265i
.in 0i
.sp 2
.ne 20
.ps +3
.vs +3
FT_ESCCODE() Convert Lotus style escape codes
.br
.ta
.in 0.08i
.ps -3
.vs -3
.sp 2
\fBFT_ESCCODE()
Convert Lotus style escape codes
.in 0i
.br
\l'6.24i'
.br
.sp
.in 0.08i
\fBSyntax
.sp
.in 0.4i
.ta 1.92i
\fBFT_ESCCODE( <cASCII> ) -> <cPrinterFormat>
.br
.ta
.sp
.in 0.08i
\fBArguments
.sp
.in 0.4i
\fB<cASCII>\fR is the ASCII representation of the printer control
.in 1.28i
codes in Lotus 123 format (e\.g\. "\\027E" for Chr(27)+"E")
.sp
.br
"\\nnn" will be converted to Chr(nnn)
.br
"\\\\" will be converted to "\\"
.sp
.in 0.08i
\fBReturns
.sp
.in 0.4i
The binary version of an ASCII coded printer setup string\.
.sp
.in 0.08i
\fBDescription
.sp
.in 0.4i
This function is useful for allowing the user to enter printer
control codes in Lotus-style ASCII format, and then having
this function convert that code to the format that the printer
needs to receive\.
.sp
.in 0.08i
\fBExamples
.sp
.in 0.4i
.ta 2i
cSetup = "\\015" // default = Epson compressed print
.br
.ta
.ta 2i
UserInput( @cSetup ) // Let user modify setup code
.br
.ta
.ta 2i
SET DEVICE TO PRINT // get ready to print
.br
.ta
.ta 2i
?? FT_ESCCODE( cSetup ) // Output the converted code
.br
.ta
.sp
.in 0.08i
\fBSource:\fR PRTESC\.PRG
.sp
\fBAuthor:\fR Steven Tyrakowski
.in 0i
.ta 1.63265i
.sp 2
.ne 20
.ps +3
.vs +3
FT_HEX2DEC() Convert a hex number to decimal
.br
.ta
.in 0.08i
.ps -3
.vs -3
.sp 2
\fBFT_HEX2DEC()
Convert a hex number to decimal
.in 0i
.br
\l'6.24i'
.br
.sp
.in 0.08i
\fBSyntax
.sp
.in 0.32i
\fBFT_HEX2DEC( <cHexNum> ) -> nDecNum
.sp
.in 0.08i
\fBArguments
.sp
.in 0.32i
\fB<cHexNum>\fR is a character string representing a hex number\.
.sp
.in 0.08i
\fBReturns
.sp
.in 0.32i
A decimal number\.
.sp
.in 0.08i
\fBDescription
.sp
.in 0.32i
Converts a hexadecimal number to a BASE 10 decimal number\.
Useful for using FT_INT86()\.
.sp
.in 0.08i
\fBExamples
.sp
.in 0.32i
FT_INT86( HEX2DEC( "21" ), aRegs )
.sp
Converts 21h, the Dos Interrupt, to its decimal equivalent,
33, for use by FT_INT86()\.
.sp
.in 0.08i
\fBSource:\fR HEX2DEC\.PRG
.sp
\fBAuthor:\fR Robert A\. DiFalco
.in 0i
.ta 1.63265i
.sp 2
.ne 20
.ps +3
.vs +3
FT_INVCLR() Get the inverse of a color
.br
.ta
.in 0.08i
.ps -3
.vs -3
.sp 2
\fBFT_INVCLR()
Get the inverse of a color
.in 0i
.br
\l'6.24i'
.br
.sp
.in 0.08i
\fBSyntax
.sp
.in 0.4i
\fBFT_INVCLR( [ <cDsrdColor> ] ) -> cColor
.sp
.in 0.08i
\fBArguments
.sp
.in 0.4i
\fB<cDsrdColor>\fR is the color to get the inverse of\. Defaults to
current color\.
.sp
.in 0.08i
\fBReturns
.sp
.in 0.4i
The inverse of the passed color\.
.sp
.in 0.08i
\fBDescription
.sp
.in 0.4i
This function inverts a passed color (in the Clipper format: ??/??),
e\.g\., "W/N" is converted to "N/W"\.
.sp
.in 0.08i
\fBExamples
.sp
.in 0.4i
.ta 2.8i
.br
cInverse := FT_INVCLR() // Get Inverse of Current Color
.br
.ta
.ta 0.72i
.br
cInvErr := FT_INVCLR( cErrColor ) // Get Inverse of cErrorColor
.br
.ta
.sp
.in 0.08i
\fBSource:\fR INVCLR\.PRG
.sp
\fBAuthor:\fR David Husnian
.in 0i
.ta 1.63265i
.sp 2
.ne 20
.ps +3
.vs +3
FT_NTOW() Translate numeric value to words
.br
.ta
.in 0.08i
.ps -3
.vs -3
.sp 2
\fBFT_NTOW()
Translate numeric value to words
.in 0i
.br
\l'6.24i'
.br
.sp
.in 0.08i
\fBSyntax
.sp
.in 0.4i
\fBFT_NTOW( <nNumber> ) -> cWords
.sp
.in 0.08i
\fBArguments
.sp
.in 0.4i
.ta 0.88i
\fB<nNumber>\fR An integer to translate
.br
.ta
.sp
.in 0.08i
\fBReturns
.sp
.in 0.4i
A text string representing <nNumber>
.sp
.in 0.08i
\fBDescription
.sp
.in 0.48i
Translates numeric input to a text string\.
.sp
FT_NTOW is intended to be used with integers only\. Since I don\'t
know what your application will be, I can\'t assume the type of
fraction you want returned (ninety nine cents, 99/100, \.99, etc)\.
If you want the fraction in words, just pass it as an integer\.
.sp
.ta 2.56i
Do not pass a negative number! Handle negative numbers any way
.br
.ta
you need to in your code\. (ie: CR, DB, Negative, Minus, etc\.)
.sp
Also, numeric 0 is returned as a null string\. You will need to
make a decision how to output it (zero dollars, no dollars, etc)\.
.sp
.in 0.08i
\fBExamples
.sp
.in 1.28i
.ta 2.56i
? FT_NTOW( 999 ) -> Nine Hundred Ninety Nine
.br
.ta
.sp
.ta 2.56i
? FT_NTOW( 1000 ) -> One Thousand
.br
.ta
.sp
? FT_NTOW( 23 ) + " Dollars and " + FT_NTOW( 99 ) + " Cents"
.in 1.92i
-> Twenty Three Dollars and Ninety Nine Cents
.sp
.in 1.28i
? FT_NTOW( 23 ) + " Dollars and " + "99/100"
.in 1.92i
-> Twenty Three Dollars and 99/100
.sp
.in 0.32i
.ta 0.56i
x := -23\.99
.br
.ta
.ta 0.56i
cents := str( (x - int( x )) * 100, 2, 0 ) + "/100"
.br
.ta
.in 1.28i
.ta 0.56i
x := int( x )
.br
.ta
.in 0.32i
string := iif( x < 0, "Credit of ", "Debit of " )
.in 1.28i
? string + FT_NTOW( abs(x) ) + " Dollars and " + "99/100"
.in 1.68i
-> Credit of Twenty Three Dollars and 99/100
.sp
.in 0.08i
\fBSource:\fR NTOW\.PRG
.sp
\fBAuthor:\fR Gary Baren
.in 0i
.ta 1.63265i
.sp 2
.ne 20
.ps +3
.vs +3
FT_SQZN() Compress a numeric value into a character string
.br
.ta
.in 0.08i
.ps -3
.vs -3
.sp 2
\fBFT_SQZN()
Compress a numeric value into a character string
.in 0i
.br
\l'6.24i'
.br
.sp
.in 0.08i
\fBSyntax
.sp
.in 0.4i
\fBFT_SQZN( <nValue> [, <nSize> [, <nDecimals> ] ] ) -> cCompressed
.sp
.in 0.08i
\fBArguments
.sp
.in 0.4i
.ta 1.04i
nValue - The numeric value to be compressed
.br
.ta
.ta 1.04i
nSize - Optional size of numeric field, defaults to 10
.br
.ta
.ta 1.04i
nDecimals - Optional number of decimal places, defaults to 0
.br
.ta
.sp
.in 0.08i
\fBReturns
.sp
.in 0.4i
.ta 1.04i
cCompressed - Compressed string, 50% the size of nSize
.br
.ta
.sp
.in 0.08i
\fBDescription
.sp
.sp
.in 0.32i
The FT_SQZN function allows a numeric value to be compressed when
stored in the database\. The compression is 50% the storage space
of the original number\. The companion function, FT_UNSQZN returns
the original number from the compressed string\.
.sp
.sp
.in 0.08i
\fBExamples
.sp
.sp
.in 0.16i
replace TRANS->cust_id with FT_SQZN(mcust_id,8),;
.in 0.8i
.ta 1.2i
TRANS->amount with FT_SQZN(mamount,12,2)
.br
.ta
.sp
.sp
.in 0.08i
\fBSource:\fR SQZN\.PRG
.sp
\fBAuthor:\fR Joseph D\. Booth, Sr\.
.in 0i
.sp
.in 1.5i
.ti -1.5i
.ta 1.5i
.ft B
See Also:
.ft R
FT_UNSQZN()
.ta 1.63265i
.in 0i
.sp 2
.ne 20
.ps +3
.vs +3
FT_STOD() Convert a date string to a Clipper date data type
.br
.ta
.in 0.08i
.ps -3
.vs -3
.sp 2
\fBFT_STOD()
Convert a date string to a Clipper date data type
.in 0i
.br
\l'6.24i'
.br
.sp
.in 0.08i
\fBSyntax
.sp
.in 0.4i
\fBFT_STOD( <cDateStr> ) -> dDateType
.sp
.in 0.08i
\fBArguments
.sp
.in 0.4i
\fB<cDateStr>\fR is a Clipper string in the format "CCYYMMDD"\.
.sp
.in 0.08i
\fBReturns
.sp
.in 0.4i
A Clipper date type\.
.sp
.in 0.08i
\fBDescription
.sp
.in 0.4i
This function allows the programmer to hard code a date into the
program without knowing what the current date type is\. This
function is the converse of the Clipper DTOS() function\.
.sp
.in 0.08i
\fBExamples
.sp
.in 0.4i
.br
LOCAL dMyDate
.br
dMyDate := FT_STOD( "19901127" )
.sp
.in 0.08i
\fBSource:\fR STOD\.C
.sp
\fBAuthor:\fR Clayton Neff
.in 0i
.ta 1.63265i
.sp 2
.ne 20
.ps +3
.vs +3
FT_UNSQZN() Uncompress a numeric compressed by FT_SQZN()
.br
.ta
.in 0.08i
.ps -3
.vs -3
.sp 2
\fBFT_UNSQZN()
Uncompress a numeric compressed by FT_SQZN()
.in 0i
.br
\l'6.24i'
.br
.sp
.in 0.08i
\fBSyntax
.sp
.in 0.4i
\fBFT_UNSQZN( <cCompressed>, <nSize> [, <nDecimals> ] ) -> nValue
.sp
.in 0.08i
\fBArguments
.sp
.in 0.4i
.ta 1.2i
\fB<cCompressed>\fR - Compressed string, obtained from FT_SQZN()
.br
.ta
.sp
.ta 1.2i
\fB<nSize>\fR - Size of numeric field
.br
.ta
.sp
.ta 1.2i
\fB<nDecimals>\fR - Optional number of decimal places
.br
.ta
.sp
.in 0.08i
\fBReturns
.sp
.in 0.4i
.ta 1.04i
nValue - Uncompressed numeric value
.br
.ta
.sp
.in 0.08i
\fBDescription
.sp
.sp
.in 0.32i
The FT_UNSQZN function returns the numeric value from the compressed
string\. The compression is 50% the storage space of the original
number\. The original number must have been compressed using the
FT_SQZN() function\.
.sp
This function, along with FT_SQZN() can be used to reduce disk storage
requirements for numeric fields in a database file\.
.sp
.sp
.in 0.08i
\fBExamples
.sp
.sp
.in 0.32i
.br
mcust_id := FT_UNSQZN(TRANS->cust_id,8),;
.ta 0.72i
.br
mamount := FT_UNSQZN(TRANS->amount,12,2)
.br
.ta
.sp
.sp
.in 0.08i
\fBSource:\fR SQZN\.PRG
.sp
\fBAuthor:\fR Joseph D\. Booth, Sr\.
.in 0i
.sp
.in 1.5i
.ti -1.5i
.ta 1.5i
.ft B
See Also:
.ft R
FT_SQZN()
.ta 1.63265i
.in 0i
.sp 2
.ne 20
.ps +3
.vs +3
FT_XTOY() Convert from any data type to any other data type
.br
.ta
.in 0.08i
.ps -3
.vs -3
.sp 2
\fBFT_XTOY()
Convert from any data type to any other data type
.in 0i
.br
\l'6.24i'
.br
.sp
.in 0.08i
\fBSyntax
.sp
.in 0.4i
\fBFT_XTOY( <xValueToConvert>, <cTypeToConvertTo> ;
.in 1.12i
\fB[, <lWantYesNo> ] ) -> xResult
.sp
.in 0.08i
\fBArguments
.sp
.in 0.4i
\fB<xValueToConvert>\fR is the value to convert\.
.sp
\fB<cTypeToConvertTo>\fR is the type of value to convert to
("C","D","L","N","A" or "B")\.
.sp
\fB<lWantYesNo>\fR is a logical to signal if \'Y\' or \'N\' is to be returned
if Converting a logical, otherwise \'\.T\.\' or \'\.F\.\' will be returned
for logicals\.
.sp
.in 0.08i
\fBReturns
.sp
.in 0.4i
The original value converted to the new type\.
.sp
.in 0.08i
\fBDescription
.sp
.in 0.4i
This function converts a value of character, date, numeric, logical,
array or code block type to any of the other type\. While it is
guaranteed to return a value of the correct type, that value may not
be meaningful (i\.e\., converting from a code block returns an EMPTY()
value of the desired type)\.
.sp
.in 0.08i
\fBExamples
.sp
.in 0.4i
.br
nNumericValue := FT_XTOY(cInputValue, "N")
.br
IF (FT_XTOY(nInputValue, "L"))
.sp
.in 0.08i
\fBSource:\fR ANY2ANY\.PRG
.sp
\fBAuthor:\fR David Husnian