Contributed samples and applications by Dr. Claudio Soto
A simple way to modify the cursor …
Bin2I | Convert signed short encoded bytes into Harbour numeric |
Bin2L | Convert signed long encoded bytes into Harbour numeric |
Bin2U | Convert unsigned long encoded bytes into Harbour numeric |
Bin2W | Convert unsigned short encoded bytes into Harbour numeric |
BitToC | Converts position-dependent bits into characters |
BinToDec | Converts a Binary Value to Decimal |
CToBit | Converts a character string into a bit pattern |
CToF | Converts a special 8-byte string into a floating point number |
CToN | Converts a numeric string into a different base |
DecToBin | Converts a Decimal Value to Binary |
DecToHexa | Converts a Decimal Value to Hexa |
DecToOctal | Converts a Decimal Value to Octal |
Fahrenheit | Temperature conversion Celsius to Fahrenheit |
FToC | Converts a floating point number into a special 8-byte string |
HexaToDec | Converts a Hexa Value to Decimal |
I2Bin | Convert Harbour numeric into signed short encoded bytes |
L2Bin | Convert Harbour numeric into signed long encoded bytes |
NToC | Converts the numbers in a digit string into a different number base |
OctalToDec | Converts a Octal Value to Decimal |
U2Bin | Convert Harbour numeric into unsigned long encoded bytes |
W2Bin | Convert Harbour numeric into unsigned short encoded bytes |
Word | Converts double to integer values |
XTOC | Convert an expression to character type string |
WGT_MEAS() Short: ------ WGT_MEAS() A Weights and Measures conversion metafunction Returns: -------- Nothing Syntax: ------- WGT_MEAS() Description: ------------ WGT_MEAS() is a menu driven Weights and Measure conversion utility, which supports many types of conversions. Examples: --------- WGT_MEAS() Source: ------- S_MEAS.PRG
FT_XTOY() Convert from any data type to any other data type Syntax FT_XTOY( <xValueToConvert>, <cTypeToConvertTo> ; [, <lWantYesNo> ] ) -> xResult Arguments <xValueToConvert> is the value to convert. <cTypeToConvertTo> is the type of value to convert to ("C","D","L","N","A" or "B"). <lWantYesNo> 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. Returns The original value converted to the new type. Description 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). Examples nNumericValue := FT_XTOY(cInputValue, "N") IF (FT_XTOY(nInputValue, "L")) Source: ANY2ANY.PRG Author: David Husnian
FT_UNSQZN() Uncompress a numeric compressed by FT_SQZN() ------------------------------------------------------------------------------ Syntax FT_UNSQZN( <cCompressed>, <nSize> [, <nDecimals> ] ) -> nValue Arguments <cCompressed> - Compressed string, obtained from FT_SQZN() <nSize> - Size of numeric field <nDecimals> - Optional number of decimal places Returns nValue - Uncompressed numeric value Description 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. This function, along with FT_SQZN() can be used to reduce disk storage requirements for numeric fields in a database file. Examples mcust_id := FT_UNSQZN(TRANS->cust_id,8),; mamount := FT_UNSQZN(TRANS->amount,12,2) Source: SQZN.PRG Author: Joseph D. Booth, Sr.
See Also: FT_SQZN()
FT_STOD() Convert a date string to a Clipper date data type Syntax FT_STOD( <cDateStr> ) -> dDateType Arguments <cDateStr> is a Clipper string in the format "CCYYMMDD". Returns A Clipper date type. Description 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. Examples LOCAL dMyDate dMyDate := FT_STOD( "19901127" ) Source: STOD.C Author: Clayton Neff
FT_SQZN() Compress a numeric value into a character string Syntax FT_SQZN( <nValue> [, <nSize> [, <nDecimals> ] ] ) -> cCompressed Arguments nValue - The numeric value to be compressed nSize - Optional size of numeric field, defaults to 10 nDecimals - Optional number of decimal places, defaults to 0 Returns cCompressed - Compressed string, 50% the size of nSize Description 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. Examples replace TRANS->cust_id with FT_SQZN(mcust_id,8),; TRANS->amount with FT_SQZN(mamount,12,2) Source: SQZN.PRG Author: Joseph D. Booth, Sr.
FT_NTOW() Translate numeric value to words Syntax FT_NTOW( <nNumber> ) -> cWords Arguments <nNumber> An integer to translate Returns A text string representing <nNumber> Description Translates numeric input to a text string. 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. Do not pass a negative number! Handle negative numbers any way you need to in your code. (ie: CR, DB, Negative, Minus, etc.) 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). Examples ? FT_NTOW( 999 ) -> Nine Hundred Ninety Nine ? FT_NTOW( 1000 ) -> One Thousand ? FT_NTOW( 23 ) + " Dollars and " + FT_NTOW( 99 ) + " Cents" -> Twenty Three Dollars and Ninety Nine Cents ? FT_NTOW( 23 ) + " Dollars and " + "99/100" -> Twenty Three Dollars and 99/100 x := -23.99 cents := str( (x - int( x )) * 100, 2, 0 ) + "/100" x := int( x ) string := iif( x < 0, "Credit of ", "Debit of " ) ? string + FT_NTOW( abs(x) ) + " Dollars and " + "99/100" -> Credit of Twenty Three Dollars and 99/100 Source: NTOW.PRG Author: Gary Baren
FT_INVCLR() Get the inverse of a color ------------------------------------------------------------------------------ Syntax FT_INVCLR( [ <cDsrdColor> ] ) -> cColor Arguments <cDsrdColor> is the color to get the inverse of. Defaults to current color. Returns The inverse of the passed color. Description This function inverts a passed color (in the Clipper format: ??/??), e.g., "W/N" is converted to "N/W". Examples cInverse := FT_INVCLR() // Get Inverse of Current Color cInvErr := FT_INVCLR( cErrColor ) // Get Inverse of cErrorColor Source: INVCLR.PRG Author: David Husnian