Tag Archives: RAT()
String Functions
CharAdd
CharAnd
CharEven
CharHist
CharList
CharMirr
CharMix
CharNoList
CharNot
CharOdd
CharOne
CharOnly
CharOr
CharPix
CharRela
CharRelRep
CharRem
CharRepl
CharRLL
CharRLR
CharSHL
CharSHR
CharSList
CharSort
CharSub
CharSwap
CharWin
CharXOR
CountLeft
CountRight
Descend
Empty
hb_At
hb_RAt
hb_ValToStr
IsAlpha
IsDigit
IsLower
IsUpper
NumAt
NumToken
PadLeft
PadRight
POSALPHA
POSCHAR
POSDEL
POSDIFF
POSEQUAL
POSINS
POSLOWER
POSRANGE
POSREPL
POSUPPER
TokenAt
TokenEnd
TokenExit
TokenInit
TokenLower
TokenNext
TokenNum
TokenSep
TokenUpper
Right()
RIGHT()
Extract the rightmost substring of a character expression
Syntax
RIGHT( <cString>, <nLen> ) --> cReturn
Arguments
<cString> Character expression to be parsed
<nLen> Number of bytes to return beginning at the rightmost position
Returns
<cReturn> Substring of evaluation
Description
This functions returns the rightmost <nLen> characters of <cString>. It is equivalent to the following expressions:
SUBSTR( <cString>, – <nLen> )
SUBSTR( <cString>, LEN( <cString> ) – <nLen> + 1, <nLen> )
Examples
? RIGHT( "HELLO HARBOUR", 5 ) // RBOUR
Compliance
Clipper
Platforms
All
Files
Library is rtl
Seealso
SUBSTR(), LEFT(), AT(), RAT()
Left()
LEFT()
Extract the leftmost substring of a character expression
Syntax
LEFT( <cString>, <nLen> ) --> cReturn
Arguments
<cString> Main character to be parsed
<nLen> Number of bytes to return beginning at the leftmost position
Returns
<cReturn> Substring of evaluation
Description
This functions returns the leftmost <nLen> characters of <cString>. It is equivalent to the following expression:
SUBSTR( <cString>, 1, <nLen> )
Examples
? LEFT( "HELLO HARBOUR", 5 ) // HELLO
Compliance
Clipper
Platforms
All
Files
Library is rtl
Seealso
SUBSTR(), RIGHT(), AT(), RAT()
hb_RAt()
hb_RAt()
Searches for last occurrence a substring of a string.
Syntax
hb_RAt( <cSearch>, <cString>, [<nStart>], [<nEnd>] ) --> nPos
Arguments
<cSearch> Substring to search for
<cString> Main string
<nStart> First position to search in cString, by default 1.
<nEnd> End position to search, by default cString length
Returns
hb_RAt() return the location of beginning position of last occurrence a substring of a string.
Description
This function searches for last occurrence a <cSearch> in <cString>. If the function is unable to find any occurrence of <cSearch> in <cString>, the return value is 0. 3rd and 4th parameters define inclusive range for 2nd parameter on which operation is performed. If 3rd and 4th parameters is not specified, then hb_RAt() is equal to RAt().
Examples
LOCAL cString LOCAL cSearch LOCAL i, y, r, nLen ? 'hb_RAt( "cde", "abcdefgfedcba" ) = ', ; hb_RAt( "cde", "abcdefgfedcba" ) // -> 3 cString := "acdefcdeedcb" cSearch := "cde" nLen := Len( cString ) FOR y := 1 TO nLen FOR i := 1 TO nLen r := hb_RAt( cSearch, cString, y, i ) IF r != 0 ? 'hb_RAt( "' + cSearch + '", "' + cString + '", ' + hb_ntos( y ) + ', ' + hb_ntos( i ) + ' ) = ' + ; hb_ntos( r ) ENDIF NEXT NEXT
Compliance
Clipper
Platforms
All(64K)
Files
Library is core
Seealso
hb_At(), SubStr(), Right(), RAt()
hb_At()
hb_At()
Locates the position of a substring in a main string.
Syntax
hb_At( <cSearch>, <cString>, [<nStart>], [<nEnd>] ) --> nPos
Arguments
<cSearch> Substring to search for
<cString> Main string
<nStart> First position to search in cString, by default 1
<nEnd> End position to search, by default cString length
Returns
hb_At() return the starting position of the first occurrence of the substring in the main string
Description
This function searches the string <cString> for the characters in the first string <cSearch>. If the substring is not contained within the second expression, the function will return 0. The third and fourth parameters lets you indicate a starting and end offset to search in.
Examples
? 'hb_At( "cde", "abcdefgfedcba" ) = ' + ; Str( hb_At( "cde", "abcdefgfedcba" ) ) // 3 ? 'hb_At( "cde", "abcdefgfedcba" ) = ' + ; Str( hb_At( "cde", "abcdefgfedcba", 4 ) ) // 0
Compliance
This function is sensitive to HB_CLP_STRICT settings during build.
<nStart> and <nEnd> are Harbour extensions and do not exist if HB_CLP_STRICT is defined. In that case, the whole string is searched.
Platforms
All
Files
Library is core
Seealso
hb_RAt()
At()
AT()
Locates the position of a substring in a main string.
Syntax
AT( <cSearch>, <cString>, [<nStart>], [<nEnd>] ) --> nPos
Arguments
<cSearch> Substring to search for
<cString> Main string
<nStart> First position to search in cString, by default 1
<nEnd> End position to search, by default cString length
Returns
AT() return the starting position of the first occurrence of the substring in the main string
Description
This function searches the string <cString> for the characters in the first string <cSearch>. If the substring is not contained within the second expression, the function will return 0. The third and fourth parameters lets you indicate a starting and end offset to search in.
Examples
? 'At( "cde", "abcdefgfedcba" ) = ' +; At( "cde", "abcsefgfedcba" )
Compliance
This function is sensitive to HB_CLP_STRICT settings during the compilation of src/rtl/at.c
<nStart> and <nEnd> are Harbour extensions and do not exist if HB_CLP_STRICT is defined. In that case, the whole string is searched.
Platforms
All
Files
Library is rtl
Seealso
RAT()
C5_RAT
RAT() Return the position of the last occurrence of a substring ------------------------------------------------------------------------------ Syntax RAT(<cSearch>, <cTarget>) --> nPosition Arguments <cSearch> is the character string to be located. <cTarget> is the character string to be searched. Returns RAT() returns the position of <cSearch> within <cTarget> as an integer numeric value. If <cSearch> is not found, RAT() returns zero. Description 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. Examples . 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 Files Library is EXTEND.LIB.
See Also: RIGHT() STRTRAN() SUBSTR()
C5 Data Manipulation Functions
Array :
AADD() :
Add a new element to the end of an array
AADD( <aTarget>, <expValue> ) --> Value
ACLONE() :
Duplicate a nested or multidimensional array
ACLONE( <aSource> ) --> aDuplicate
ACOPY() :
Copy elements from one array to another
ACOPY( <aSource>, <aTarget>, [ <nStart> ], [ <nCount> ], [ <nTargetPos> ] ) --> aTarget
ADEL() :
Delete an array element
ADEL( <aTarget>, <nPosition> ) --> aTarget
ADIR()* :
Fill a series of arrays with directory information
ADIR([ <cFilespec> ], [ <aFilenames> ], [ <aSizes> ], [ <aDates> ], [ <aTimes> ], [ <aAttributes> ] ) --> nFiles
AEVAL() :
Execute a code block for each element in an array
AEVAL( <aArray>, <bBlock>, [ <nStart> ], [ <nCount> ] ) --> aArray
AFILL() :
Fill an array with a specified value
AFILL( <aTarget>, <expValue>, [ <nStart> ], [ <nCount> ] )
--> aTarget
AINS() :
Insert a NIL element into an array
AINS( <aTarget>, <nPosition> ) --> aTarget
ARRAY() :
Create an uninitialized array of specified length
ARRAY( <nElements> [, <nElements>...] ) --> aArray
ASCAN() :
Scan an array for a value or until a block returns (.T.)
ASCAN( <aTarget>, <expSearch>, [ <nStart> ], [ <nCount> ] )
--> nStoppedAt
ASIZE() :
Grow or shrink an array
ASIZE( <aTarget>, <nLength> ) --> aTarget
ASORT() :
Sort an array
ASORT( <aTarget>, [ <nStart> ], [ <nCount> ], [ <bOrder> ] )
--> aTarget
ATAIL() :
Return value of the highest numbered (last) element of an array
ATAIL( <aArray> ) --> Element
Common :
EMPTY() :
Determine if the result of an expression is empty
EMPTY( <exp> ) --> lEmpty
LEN() :
Return the length of a character string or array size
LEN( <cString> | <aArray> ) --> nCount
MAX() :
Return the larger of two numeric or date values
MAX( <nExp1>, <nExp2> ) --> nLarger MAX( <dExp1>, <dExp2> ) --> dLarger
MIN() :
Return the smaller of two numeric or date values
MIN( <nExp1>, <nExp2> ) --> nSmaller MIN( <dExp1>, <dExp2> ) --> dSmaller
PAD() :
Pad character, date or numeric values with a fill character
PADL( <exp>, <nLength>, [ <cFillChar> ] ) --> cPaddedString PADC( <exp>, <nLength>, [ <cFillChar> ] ) --> cPaddedString PADR( <exp>, <nLength>, [ <cFillChar> ] ) --> cPaddedString
TRANSFORM() :
Convert any value into a formatted character string
TRANSFORM( <exp>, <cSayPicture> ) --> cFormatString
TYPE() :
Determine the type of an expression
TYPE( <cExp> ) --> cType
VALTYPE() :
Determine the data type returned by an expression
VALTYPE( <exp> ) --> cType
Date & Time :
CDOW() :
Convert a date value to a character day of the week
CDOW( <dExp> ) --> cDayName
CMONTH() :
Convert a date to a character month name
CMONTH( <dDate> ) --> cMonth
CTOD() :
Convert a date string to a date value
CTOD( <cDate> ) --> dDate
DATE() :
Return the system date as a date value
DATE() --> dSystem
DAY() :
Return the day of the month as a numeric value
DAY( <dDate> ) --> nDay
DOW() :
Convert a date value to a numeric day of the week
DOW( <dDate> ) --> nDay
DTOC() :
Convert a date value to a character string
DTOC( <dDate> ) --> cDate
DTOS() :
Convert a date value to a string formatted as yyyymmdd
DTOS( <dDate> ) --> cDate
MONTH() :
Convert a date value to the number of the month
MONTH( <dDate> ) --> nMonth
SECONDS() :
Return the number of seconds elapsed since midnight
SECONDS() --> nSeconds
TIME() :
Return the system time
TIME() --> cTimeString
YEAR() :
Convert a date value to the year as a numeric value
YEAR( <dDate> ) --> nYear
Numeric :
ABS() :
Return the absolute value of a numeric expression
ABS( <nExp> ) --> nPositive
BIN2I() :
Convert a 16-bit signed integer to a numeric value
BIN2I( <cSignedInt> ) --> nNumber
BIN2L() :
Convert a 32-bit signed integer to a numeric value
BIN2L( <cSignedInt> ) --> nNumber
BIN2W() :
Convert a 16-bit unsigned integer to a numeric value
BIN2W( <cUnsignedInt> ) --> nNumber
EXP() :
Calculate e**x
EXP( <nExponent> ) --> nAntilogarithm
INT() :
Convert a numeric value to an integer
INT( <nExp> ) --> nInteger
I2BIN() :
Convert a numeric to a 16-bit binary integer
I2BIN( <nInteger> ) --> cBinaryInteger
LOG() :
Calculate the natural logarithm of a numeric value
LOG( <nExp> ) --> nNaturalLog
L2BIN() :
Convert a numeric value to a 32-bit binary integer
L2BIN( <nExp> ) --> cBinaryInteger
MOD()* :
Return dBASE III PLUS modulus of two numbers
MOD( <nDividend>, <nDivisor> ) --> nRemainder
ROUND() :
Return a value rounded to a specified number of digits
ROUND( <nNumber>, <nDecimals> ) --> nRounded
SQRT() :
Return the square root of a positive number
SQRT( <nNumber> ) --> nRoot
VAL() :
Convert a character number to numeric type
VAL( <cNumber> ) --> nNumber
String & Memo :
ALLTRIM() :
Remove leading and trailing spaces from character string
ALLTRIM( <cString> ) --> cTrimString
ASC() :
Convert a character to its ASCII value
ASC( <cExp> ) --> nCode
AT() :
Return the position of a substring within a string
AT( <cSearch>, <cTarget> ) --> nPosition
CHR() :
Convert an ASCII code to a character value
CHR( <nCode> ) --> cChar
HARDCR() :
Replace all soft CRs with hard CRs
HARDCR( <cString> ) --> cConvertedString
ISALPHA() :
Determine if the leftmost character is alphabetic
ISALPHA( <cString> ) --> lBoolean
ISDIGIT() :
Determine if the leftmost character is a digit
ISDIGIT( <cString> ) --> lBoolean
ISLOWER() :
Determine if the leftmost character is a lower case letter
ISLOWER( <cString> ) --> lBoolean
ISUPPER() :
Determine if the leftmost character is upper case
ISUPPER( <cString> ) --> lBoolean
LEFT() :
Extract a substring beginning with the first character
LEFT( <cString>, <nCount> ) --> cSubString
LOWER() :
Convert uppercase characters to lowercase
LOWER( <cString> ) --> cLowerString
LTRIM() :
Remove leading spaces from a character string
LTRIM( <cString> ) --> cTrimString
MEMOEDIT() :
Display or edit character strings and memo fields
MEMOEDIT( [ <cString> ], [ <nTop> ], [ <nLeft> ], [ <nBottom> ], [ <nRight> ], [ <lEditMode> ], [ <cUserFunction> ], [ <nLineLength> ], [ <nTabSize> ], [ <nTextBufferRow> ], [ <nTextBufferColumn> ], [ <nWindowRow> ], [ <nWindowColumn> ] ) --> cTextBuffer
MEMOLINE() :
Extract a line of text from character string or memo field
MEMOLINE( <cString>, [ <nLineLength> ], [ <nLineNumber> ], [ <nTabSize> ], [ <lWrap> ] ) --> cLine
MEMOREAD() :
Return the contents of a disk file as a character string
MEMOREAD( <cFile> ) --> cString
MEMOTRAN() :
Replace carriage return/line feeds in character strings
MEMOTRAN( <cString>, [ <cReplaceHardCR> ], [ <cReplaceSoftCR> ] ) --> cNewString
MEMOWRIT() :
Write a character string or memo field to a disk file
MEMOWRIT( <cFile>, <cString> ) --> lSuccess
MLCOUNT() :
Count the lines in a character string or memo field
MLCOUNT( <cString>, [ <nLineLength> ], [ <nTabSize> ],
[ <lWrap> ] ) --> nLines
MLCTOPOS() :
Return byte position based on line and column position
MLCTOPOS( <cText>, <nWidth>, <nLine>, <nCol>, [ <nTabSize> ], [ <lWrap> ] ) --> nPosition
MLPOS() :
Determine the position of a line in a memo field
MLPOS( <cString>, <nLineLength>, <nLine>, [ <nTabSize> ], [ <lWrap> ] ) --> nPosition
MPOSTOLC() :
Return line and column position based on byte position
MPOSTOLC( <cText>, <nWidth>, <nPos>, [ <nTabSize> ], [ <lWrap> ] ) --> aLineColumn
RAT() :
Return the position of the last occurrence of a substring
RAT( <cSearch>, <cTarget> ) --> nPosition
REPLICATE() :
Return a string repeated a specified number of times
REPLICATE( <cString>, <nCount> ) --> cRepeatedString
RIGHT() :
Return a substring beginning with rightmost character
RIGHT( <cString>, <nCount> ) --> cSubString
RTRIM() :
Remove trailing spaces from a character string
RTRIM( <cString> ) --> cTrimString
SET EXACT* :
Toggle exact matches for character strings
SET EXACT on | OFF | <xlToggle>
SOUNDEX() :
Convert a character string to soundex form
SOUNDEX( <cString> ) --> cSoundexString
SPACE() :
Return a string of spaces
SPACE( <nCount> ) --> cSpaces
STR() :
Convert a numeric expression to a character string
STR( <nNumber>, [ <nLength> ], [ <nDecimals> ] ) --> cNumber
STRTRAN() :
Search and replace characters within a character string
STRTRAN( <cString>, <cSearch>, [ <cReplace> ],
[ <nStart> ], [ <nCount> ] ) --> cNewString
STUFF() :
Delete and insert characters in a string
STUFF( <cString>, <nStart>, <nDelete>, <cInsert> ) --> cNewString
SUBSTR() :
Extract a substring from a character string
SUBSTR( <cString>, <nStart>, [ <nCount> ] ) --> cSubstring
TRIM() :
Remove trailing spaces from a character string
TRIM( <cString> ) --> cTrimString
UPPER() :
Convert lowercase characters to uppercase
UPPER( <cString> ) --> cUpperString