Harbour All Functions – S

SaveToken

SayScreen

Seconds
Secs

Select

Set

SetAtLike

SetDate

SetKey

SetMode

SetPrec

SetTime

SetTypeahead

Sign

Sin

SinH

Space

Sqrt

Str

StrDiff

StrFormat

StrSwap
StrTran
StrZero
SubStr

String Functions

AddASCII

AfterAtNum

AllTrim
Asc

ASCIISum

ASCPos
At

AtAdjust

AtNum
AtRepl
AtToken

BeforAtNum

Chr

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

JustLeft
JustRight

Left
Len
Lower
LTrim

NumAt
NumToken
PadLeft
PadRight

PadC
PadL
PadR

POSALPHA
POSCHAR
POSDEL
POSDIFF
POSEQUAL
POSINS
POSLOWER
POSRANGE
POSREPL
POSUPPER

RangeRem
RangeRepl

RAt

RemAll

RemLeft
RemRight
ReplAll

Replicate

ReplLeft

ReplRight

RestToken

Right
RTrim

SaveToken

SetAtLike
Space
Str

StrDiff

StrFormat

StrSwap

StrTran
StrZero
SubStr

TabExpand
TabPack

Token

TokenAt
TokenEnd
TokenExit
TokenInit
TokenLower
TokenNext
TokenNum
TokenSep
TokenUpper

Transform
Trim
Upper
Val

ValPos
WordOne
WordOnly
WordRem
WordRepl
WordSwap

WordToChar


StrTran()

StrTran()

Translate substring value with a main string

Syntax

      StrTran( <cString>,  <cLocString>,  [<cRepString>],  
               [<nPos>], [<nOccurrences>] ) --> cReturn

Arguments

<cString> The main string to search

<cLocString> The string to locate in the main string

<cRepString> The string to replace the <cLocString>

<nPos> The first occurrence to be replaced

<nOccurrences> Number of occurrence to replace

Returns

<cReturn> Formated string

Description

This function searches for any occurrence of <cLocString> in <cString> and replaces it with <cRepString>. If <cRepString> is not specified, a NULL byte will replace <cLocString>.

If <nPos> is used, its value defines the first occurrence to be replaced. The default value is 1. Additionally, if used, the value of <nOccurrences> tell the function how many occurrences of <cLocString> in <cString> are to the replaced. The default of <nOccurrences> is all occurrences.

Examples

      ? StrTran( "Harbour  Power",  "  ",  " " )   // Harbour Power
      // Harbour Power The future  of  xBase
      ? StrTran( "Harbour  Power  The Future  of  xBase",  "  ",  " " ,  ,  2 )

Compliance

Clipper

Platforms

All(64K)

Files

Libraty is rtl

Seealso

SubStr(), At()

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()

RAt()

RAT()

Searches for a substring from the right side of a string.

Syntax

      RAT( <cSearch>, <cString> ) --> nPos

Arguments

<cSearch> Substring to search for

<cString> Main string

Returns

RAT() return the location of beginning position.

Description

This function searches through <cString> for the first existence of <cSearch>. The search operation is performed from the right side of <cString> to the left. If the function is unable to find any occurrence of <cSearch> in <cString>, the return value is 0.

Examples

      ? 'RAt( "cde", "abcdefgfedcba" ) = ' +;
         RAt( "cde", "abcsefgfedcba" )

Compliance

Clipper

Platforms

All  (64K)

Files

Library is rtl

Seealso

AT(), SUBSTR(), RIGHT()

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()