ADDSLASHES() | Returns string with slashes (\). |
ALLTRIM() | Remove leading and trailing spaces from a character string |
ASC() | Convert a character to its ASCII value |
AT() | Return the position of a substring within a character string |
BETWEEN() | Check value. |
BUNZIP2() | Uncompress string with BZIP2 alghoritm. |
BZIP2() | Compress string with bZIP2 alghoritm. |
CHR() | Convert an ASCII code to a character value |
CSCOUNT() | Returns the number specified chars into source string. |
DSTRTON() | Convert string as "double" to xClipper-numeric. |
EMPTY() | Determine if the result of an expression is empty |
FSTRTON() | Convert string as "float" to xClipper-numeric. |
FT_AT2() | Find position of the nth occurrence of a substring |
FT_BITCLR() | Clear (reset) selected bit in a byte |
FT_BITSET() | Set selected bit in a byte |
FT_BYTEAND() | Perform bit-wise AND on two ASCII characters (bytes) |
FT_BYTENEG() | Perform bit-wise negation on an ASCII character |
FT_BYTENOT() | Perform bit-wise NOT on an ASCII character (byte) |
FT_BYTEOR() | Perform bit-wise OR on two ASCII characters (bytes) |
FT_BYTEXOR() | Perform bit-wise XOR on two ASCII characters (bytes) |
FT_FINDITH() | Find the "ith" occurrence of a substring within a string |
FT_ISBIT() | Test the status of an individual bit |
FT_ISBITON() | Determine the state of individual bits in a number |
FT_METAPH() | Convert a character string to MetaPhone format |
FT_NOOCCUR() | Find the number of times one string occurs in another |
FT_PCHR() | Convert printer control codes |
GLOB() | Check confirmity string to regular expression. |
GUNZIP() | Uncompress string with GZIP alghoritm. |
GZIP() | Compress string with GZIP alghoritm. |
HARDCR() | Replace all soft carriage returns in a character string with hard carriage |
HASHNAME() | Returns string from hash values. |
HASHSTR() | Returns hash code for string. |
ISALPHA() | Determine if the leftmost character in a string is alphabetic |
ISDIGIT() | Determine if the leftmost character in a character string is a digit |
ISLOWER() | Determine if the leftmost character is a lowercase letter |
ISUPPER() | Determine if the leftmost character in a string is uppercase |
LEFT() | Extract a substring beginning with the first character in a string |
LEN() | Return the length of a character string or the number of elements in an array |
LIKE() | Check confirmity string to simple mask. |
LOWER() | Convert uppercase characters to lowercase |
LTRIM() | Remove leading spaces from a character string |
MEMOEDIT() | Display or edit character strings and memo fields |
MEMOLINE() | Extract a line of text from a character string or memo field |
MEMOREAD() | Return the contents of a disk file as a character string |
MEMOTRAN() | Replace carriage return/linefeeds in character strings |
MEMOWRIT() | Write a character string or memo field to a disk file |
MLCOUNT() | Count the number of lines in a character string or memo field |
MLCTOPOS() | Return the byte position of a formatted string based on line and column |
MLPOS() | Determine the position of a line in a character string or memo field |
MPOSTOLC() | Return line and column position of a formatted string based on a specified |
PAD() | Pad character, date, and numeric values with a fill character |
QOUT() | Display a list of expressions to the console |
RAT() | Return the position of the last occurrence of a substring |
REPLICATE() | Return a string repeated a specified number of times |
RIGHT() | Return a substring beginning with the rightmost character |
RTRIM() | Remove trailing spaces from a character string |
SEARCH() | Search a substring into string by regular expression. |
SOUNDEX() | Convert a character string to "soundex" form |
SPACE() | Return a string of spaces |
STR() | Convert a numeric expression to a character string |
STR2VAR() | Convert uucode string to data. |
STRTRAN() | Search and replace characters within a character string or memo field |
STUFF() | Delete and insert characters in a string |
SUBSTR() | Extract a substring from a character string |
TRANSFORM() | Convert any value into a formatted character string |
TRIM() | Remove trailing spaces from a character string |
TYPE() | Determine the type of an expression |
UPPER() | Convert lowercase characters to uppercase |
VAL() | Convert a character number to numeric type |
VALTYPE() | Determine the data type returned by an expression |
VAR2STR() | Convert data to uucode string. |
WEIGHTASC() | Returns the weight characterics of character. |
WEIGHTTABLE() | Returns the weight table of characters. |
ADDSLASHES(<sString>) --> <sResString>
ADDSLASHES() returns string with backward slashes (\).
ADDSLASHES() returns a string <sResString> with backslashes before characters that need to be quoted in database queries etc. These characters are single quote ('), double quote ("), backslash (\) and NUL (the null byte).
str := "Name='Ann'" ADDSLASHES(str) // --> Name=\'Ann\'
No dependies of platform.
ALLTRIM(<cString>) --> cTrimString
ALLTRIM() returns a character string with leading and trailing spaces removed.
ALLTRIM() is a character function that removes both leading and trailing spaces from a string. It is related to LTRIM() and RTRIM() which remove leading and trailing spaces, respectively. The inverse of ALLTRIM(), LTRIM(), and RTRIM() are the PADC(), PADL(), and PADR() functions which center, left-justify, or right-justify character strings by padding them with fill characters.
This example creates a string with both leading and trailing spaces, and then trims them with ALLTRIM(): cString := SPACE(10) + "string" + SPACE(10) ? LEN(cString) // Result: 26 ? LEN(ALLTRIM(cString)) // Result: 6
ASC(<cExp>) --> nCode
ASC() returns an integer numeric value in the range of zero to 255, representing the ASCII value of <cExp>.
ASC() is a character conversion function that returns the ASCII value of the leftmost character in a character string. ASC() is used primarily on expressions requiring numeric calculations on the ASCII value of a character. CHR() and ASC() are inverse functions.
These examples illustrate various results of ASC(): ? ASC("A") // Result: 65 ? ASC("Apple") // Result: 65 ? ASC("a") // Result: 97 ? ASC("Z") - ASC("A") // Result: 25 ? ASC("") // Result: 0
AT(<cSearch>, <cTarget>) --> nPosition
AT() returns the position of the first instance of <cSearch> within <cTarget> as an integer numeric value. If <cSearch> is not found, AT() returns zero.
AT() is a character function used to determine the position of the first occurrence of a character substring within another string. If you only need to know whether a substring exists within another string, use the $ operator. To find the last instance of a substring within a string, use RAT().
These examples show typical use of AT(): ? AT("a", "abcde") // Result: 1 ? AT("bcd", "abcde") // Result: 2 ? AT("a", "bcde") // Result: 0 This example splits a character string based on the position of a comma within the target string: cTarget := "Langtree, Lilly" ? SUBSTR(cTarget, 1, AT(",", cTarget) - 1) // Result: Langtree ? SUBSTR(cTarget, AT(",", cTarget) + 2) // Result: Lilly
BETWEEN(<TargetData>, <FirstData>, <SecondData>) --> TRUE || FALSE
Returns TRUE if <TargetData> is located berween <FirstData> and <SecondData>.
BETWEEN() compares source value <TargetData> with <FirstData> and <SecondData>. If <TargetData> locate between <FirstData> and <SecondData>, BETWEEN() returns TRUE.
All values must be ones type (string, numeric, date, ...).
val := 12345 BETWEEN(val, 0, 99999) // --> TRUE BETWEEN(val, 99999, 0) // --> TRUE BETWEEN(val, 9999, 0) // --> FALSE
No dependies of platform.
CHR(<nCode>) --> cChar
CHR() returns a single character value whose ASCII code is specified by <nCode>.
CHR() is a numeric conversion function that converts an ASCII code to a character. It is the inverse of ASC(). CHR() serves a number of common tasks including:
Sending control codes and graphics characters to the screen or printer
Ringing the bell
Converting INKEY() return values to characters
Stuffing the keyboard buffer
These examples illustrate CHR() with various arguments: ? CHR(72) // Result: H ? CHR(ASC("A") + 32) // Result: a ? CHR(7) // Result: bell sounds These lines of code show the difference between a null string and the null character: ? LEN("") // Result: 0 ? LEN(CHR(0)) // Result: 1
CSCOUNT(<ÓChar>, <sString>) --> <nCount>
Returns the number of character <cChar> into source string <sString>.
CSCOUNT() returns the number of character <cChar> into source string <sString>.
CSCOUNT("s", "substr") // --> 2 CSCOUNT("a", "substr") // --> 0
No dependies of platform.
DSTRTON(<sString>) --> <nValue>
Returns the numeric value, what was converted from string with "double" representation.
DSTRTON() converts string <sString> to numeric values and returns it.
fread(file,@str,8)<BR> n=DSTRTON(str)
No dependies of platform.
FSTRTON(<sString>) --> <nValue>
Returns the numeric value, what was converted from string with "float" representation.
FSTRTON() converts string <sString> to numeric values and returns it.
fread(file,@str,8)<BR> n=FSTRTON(str)
No dependies of platform.
FT_AT2( <cSearch>, <cTarget> [, <nOccurs> [, <lCaseSens> ] ] ) -> nPos
The position of the nth occurrence of a substring
This function will find the nth occurrence of a substring within a string.
cSearch := "t" cTarget := "This is the day that the Lord has made." FT_AT2( cSearch, cTarget ) // Returns ( 9 ) FT_AT2( cSearch, cTarget, 2 ) // Returns ( 17 ) FT_AT2( cSearch, cTarget, 2, .F. ) // Returns ( 9 )
FT_BITCLR( <cByte>, <nBitPos> ) -> cByte
Returns new byte, with designated bit cleared (reset). If parameters are faulty, returns NIL.
In effect, ANDs argument byte with a byte that has all bits set except the target bit. If bit is already clear (0), it remains clear. Note: Calls FT_ISBIT() which is also in this Library.
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.
This code would clear bit 4 in a byte represented by CHR(115): cNewByte := FT_BITCLR( CHR(115), 4 ) ? ASC( cNewbyte ) // result: 99 ? cNewByte // result: 'c' This code would clear bit 5 in the byte represented by letter 'A': FT_BITCLR( 'A', 5 ) // result: 'A', since // bit 5 already clear For a demonstration of Clipper bit manipulations, compile and link the program BITTEST.PRG in the Nanforum Toolkit source code.
FT_BITSET( <cByte>, <nBitPos> ) -> cByte
Returns new byte, with designated bit set. If parameters are faulty, returns NIL.
In effect, ORs argument byte with a byte that has only the target bit set. If bit is already set, it remains set. Note: Calls FT_ISBIT() which is also in this Library.
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.
This code would set bit 4 in a byte represented by CHR(107): cNewbyte := FT_BITSET( CHR(107), 4 ) ? ASC( cNewbyte ) // result: 123 ? cNewbyte // result: '{' This code would set bit 5 in the byte represented by the letter 'A'. ? FT_BITSET( 'A', 5 ) // result: 'a' // bit 5 set For a demonstration of Clipper bit manipulations, compile and link the program BITTEST.PRG in the Nanforum Toolkit source code.
FT_BYTEAND( <cByte1>, <cByte2> ) -> cByte
Returns resulting byte, in CHR() form. If parameters are faulty, returns NIL.
Can be used for any bit-wise masking operation. In effect, this is a bit-by-bit AND operation. Equivalent to AND assembler instruction.
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.
This code would mask out the high nibble (four most significant bits) of the byte represented by chr(123) and leave the low nibble bits as in the parameter byte. cNewbyte := FT_BYTEAND( CHR(123), CHR(15) ) ? asc(cNewByte) // result: 11 ? cNewByte // result: non-printable character For a demonstration of Clipper bit manipulations, compile and link the program BITTEST.PRG in the Nanforum Toolkit source code.
FT_BYTENEG( <cByte> ) -> cNewByte
Returns resulting byte, in CHR() form. If parameters are faulty, returns NIL.
Can be used for bit-wise byte manipulation. In effect, this is a bit-by-bit NEG (two's complement) operation. Equivalent to NEG assembler instruction.
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.
This code performs a bit-wise NEG on byte represented by CHR(32): cNewByte := FT_BYTENOT(CHR(32)) ? asc(cNewByte) // result: 224 For a demonstration of Clipper bit manipulations, compile and link the program BITTEST.PRG in the Nanforum Toolkit source code.
FT_BYTENOT( <cByte> ) -> cNewByte
Returns resulting byte, in CHR() form. If parameters are faulty, returns NIL.
Can be used for bitwise byte manipulation. In effect, this is a bit-by-bit NOT (one's complement) operation. Equivalent to the NOT assembler instruction.
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.
This code performs a bitwise NOT on byte represented by CHR(32): cNewByte := FT_BYTENOT( CHR(32) ) ? ASC( cNewByte ) // result: 223 For a demonstration of Clipper bit manipulations, compile and link the program BITTEST.PRG in the Nanforum Toolkit source code.
FT_BYTEOR( <cByte1>, <cByte2> ) -> cNewByte
Returns resulting byte, in CHR() form. If parameters are faulty, returns NIL.
Can be used for bit-wise byte manipulation. In effect, this is a bit-by-bit OR operation. Equivalent to OR assembler instruction.
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.
This code performs a bit-wise OR on two bytes represented by CHR(20) and CHR(10): cNewByte := FT_BYTEOR( CHR(20), CHR(10) ) ? ASC( cNewByte ) // result: 30 ? cNewByte // result: non-printable character For a demonstration of Clipper bit manipulations, compile and link the program BITTEST.PRG in the Nanforum Toolkit source code.
FT_BYTEXOR( <cByte1>, <cByte2> ) -> cNewByte
Returns resulting byte, in CHR() form. If parameters are faulty, returns NIL.
Can be used for bit-wise byte manipulation. In effect, this is a bit-by-bit XOR operation. Equivalent to XOR assembler instruction.
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.
This code performs a bit-wise XOR on two bytes represented by CHR(32) and CHR(55): cNewByte := FT_BYTEXOR( CHR(32), CHR(55) ) ? ASC( cNewByte ) // result: 23 ? cNewByte // result: non-printable character For a demonstration of Clipper bit manipulations, compile and link the program BITTEST.PRG in the Nanforum Toolkit source code.
FT_FINDITH( <cCheckFor>, <cCheckIn>, <nWhichOccurrence> ; [, <lIgnoreCase> ] ) -> <nStringPosition>
The position in the string cCheckIn of the ith occurrence of cCheckFor.
This function finds the position in a string of the "ith" time another string appears in it.
// Find the Position in cMemoString of // the 10th Occurrence of "the", case // insensitive nNextPosition := FT_FINDITH("the", cMemoString, 10)
FT_ISBIT( <cByte>, <nBitPos> ) -> lResult
.T. if designated bit is set (1), .F. if not set (0), NIL if invalid parameters.
Tests for status of any selected bit in the byte passed as a parameter. Byte must be presented in CHR() form, as a literal constant, or as the one-byte character result of an expression.
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.
This code tests whether bit 3 is set in the byte represented by CHR(107): lBitflag := FT_ISBIT(CHR(107), 3) ? lBitflag // result: .T. This code tests whether bit 5 is set in the byte represented by ASCII 65 (letter 'A') ? FT_ISBIT('A', 5) // result: .F. For a demonstration of Clipper bit manipulations, compile and link the program BITTEST.PRG in the Nanforum Toolkit source code.
FT_ISBITON( <nNumber>, <nBit> ) -> lResult
.T. if the specified bit was on., .F. if off.
This function is useful when dealing with binary integers. It will come in very handy if you use the FT_INT86() function, because the CPU flags are returned as a series of bits. Using this function, you can determine the state of each CPU flag.
if FT_ISBITON( nCPUFlags, 0 ) Qout( "The carry flag was set." ) endif if FT_ISBITON( nCPUFlags, 7 ) Qout( "The sign flag was set." ) endif
FT_METAPH( <cName> [, <nSize> ] ) -> cMetaPhone
A phonetically spelled character string
This function is a character function use to index and search for sound-alike or phonetic matches. It is an alternative to the SOUNDEX() function, and addresses some basic pronunciation rules, by looking at surrounding letters to determine how parts of the string are pronounced. FT_METAPH() will group sound-alikes together, and forgive shortcomings in spelling ability.
USE Persons INDEX ON FT_METAPH( LastName ) TO LastName SEEK FT_METAPH( "Philmore" ) ? FOUND(), LastName // Result: .T. Philmore SEEK FT_METAPH( "Fillmore" ) ? FOUND(), LastName // Result: .T. Philmore
FT_NOOCCUR( <cCheckFor>, <cCheckIn> ; [, <lIgnoreCase> ] ) -> <nOccurrences>
The number of times <cCheckFor> appears in <cCheckIn>
This function finds the number of times a string occurs in a second string.
// Find the number of times "the" appears in cMemoString, case // insensitive nNoOfOccurrences := FT_NOOCCUR( "the", cMemoString ) // Find the number of times "the" appears in cMemoString, case // sensitive nNoOfOccurrences := FT_NOOCCUR( "the", cMemoString, TRUE )
FT_PCHR( <cString> ) -> <cPrinterFormat>
A character string of printer control codes.
This function is useful for allowing the user to enter printer control codes in text (enclosed in double quotes), numeric, hexadecimal, or Epson commands preceded by a slash and returns the printer control code equivalent.
NOTES"
- Combinations of text, numbers, hex, and commands must be separated by commas ("A",27,&1B,/RESET). - Text must be enclosed in double quotes ("x"). - Hexadecimal must be preceded by an ampersand (&1B). - Epson commands, listed below, must be preceded by a forward slash (/RESET).
Epson commands: (slash commands are specific to the Epson)
Job Control:
/RESET or /INIT Reset or initialize the printer /BELL or /BEEP Cause the printer's speaker to beep (not HS) /CAN Clear print buffers (not MX) /SLOW Set low speed mode (not CR, HS, MX) /FAST Cancel low speed mode (not CR, HS, MX) /ONE Select Unidirectional mode /TWO Select Directional mode /ON Activate printer /OFF Turn off printer
/FF or /EJECT Form Feed
Page Control:
/1/6 Set 6 lines per inch /1/8 Set 8 lines per inch /SKIP Set Skip perforation ON /SKIPOFF Set Skip perforation OFF
Font Selection and Manipulation:
/ITALIC Select italic char. set (only FX86, EX, LX, no LQ-1500, SX) /GRAPHIC Select graphic char. set (only FX86, EX, LX, no LQ-1500, SX) /ROMAN Choose Roman font /SANS Choose Sans Serif font /DRAFT Choose draft /NLQ Choose near letter quality /PICA Choose 10 chars per inch /ELITE Choose 12 chars per inch /COND or /SI Choose 15 chars per inch /EMPH Turn emphasize on /EMPHOFF Turn emphasize off /SPANISH Select spanish international char set /USA Select USA international char set
cSetUp := '27,116,1' Set Print ON ? FT_PCHR( cSetUp ) -> (CHR(27)+CHR(116)+CHR(1)) <select Epson char. graphics> ? FT_PCHR( '27,"x",0' ) -> (CHR(27)+CHR(120)+CHR(0)) <Epson draft mode> ? FT_PCHR( '&1B,"E"' ) -> (CHR(27)+CHR(69)) <HP reset> ? FT_PCHR( '/ELITE,/NLQ' ) ->(CHR(27)+CHR(77)+CHR(27)+CHR(120)+CHR(1)) <Epson elite & near letter quality>
GLOB(<sString>, <sReg>, [<lIgnoreCase>]) --> TRUE || FALSE
Returns TRUE if string corresponding to regular expression.
GLOB() returns TRUE if string corresponding to regular expression. The expression <sReg> is the simple regular expression by DOS rules.
? GLOB("aaa", "aaa") // --> TRUE ? GLOB("aaa", "[a-z]*") // --> TRUE ? GLOB("aaa", "a*") // --> TRUE ? GLOB("aaa", "*") // --> TRUE ? GLOB("aaa", "a") // --> FALSE ? GLOB("", "a") // --> FALSE ? GLOB("", "*") // --> TRUE
No dependies of platform.
HARDCR(<cString>) --> cConvertedString
HARDCR() returns a character string up to 65,535 (64K) characters in length.
HARDCR() is a memo function that replaces all soft carriage returns (CHR(141)) with hard carriage returns (CHR(13)). It is used to display long character strings and memo fields containing soft carriage returns with console commands. In xClipper, console commands (including REPORT and LABEL FORM) do not automatically convert soft carriage returns to hard carriage returns, making it necessary for you to explicitly make the conversion. Soft carriage returns are added by MEMOEDIT() when lines wrap.
To display a memo field formatted with the automatic word wrapping of MEMOEDIT(): USE Sales NEW ? HARDCR(Sales->Notes)
HASHNAME(<nHashCode>) --> <sStr>
Returns the string, from what was converted hash code.
HASHNAME() returns sources string for hash code <nHashCode>.
HASHSTR("asdf") // --> 1886203041 HASHNAME(1886203041) // --> asdf
HASHSTR(<sStr>) --> <nHashCode>
Returns the numeric value - hash code, what was converted from string.
HASHSTR() calulates hash code from string <sStr> and returns it as numeric value <nHashCode>. Hash code has unique values into range of 1000000 to MAX_LONG.
HASHSTR("asdf") // --> 1886203041 HASHSTR("ASDF") // --> 1190707477 HASHSTR("aSdF") // --> 1934510729
ISALPHA(<cString>) --> lBoolean
ISALPHA() returns true (.T.) if the first character in <cString> is alphabetic; otherwise, it returns false (.F.).
ISALPHA() is a character function that determines if the specified string begins with an alphabetic character. An alphabetic character consists of any uppercase or lowercase letter from A to Z. ISALPHA() returns false (.F.) if the string begins with a digit or any other character.
These examples demonstrate various results of ISALPHA(): ? ISALPHA("AbcDe") // Result: .T. ? ISALPHA("aBcDE") // Result: .T. ? ISALPHA("1BCde") // Result: .F. ? ISALPHA(".FRED") // Result: .F.
ISDIGIT(<cString>) --> lBoolean
ISDIGIT() returns true (.T.) if the first character of the character string is a digit between zero and nine; otherwise, it returns false (.F.).
ISDIGIT() is a character function that determines whether the first character in a string is a numeric digit between zero and nine. If any other character is the first character of the <cString>, ISDIGIT() returns false (.F.).
ISDIGIT() is useful where you need to know if the current character string is a number before converting it to a numeric value with the VAL() function.
These examples demonstrate various results of ISDIGIT(): ? ISDIGIT("AbcDe") // Result: .F. ? ISDIGIT("1abcd") // Result: .T. ? ISDIGIT(".12345") // Result: .F.
ISLOWER(<cString>) --> lBoolean
ISLOWER() returns true (.T.) if the first character of the character string is a lowercase letter; otherwise, it returns false (.F.).
ISLOWER() is a character function that determines whether the first character of a character string is lowercase. It is the inverse of ISUPPER() which determines whether a character begins with an uppercase character.
Both ISLOWER() and ISUPPER() relate to the LOWER() and UPPER() functions which actually convert lowercase characters to uppercase, and vice versa.
These examples demonstrate various results of ISLOWER(): ? ISLOWER("aBcDe") // Result: .T. ? ISLOWER("AbcDe") // Result: .F. ? ISLOWER("1abcd") // Result: .F. ? ISLOWER("abcd") // Result: .T.
ISUPPER(<cString>) --> lBoolean
ISUPPER() returns true (.T.) if the first character is an uppercase letter; otherwise, it returns false (.F.).
ISUPPER() is a character function that determines whether the first character of a string is uppercase. It is the inverse of ISLOWER(). Both ISUPPER() and ISLOWER() relate to the UPPER() and LOWER() functions which actually convert uppercase characters to lowercase, and vice versa.
These examples illustrate ISUPPER() applied to various values: ? ISUPPER("AbCdE") // Result: .T. ? ISUPPER("aBCdE") // Result: .F. ? ISUPPER("$abcd") // Result: .F. ? ISUPPER("8ABCD") // Result: .F.
LEFT(<cString>, <nCount>) --> cSubString
LEFT() returns the leftmost <nCount> characters of <cString> as a character string. If <nCount> is negative or zero, LEFT() returns a null string (""). If <nCount> is larger than the length of the character string, LEFT() returns the entire string.
LEFT() is a character function that returns a substring of a specified character string. It is the same as SUBSTR(<cString>, 1, <nCount>). LEFT() is also like RIGHT(), which returns a substring beginning with the last character in a string.
LEFT(), RIGHT(), and SUBSTR() are often used with both the AT() and RAT() functions to locate the first and/or the last position of a substring before extracting it.
This example extracts the first three characters from the left of the target string: ? LEFT("ABCDEF", 3) // Result: ABC This example extracts a substring from the beginning of a string up to the first occurrence of a comma: LOCAL cName := "James, William" ? LEFT(cName, AT(",", cName) - 1) // Result: James
LIKE(<sMask>, <sString>) --> TRUE || FALSE
Returns TRUE if string corresponding to mask.
LIKE() returns TRUE if string corresponding to mask. The string <sMask> can contents special symbols: <?>, <*>, <.>
? LIKE("aaa", "aaa") // --> TRUE ? LIKE("aaa", "a*") // --> TRUE ? LIKE("aaa", "*") // --> TRUE ? LIKE("aaa", "a") // --> FALSE ? LIKE("", "a") // --> FALSE ? LIKE("", "*") // --> TRUE
No dependies of platform.
LOWER(<cString>) --> cLowerString
LOWER() returns a copy of <cString> with all alphabetic characters converted to lowercase. All other characters remain the same as in the original string.
LOWER() is a character function that converts uppercase and mixed case strings to lowercase. It is related to UPPER() which converts lowercase and mixed case strings to uppercase. LOWER() is related to the ISLOWER() and ISUPPER() functions which determine whether a string begins with a lowercase or uppercase letter.
LOWER() is generally used to format character strings for display purposes. It can, however, be used to normalize strings for case- independent comparison or INDEXing purposes.
These examples demonstrate various results of LOWER(): ? LOWER("STRING") // Result: string ? LOWER("1234 CHARS = ") // Result: 1234 chars =
LTRIM(<cString>) --> cTrimString
LTRIM() returns a copy of <cString> with the leading spaces removed. If <cString> is a null string ("") or all spaces, LTRIM() returns a null string ("").
LTRIM() is a character function that formats character strings with leading spaces. These can be, for example, numbers converted to character strings using STR().
LTRIM() is related to RTRIM(), which removes trailing spaces, and ALLTRIM(), which removes both leading and trailing spaces. The inverse of ALLTRIM(), LTRIM(), and RTRIM() are the PADC(), PADR(), and PADL() functions which center, right-justify, or left-justify character strings by padding them with fill characters.
These examples illustrate LTRIM() used with several other functions: nNumber = 18 ? STR(nNumber) // Result: 18 ? LEN(STR(nNumber)) // Result: 10 ? LTRIM(STR(nNumber)) // Result: 18 ? LEN(LTRIM(STR(nNumber))) // Result: 2
MEMOEDIT([<cString>], [<nTop>], [<nLeft>], [<nBottom>], [<nRight>], [<lEditMode>], [<cUserFunction>], [<nLineLength>], [<nTabSize>], [<nTextBufferRow>], [<nTextBufferColumn>], [<nWindowRow>], [<nWindowColumn>]) --> cTextBuffer
<cString> | is the character string or memo field to copy to the |
MEMOEDIT() text buffer. If not specified, the text buffer is empty. | |
<nTop> | , <nLeft>, <nBottom>, and <nRight> are the |
upper-left and lower-right window coordinates. Row values can range | |
from zero to MAXROW(), and column positions can range from zero to | |
MAXCOL(). If not specified, the default coordinates are 0, 0, MAXROW(), | |
and MAXCOL(). | |
<lEditMode> | determines whether the text buffer can be edited or |
merely displayed. Specifying true (.T.) allows the user to make changes | |
to the text buffer, while specifying false (.F.) only allows the user to | |
browse the text buffer. If not specified, the default value is true | |
(.T.). | |
<cUserFunction> | is the name of a user-defined function that executes |
when the user presses a key not recognized by MEMOEDIT() and when no | |
keys are pending in the keyboard buffer. <cUserFunction> is specified | |
as a character value without parentheses or arguments. Specifying false | |
(.F.) for this argument displays <cString> and causes MEMOEDIT() to | |
immediately terminate. If this argument is specified, the automatic | |
behavior of MEMOEDIT() changes. Refer to the discussion below. | |
<nLineLength> | determines the length of lines displayed in the |
MEMOEDIT() window. If a line is greater than <nLineLength>, it is word | |
wrapped to the next line in the MEMOEDIT() window. If <nLineLength> is | |
greater than the number of columns in the MEMOEDIT() window, the window | |
will scroll if the cursor moves past the window border. If | |
<nLineLength> | is not specified, the default line length is (<nRight> - |
<nLeft> | ). |
<nTabSize> | determines the tab stops that will be used when the user |
presses Tab. If <nTabSize> is not specified, tab stops will be placed | |
at every four characters. | |
<nTextBufferRow> | and <nTextBufferColumn> define the display |
position of the cursor within the text buffer when MEMOEDIT() is | |
invoked. <nTextBufferRow> begins with one (1) and <nTextBufferColumn> | |
begins with zero (0). If these arguments are not specified, the cursor | |
is placed at row one (1) and column zero (0) of the MEMOEDIT() window. | |
<nWindowRow> | and <nWindowColumn> define the initial position of |
the cursor within the MEMOEDIT() window. Row and column positions begin | |
with zero (0). If these arguments are not specified, the initial window | |
position is row zero (0) and the current cursor column position. |
MEMOEDIT() returns the text buffer if the user terminates editing with Ctrl+W or a copy of <cString> if user terminates with Esc.
MEMOLINE(<cString>,[<nLineLength>],[<nLineNumber>], [<nTabSize>],[<lWrap>]) --> cLine
<cString> | is the memo field or character string from which a line of |
text is to be extracted. | |
<nLineLength> | specifies the number of characters per line and can be |
between four and 254. If not specified, the default line length is 79. | |
<nLineNumber> | is the line number to be extracted. If not specified, |
the default value is one. | |
<nTabSize> | defines the tab size. If not specified, the default |
value is four. If <nTabSize> is greater than or equal to <nLineLength>, | |
then the tab size is automatically converted to <nLineLength> - 1. | |
<lWrap> | toggles word wrap on and off. Specifying true (.T.) toggles |
word wrap on; false (.F.) toggles it off. If not specified, the default | |
value is true (.T.). |
MEMOLINE() returns the line of text specified by <nLineNumber> in <cString> as a character string. If the line has fewer characters than the indicated length, the return value is padded with blanks. If the line number is greater than the total number of lines in <cString>, MEMOLINE() returns a null string ("").
If <lWrap> is true (.T.) and the indicated line length breaks the line in the middle of a word, that word is not included as part of the return value but shows up at the beginning of the next line extracted with MEMOLINE().
If <lWrap> is false (.F.), MEMOLINE() returns only the number of characters specified by the line length. The next line extracted by MEMOLINE() begins with the character following the next hard carriage return, and all intervening characters are not processed.
MEMOLINE() is a memo function used with MLCOUNT() to extract lines of text from character strings and memo fields based on the number of characters per line. It is the most basic facility provided by xClipper to display memo fields and long strings.
The basic method of operation is to determine the number of lines in the memo field or character string using MLCOUNT() with the same number of characters per line, tab size, and wrapping behavior as you intend to use with MEMOLINE(). Using this value as the upper boundary of a FOR...NEXT, each line of the memo field or character string can be extracted with MEMOLINE() and processed with any combination of output commands and functions required.
This example demonstrates the general method for displaying memo fields and long character strings using the combination of MLCOUNT() and MEMOLINE(): LOCAL nLineLength := 40, nTabSize := 3, lWrap := .T. LOCAL nLines, nCurrentLine USE Customer INDEX CustName NEW // nLines := MLCOUNT(CustNotes, nLineLength,; nTabSize, lWrap) // SET PRINTER ON FOR nCurrentLine := 1 TO nLines ? MEMOLINE(CustNotes, nLineLength, nCurrentLine,; nTabSize, lWrap) NEXT SET PRINTER OFF
MEMOREAD(<cFile>) --> cString
MEMOREAD() returns the contents of a text file as a character string. The maximum file size that can be read is 65,535 characters (64K)--the maximum size of a character string. If <cFile> cannot be found, MEMOREAD() returns a null string ("").
MEMOREAD() is a memo function that reads a disk file into memory where it can be manipulated as a character string or assigned to a memo field. MEMOREAD() is used with MEMOEDIT() and MEMOWRIT() to edit an imported disk file, and then write it back to disk. MEMOREAD() searches for <cFile> beginning with the current DOS directory. If the file is not found, MEMOREAD() searches the DOS path. MEMOREAD() does not use the xClipper DEFAULT or PATH to search for <cFile>.
In a network environment, MEMOREAD() attempts to open the specified file shared and read--only. If the file is opened exclusive by another process, MEMOREAD() returns a null string ("").
This example uses MEMOREAD() to assign the contents of a text file to the Notes memo field and to a character variable: REPLACE Notes WITH MEMOREAD("Temp.txt") cString = MEMOREAD("Temp.txt") This example defines a function that edits a disk file: FUNCTION Editor( cFile ) LOCAL cString IF (cString := MEMOREAD(cFile)) == "" ? "Error reading " + cFile RETURN .F. ELSE MEMOWRIT(cFile, MEMOEDIT(cString)) RETURN .T. ENDIF
MEMOTRAN(<cString>,[<cReplaceHardCR>],[<cReplaceSoftCR>]) --> cNewString
<cString> | is the character string or memo field to be searched. |
<cReplaceHardCR> | is the character with which to replace a hard |
carriage return/line feed pair. If not specified, the default value is | |
a semicolon (;). | |
<cReplaceSoftCR> | is the character with which to replace a soft |
carriage return/line feed pair. If not specified, the default value is | |
a space. |
MEMOTRAN() returns a copy of <cString> with the specified carriage return/line feed pairs replaced.
MEMOTRAN() is a memo function that converts a memo field or long character string containing hard and soft carriage return/line feed characters into a form that can be displayed. These two character combinations are end of line formatting indicators placed in the string by MEMOEDIT(). Soft carriage returns (CHR(141)) are inserted when a line longer than the width of the MEMOEDIT() window wraps. Hard carriage returns (CHR(13)) are inserted when the user explicitly presses Return.
MEMOTRAN() is particularly useful when displaying a memo field in a REPORT FORM which does not wrap when a soft carriage return is encountered. MEMOTRAN() resolves this by converting soft carriage returns to spaces. Note, however, that you must declare MEMOTRAN() as external using the REQUEST statement if it is used in a REPORT FORM and not specified anywhere else in the current program.
This example strips all end of line characters from a memo field: REPLACE Notes WITH MEMOTRAN(Notes)
MEMOWRIT(<cFile>, <cString>) --> lSuccess
MEMOWRIT() returns true (.T.) if the writing operation is successful; otherwise, it returns false (.F.).
MEMOWRIT() is a memo function that writes a character string or memo field to a disk file. If a path is not specified, MEMOWRIT() writes <cFile> to the current DOS directory and not the current DEFAULT directory. If <cFile> already exists, it is overwritten.
MEMOWRIT() is generally used with MEMOREAD() to load text files into memory where they can be edited, displayed, and written back to disk. You can also use MEMOWRIT() as a quick way of exporting a memo field to a text file.
This example uses MEMOWRIT() with MEMOREAD() to allow editing of memo fields with an external editor: LOCAL cEditor := "MYEDIT.EXE" USE Sales NEW IF MEMOWRIT("Cliptmp.txt", Notes) RUN (cEditor + " Cliptmp.txt") REPLACE Notes WITH MEMOREAD("Cliptmp.txt") ELSE ? "Error while writing Cliptmp.txt" BREAK ENDIF
MLCOUNT(<cString>, [<nLineLength>],[<nTabSize>], [<lWrap>]) --> nLines
<cString> | is the character string or memo field to be counted. |
<nLineLength> | specifies the number of characters per line and can |
range from four to 254. If not specified, the default line length is | |
79. | |
<nTabSize> | defines the tab size. If not specified, the default |
value is four. If <nTabSize> is greater than or equal to <nLineLength>, | |
then the tab size is automatically converted to <nLineLength> - 1. | |
<lWrap> | toggles word wrap on and off. Specifying true (.T.) toggles |
word wrap on; false (.F.) toggles it off. If not specified, the default | |
value is true (.T.). |
MLCOUNT() returns the number of lines in <cString> depending on the <nLineLength>, the <nTabSize>, and whether word wrapping is on or off.
MLCOUNT() is a memo function used with MEMOLINE() to print character strings and memo fields based on the number of characters per line. In the basic operation, use MLCOUNT() to return the number of lines in the character string or memo field. Then, using MEMOLINE() to extract each line, loop through the memo field until there are no lines left.
If <lWrap> is true (.T.) and an end of line position breaks a word, it is word wrapped to the next line and the next line begins with that word. If <lWrap> is false (.F.), MLCOUNT() counts the number of characters specified by <nLineLength> as the current line. The next line begins with the character following the next hard or soft carriage return. Intervening characters are ignored.
This example displays the contents of each Notes memo field in the Sales database file, one line at a time: USE Sales NEW nLineLength = 65 // DO WHILE !EOF() nLines = MLCOUNT(Sales->Notes, nLineLength) FOR nCurrLine = 1 TO nLines ? MEMOLINE(Sales->Notes, nLineLength, nCurrLine) NEXT SKIP ? ENDDO
MLCTOPOS(<cText>, <nWidth>, <nLine>, <nCol>, [<nTabSize>], [<lWrap>]) --> nPosition
<cText> | is the text string to be scanned. |
<nWidth> | is the line length formatting width. |
<nLine> | is the line number counting from 1. |
<nCol> | is the column number counting from 0. |
<nTabSize> | is the number of columns between tab stops. If not |
specified, the default is 4. | |
<lWrap> | is the word wrap flag. If not specified, the default is |
true (.T.). |
MLCTOPOS() returns the byte position within <cText> counting from 1.
MLCTOPOS() is a memo function that determines the byte position that corresponds to a particular line and column within the formatted text. Note that the line number is one-relative and the column number is zero-relative. This is compatible with MEMOEDIT(). The return value is one-relative, making it suitable for use in SUBSTR() or other string functions.
This example determines the byte position of line 5, column 3 in the cText string: cText := "Note the side on which the bread ; is buttered." // ? MLCTOPOS(cText, 5, 3, 0) // Result: 10
MLPOS(<cString>, <nLineLength>, <nLine>, [<nTabSize>], [<lWrap>]) --> nPosition
<cString> | is a character string or memo field. |
<nLineLength> | specifies the number of characters per line. |
<nLine> | specifies the line number. |
<nTabSize> | defines the tab size. The default is four. If |
<nTabSize> | is greater than or equal to <nLineLength>, then the tab size |
is adjusted to <nLineLength> - 1. | |
<lWrap> | toggles word wrap on and off. Specifying true (.T.) toggles |
word wrap on, and false (.F.) toggles it off. The default is true | |
(.T.). |
MLPOS() returns the character position of <nLine> in <cString> as an integer numeric value. If <nLine> is greater than the number of lines in <cString>, MLPOS() returns the length of <cString>.
This example uses MLPOS() to find the position of a specific line, given a line length: cString = MEMOREAD("Temp.txt") nLineLength = 40 nLine = 5 nPosition = MLPOS(cString, nLineLength, nLine) ? SUBSTR(cString, nPosition, 12)
MPOSTOLC(<cText>, <nWidth>, <nPos>, [<nTabSize>], [<lWrap>]) --> aLineColumn
<cText> | is a text string. |
<nWidth> | is the length of the formatted line. |
<nPos> | is the byte position within text counting from one (1). |
<nTabSize> | is the number of columns between tab stops. If not |
specified, the default is four (4). | |
<lWrap> | is the word wrap flag. If not specified, the default is |
true (.T.). |
MPOSTOLC() returns an array containing the line and the column values for the specified byte position, <nPos>.
MPOSTOLC() is a memo function that determines the formatted line and column corresponding to a particular byte position within <cText>. Note that the line number returned is one-relative and the column number is zero-relative. This is compatible with MEMOEDIT(). <nPos> is one-relative, compatible with AT(), RAT(), and other string functions.
This example determines, for the text string shown, the line and column corresponding to the tenth character of the text, assuming a formatting width of five columns. A formatting width of five would cause each of the first three words to be placed on a line by itself. The tenth character of the text is the "s" in "side". The word "side" would be at the leftmost column of the third line of the formatted text, so the return value is {3, 0}. cText := "Note the side on which the bread ; is buttered." // aLC := MPOSTOLC(cText, 5, 10) // Result: {3, 0}
PADL(<exp>, <nLength>, [<cFillChar>]) --> cPaddedString PADC(<exp>, <nLength>, [<cFillChar>]) --> cPaddedString PADR(<exp>, <nLength>, [<cFillChar>]) --> cPaddedString
PADC(), PADL(), and PADR() return the result of <exp> as a character string padded with <cFillChar> to a total length of <nLength>.
PADC(), PADL(), and PADR() are character functions that pad character, date, and numeric values with a fill character to create a new character string of a specified length. PADC() centers <exp> within <nLength> adding fill characters to the left and right sides; PADL() adds fill characters on the left side; and PADR() adds fill characters on the right side. If the length of <exp> exceeds <nLength>, all of the PAD() functions truncate cPaddedString to <nLength>.
PADC(), PADL(), and PADR() display variable length strings within a fixed length area. They can be used, for instance, to ensure alignment with consecutive ?? commands. Another use is to display text to a fixed- width screen area assuring that previous text is completely overwritten.
PADC(), PADL(), and PADR() are the inverse of the ALLTRIM(), RTRIM(), and LTRIM() functions which trim leading and trailing space from character strings.
This example uses PADR() to format a record number display on a status line filling the allocated space: IF EOF() @ 23, 45 PADR("EOF/" + LTRIM(STR(LASTREC())), 20) ELSEIF BOF() @ 23, 45 PADR("BOF/" + LTRIM(STR(LASTREC())), 20) ELSE @ 23, 45 SAY PADR("Record " + LTRIM(STR(RECNO()) ; + "/" + LTRIM(STR(LASTREC())), 20) ENDIF
RAT(<cSearch>, <cTarget>) --> nPosition
RAT() returns the position of <cSearch> within <cTarget> as an integer numeric value. If <cSearch> is not found, RAT() returns zero.
RAT() is a character function that returns the position of the last occurrence of a character substring within another character string. It does this by searching the target string from the right. RAT() is like the AT() function, which returns the position of the first occurrence of a substring within another string. RAT() is also like the $ operator, which determines whether a substring is contained within a string.
Both the RAT() and AT() functions are used with SUBSTR(), LEFT(), and RIGHT() to extract substrings.
This example uses RAT() to create a user-defined function, FilePath(), that extracts the path from a file specification. If the path is unspecified, FilePath() returns a null string (""): ? FilePath("C:\DBF\Sales.dbf") // Result: C:\DBF\ FUNCTION FilePath( cFile ) LOCAL nPos, cFilePath IF (nPos := RAT("\", cFile)) != 0 cFilePath = SUBSTR(cFile, 1, nPos) ELSE cFilePath = "" ENDIF RETURN cFilePath
REPLICATE(<cString>, <nCount>) --> cRepeatedString
REPLICATE() returns a character string up to a maximum of 65,535 (64K) bytes in length. Specifying a zero as the <nCount> argument returns a null string ("").
REPLICATE() is a character function that repeatedly displays, prints, or stuffs the keyboard with one or more characters. REPLICATE() is like the SPACE() function, which returns a specified number of space characters.
These examples demonstrate REPLICATE() repeating strings: ? REPLICATE("*", 5) // Result: ***** ? REPLICATE("Hi ", 2) // Result: Hi Hi ? REPLICATE(CHR(42), 5) // Result: ***** This example uses REPLICATE() to stuff the keyboard with several Down arrow keys: #include "Inkey.ch" KEYBOARD REPLICATE(CHR(K_DOWN), 25)
RIGHT(<cString>, <nCount>) --> cSubString
RIGHT() returns the rightmost <nCount> characters of <cString>. If <nCount> is zero, RIGHT() returns a null string (""). If <nCount> is negative or larger than the length of the character string, RIGHT() returns <cString>. The maximum string size is 65,535 (64K) bytes.
RIGHT() is a character function that extracts a substring beginning with the rightmost character in <cString>. It is the same as the character expression, SUBSTR(<cString>, <nCount>). For example, RIGHT("ABC", 1) is the same as SUBSTR("ABC", -1). RIGHT() is related to LEFT(), which extracts a substring beginning with the leftmost character in <cString>.
The RIGHT(), LEFT(), and SUBSTR() functions are often used with both the AT() and RAT() functions to locate either the first and/or the last position of a substring before extracting it.
This example shows the relationship between RIGHT() and SUBSTR(): ? RIGHT("ABCDEF", 3) // Result: DEF ? SUBSTR("ABCDEF", -3) // Result: DEF This example extracts a substring from the end of another string up to the last occurrence of a comma: LOCAL cName := "James,William" ? RIGHT(cName,; LEN(cName) - RAT(",", cName) - 1) // Result: William
[R]TRIM(<cString>) --> cTrimString
RTRIM() returns a copy of <cString> with the trailing spaces removed. If <cString> is a null string ("") or all spaces, RTRIM() returns a null string ("").
RTRIM() is a character function that formats character strings. It is useful when you want to delete trailing spaces while concatenating strings. This is typically the case with database fields which are stored in fixed-width format. For example, you can use RTRIM() to concatenate first and last name fields to form a name string.
RTRIM() is related to LTRIM() which removes leading spaces, and ALLTRIM() which removes both leading and trailing spaces. The inverse of ALLTRIM(), LTRIM(), and RTRIM() are the PADC(), PADR(), and PADL() functions which center, right-justify, or left-justify character strings by padding them with fill characters. RTRIM() is exactly the same as TRIM() in function.
This is a user-defined function in which RTRIM() formats city, state, and zip code fields for labels or form letters: FUNCTION CityState(cCity, cState, cZip) RETURN RTRIM(cCity) + ", " ; + RTRIM(cState) + " " + cZip In this example the user-defined function, CityState(), displays a record from Customer.dbf: USE Customer INDEX CustName NEW SEEK "Kate" ? CityState(City, State, ZipCode) // Result: Athens, GA 10066
SEARCH(<sPattern>, <sString>, [@aReg], [<nFrom>], [<nRange>]) --> TRUE || FALSE
Returns TRUE in successfully searching.
SEARCH() searches substring into string <sString> by regular expression <sPattern> begin with position <nFrom> and in range <nRange>. The result of search will be wrote to <aReg> if this parameter specified.
<nRange> it is the shifting value, when will be checked concidence about <nFrom>. If <nRange>==0 - checked only position <nFrom>; if <nRange>==1 - checked positions <nFrom> and <nFrom>+1; if <nRange>==-1 - checked positions <nFrom> and <nFrom>-1.
Every element <aReg> is the array of 3 elementes: 1-st element - is the starting position founded substring; 2-d element - is the end founded substring; 3-d element - is the substring length.
str := "int clip_SEARCH(ClipMachine * mp)" reg := {} if SEARCH("clip_[_A-Z]*", str, @reg) qout("start :" +str(reg[1][1])) qout("end :" +str(reg[1][2])) qout("length:" +str(reg[1][3])) else qout("Regular expression not found!") endif
SOUNDEX(<cString>) --> cSoundexString
SOUNDEX() returns a four-digit character string in the form A999.
SOUNDEX() is a character function that indexes and searches for sound- alike or phonetic matches. It is used in applications where the precise spelling of character keys is not known or where there is a high probability of misspelled names. Misspelling is common in real-time transaction systems where the data entry operator is receiving information over the telephone. SOUNDEX() works by bringing sound-alikes together under the same key value. Note, however, the soundex method is not absolute. Keys that are quite different can result in the same soundex value.
This example builds an index using SOUNDEX() to create the key values. It then searches for a value found in the Salesman field: USE Sales INDEX ON SOUNDEX(Salesman) TO Salesman SEEK SOUNDEX("Smith") ? FOUND(), Salesman // Result: .T. Smith Here, a search is made for the same key as above but with a different spelling: SEEK SOUNDEX("Smythe") ? FOUND(), Salesman // Result: .T. Smith
SPACE(<nCount>) --> cSpaces
SPACE() returns a character string. If <nCount> is zero, SPACE() returns a null string ("").
SPACE() is a character function that returns a specified number of spaces. It is the same as REPLICATE("", <nCount>). SPACE() can initialize a character variable before associating it with a GET. SPACE() can also pad strings with leading or trailing spaces. Note, however, that the PADC(), PADL(), and PADR() functions are more effective for this purpose.
This example uses SPACE() to initialize a variable for data input: USE Customer NEW MEMVAR->Name = SPACE(LEN(Customer->Name)) @ 10,10 SAY "Customer Name" GET MEMVAR->Name READ
STR(<nNumber>, [<nLength>], [<nDecimals>]) --> cNumber
STR() returns <nNumber> formatted as a character string. If the optional length and decimal arguments are not specified, STR() returns the character string according to the rules.
STR() is a numeric conversion function that converts numeric values to character strings. It is commonly used to concatenate numeric values to character strings. STR() has applications displaying numbers, creating codes such as part numbers from numeric values, and creating index keys that combine numeric and character data.
STR() is like TRANSFORM(), which formats numeric values as character strings using a mask instead of length and decimal specifications.
The inverse of STR() is VAL(), which converts character numbers to numerics.
These examples demonstrate the range of values returned by STR(), depending on the arguments specified: nNumber:= 123.45 ? STR(nNumber) // Result: 123.45 ? STR(nNumber, 4) // Result: 123 ? STR(nNumber, 2) // Result: ** ? STR(nNumber * 10, 7, 2) // Result: 1234.50 ? STR(nNumber * 10, 12, 4) // Result: 1234.5000 ? STR(nNumber, 10, 1) // Result: 1234.5 This example uses STR() to create an index with a compound key of order numbers and customer names: USE Customer NEW INDEX ON STR(NumOrders, 9) + CustName TO CustOrd
STR2VAR(<sUucodeStr>) --> <vData>
Returns some data wath equal source uucode string <sUucodeStr>.
STR2VAR() deconverts uucode string <sUucodeStr> to source data <vData> to uucode string and returns it. This function is conversely for VAR2STR() function.
f1 := fopen("test.txt") f2 := fcreare("test_uucode.txt") do while !feof(f1) uStr := VAR2STR(fGet(f1, 1024)) fwrite(f2, uStr, len(uStr)) enddo fclose(f2) fclose(f1) f1 := fopen("test_uucode.txt") do while !feof(f1) uStr := fGet(f1, 1024) ? STR2VAR(uStr) ? enddo fclose(f1)
No dependies of platform.
STRTRAN(<cString>, <cSearch>,[<cReplace>], [<nStart>], [<nCount>]) --> cNewString
<cString> | is the character string or memo field to be searched. |
<cSearch> | is the sequence of characters to be located. |
<cReplace> | is the sequence of characters with which to replace |
<cSearch> | . If this argument is not specified, the specified instances |
of the search argument are replaced with a null string (""). | |
<nStart> | is the first occurrence that will be replaced. If this |
argument is omitted, the default is one. If this argument is equal to | |
or less than zero, STRTRAN() returns an empty string. | |
<nCount> | is the number of occurrences to be replaced. If this |
argument is not specified, the default is all. |
STRTRAN() returns a new character string with the specified instances of <cSearch> replaced with <cReplace>.
STRTRAN() is a character function that performs a standard substring search within a character string. When it finds a match, it replaces the search string with the specified replacement string. All instances of <cSearch> are replaced unless <nStart> or <nCount> is specified. Note that STRTRAN() replaces substrings and, therefore, does not account for whole words.
This example uses STRTRAN() to establish a postmodern analog to a famous quotation: cString:= "To compute, or not to compute?" ? STRTRAN(cString, "compute", "be") // Result: To be, or not to be?
STUFF(<cString>, <nStart>, <nDelete>, <cInsert>) --> cNewString
STUFF() returns a copy of <cString> with the specified characters deleted and with <cInsert> inserted.
STUFF() is a character function that deletes <nDelete> characters from <cString> beginning at the <nStart> position. Then, it inserts <cInsert> into the resulting string beginning at <nStart> to form the return string. With this, STUFF() can perform the following six operations:
Insert: If <nDelete> is zero, no characters are removed from <cString>. <cInsert> is then inserted at <nStart>, and the entire string is returned. For example, STUFF("My dog has fleas.", 12, 0, "no" ) returns "My dog has no fleas."
Replace: If <cInsert> is the same length as <nDelete>, <cInsert> replaces characters beginning at <nStart>. The same number of characters are deleted as are inserted, and the resulting string is the same length as the original. For example, STUFF("My dog has fleas.", 12, 5, "bones") returns "My dog has bones."
Delete: If <cInsert> is a null string (""), the number of characters specified by <nDelete> are removed from <cString>, and the string is returned without any added characters. For example, STUFF("My dog has fleas.", 1, 3, "") returns "dog has fleas."
Replace and insert: If <cInsert> is longer than <nDelete>, all characters from <nStart> up to <nDelete> are replaced and the rest of <cInsert> is inserted. Since more characters are inserted than are deleted, the resulting string is always longer than the original. For example, STUFF("My dog has fleas.", 8, 3, "does not have") returns "My dog does not have fleas."
Replace and delete: If the length of <cInsert> is less than <nDelete>, more characters are deleted than inserted. The resulting string, therefore, is shorter than the original. For example, STUFF("My dog has fleas.", 8, 3, "is") returns "My dog is fleas."
Replace and delete rest: If <nDelete> is greater than or equal to the number of characters remaining in <cString> beginning with <nStart>, all remaining characters are deleted before <cInsert> is inserted. For example, STUFF("My dog has fleas.", 8, 10, "is.") returns "My dog is."
These examples demonstrate the six basic operations of STUFF(): // Insert ? STUFF("ABCDEF", 2, 0, "xyz") // Result: AxyzBCDEF // Replace ? STUFF("ABCDEF", 2, 3, "xyz") // Result: AxyzEF // Delete ? STUFF("ABCDEF", 2, 2, "") // Result: ADEF // Replace and insert ? STUFF("ABCDEF", 2, 1, "xyz") // Result: AxyzCDEF // Replace and delete ? STUFF("ABCDEF", 2, 4, "xyz") // Result: AxyzF // Replace and delete rest ? STUFF("ABCDEF", 2, 10, "xyz") // Result: Axyz
SUBSTR(<cString>, <nStart>, [<nCount>]) --> cSubstring
<cString> | is the character string from which to extract a substring. |
It can be up to 65,535 (64K) bytes, the maximum character string size in | |
xClipper. | |
<nStart> | is the starting position in <cString>. If <nStart> is |
positive, it is relative to the leftmost character in <cString>. If | |
<nStart> | is negative, it is relative to the rightmost character in the |
<cString> | . |
<nCount> | is the number of characters to be extracted. If omitted, |
the substring begins at <nStart> and continues to the end of the string. | |
If <nCount> is greater than the number of characters from <nStart> to | |
the end of <cString>, the excess numbers are ignored. |
SUBSTR() returns a character string.
SUBSTR() is a character function that extracts a substring from another character string or memo field. SUBSTR() is related to the LEFT() and RIGHT() functions which extract substrings beginning with leftmost and rightmost characters in <cString>, respectively.
The SUBSTR(), RIGHT(), and LEFT() functions are often used with both the AT() and RAT() functions to locate either the first and/or the last position of a substring before extracting it. They are also used to display or print only a portion of a character string.
These examples extract the first and last name from a variable: cName:= "Biff Styvesent" ? SUBSTR(cName, 1, 4) // Result: Biff ? SUBSTR(cName, 6) // Result: Styvesent ? SUBSTR(cName, LEN(cName) + 2) // Result: null string ? SUBSTR(cName, -9) // Result: Styvesent ? SUBSTR(cName, -9, 3) // Result: Sty This example uses SUBSTR() with AT() and RAT() to create a user-defined function to extract a file name from a file specification: ? FileBase("C:\PRG\MYFILE.OBJ") // Result: MYFILE.OBJ FUNCTION FileBase( cFile ) LOCAL nPos IF (nPos := RAT("\", cFile)) != 0 RETURN SUBSTR(cFile, nPos + 1) ELSEIF (nPos := AT(":", cFile)) != 0 RETURN SUBSTR(cFile, nPos + 1) ELSE RETURN cFile ENDIF
TRIM(<cString>) --> cTrimString
TRIM() returns a copy of <cString> with the trailing spaces removed. If <cString> is a null string ("") or all spaces, TRIM() returns a null string ("").
TRIM() is a character function that formats character strings. It is useful when you want to delete trailing spaces while concatenating strings. This is typically the case with database fields which are stored in fixed-width format. For example, you can use TRIM() to concatenate first and last name fields to form a name string.
TRIM() is related to LTRIM(), which removes leading spaces, and ALLTRIM(), which removes both leading and trailing spaces. The inverse of ALLTRIM(), LTRIM(), and RTRIM() are the PADC(), PADR(), and PADL() functions which center, right-justify, or left-justify character strings by padding them with fill characters.
This is a user-defined function in which TRIM() formats city, state, and zip code fields for labels or form letters: FUNCTION CityState(cCity, cState, cZip) RETURN TRIM(cCity) + ", " ; + TRIM(cState) + " " + cZip In this example the user-defined function, CityState(), displays a record from Customer.dbf: USE Customer INDEX CustName NEW SEEK "Kate" ? CityState(City, State, ZipCode) // Result: Athens, GA 10066
UPPER(<cString>) --> cUpperString
UPPER() returns a copy of <cString> with all alphabetical characters converted to uppercase. All other characters remain the same as in the original string.
UPPER() is a character function that converts lowercase and mixed case strings to uppercase. It is related to LOWER() which converts uppercase and mixed case strings to lowercase. UPPER() is related to the ISUPPER() and ISLOWER() functions which determine whether a string begins with an uppercase or lowercase letter.
UPPER() is generally used to format character strings for display purposes. It can, however, be used to normalize strings for case- independent comparison or INDEXing purposes.
These examples illustrate the effects of UPPER(): ? UPPER("a string") // Result: A STRING ? UPPER("123 char = <>") // Result: 123 CHAR = <> This example uses UPPER() as part of a case-independent condition: USE Customer INDEX CustName NEW LIST CustName FOR "KATE" $ UPPER(Customer) UPPER() is also useful for creating case-independent index key expressions: USE Customer NEW INDEX ON UPPER(Last) TO CustLast Later, use the same expression to look up Customers: MEMVAR->Last = SPACE(15) @ 10, 10 GET MEMVAR->Last READ SEEK UPPER(MEMVAR->Last)
VAL(<cNumber>) --> nNumber
VAL() returns <cNumber> converted to a numeric value including decimal digits.
VAL() is a character conversion function that converts a character string containing numeric digits to a numeric value. When VAL() is executed, it evaluates <cNumber> until a second decimal point, the first non-numeric character, or the end of the expression is encountered. Leading spaces are ignored. When SET FIXED is ON, VAL() returns the number of decimal places specified by SET DECIMALS, rounding <cNumber> if it is specified with more digits than the current DECIMALS value. As with all other functions that round, digits between zero and four are rounded down, and digits between five and nine are rounded up. When SET FIXED is OFF, VAL() returns the number of decimal places specified in <cNumber>.
VAL() is the opposite of STR() and TRANSFORM(), which convert numeric values to character strings.
These examples illustrate VAL() with SET FIXED ON and SET DECIMALS TO 2: SET DECIMALS TO 2 SET FIXED ON // ? VAL("12.1234") // Result: 12.12 ? VAL("12.1256") // Result: 12.13 ? VAL("12A12") // Result: 12 ? VAL("A1212") // Result: 0 ? VAL(SPACE(0)) // Result: 0 ? VAL(SPACE(1)) // Result: 0 ? VAL(" 12.12") // Result: 12.12
VAR2STR(<vData>) --> <sUucodeStr>
Returns uucode string <sUucodeStr>.
VAR2STR() converts source data <vData> to uucode string <sUucodeStr> and returns it.
f1 := fopen("test.txt") f2 := fcreare("test_uucode.txt") do while !feof(f1) uStr := VAR2STR(str) fwrite(f2, uStr, len(uStr)) enddo fclose(f2) fclose(f1)
No dependies of platform.