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


Space()

Space()

Returns a string of blank spaces

Syntax

      Space( <nSize> ) --> cString

Arguments

<nSize> The length of the string

Returns

<cString> A string containing blank spaces

Description

This function returns a string consisting of <nSize> blank spaces. If the value of <nSize> is 0, a NULL string (“” ) will be returned.

This function is useful to declare the length of a character memory variable.

Examples

      PROCEDURE Main()
         LOCAL cBigString
         LOCAL cFirst
         LOCAL cString := Space( 20 )  // Create an character memory variable
                                       // with length 20
         ? Len( cString )      // 20
         cBigString := Space( 100000 ) // create a memory variable with 100000
                                       // blank spaces
         ? Len( cBigString )
         USE tests NEW
         cFirst := MakeEmpty( 1 )
         ? Len( cFirst )
         RETURN

      FUNCTION MakeEmpty( xField )
         LOCAL nRecord
         LOCAL xRetValue

         IF ! Empty( Alias() )
            nRecord := RecNo()
            dbGoto( 0 )
            IF ValType( xField ) == "C"
               xField := AScan( dbStruct(),  {| aFields | aFields[ 1 ] == Upper( xfield ) } )
            ELSE
               DEFAULT xField TO 0
               IF xField < 1 .OR. xField > FCount()
                  xfield := 0
               ENDIF
            ENDIF
            IF !( xfield == 0 )
               xRetvalue := FieldGet( xfield )
            ENDIF
            dbGoto( nrecord )
         ENDIF
         RETURN xRetvalue

Compliance

Clipper

Platforms

All(64K)

Files

Library is core

Seealso

PadC(), PadL(), PadR(), Replicate()

Replicate()

REPLICATE()

Repeats a single character expression

Syntax

      REPLICATE( <cString>, <nSize> )  --> cReplicateString

Arguments

<cString> Character string to be replicated

<nSize> Number of times to replicate <cString>

Returns

<cReplicateString> A character expression contain the <cString> fill character.

Description

This function returns a string composed of <nSize> repetitions of <cString>. The length of the character string returned by this function is limited to the memory available.

A value of 0 for <nSize> will return a NULL string.

Examples

      ? REPLICATE( "a", 10 )      // aaaaaaaaaa
      ? REPLICATE( "b", 100000 )

Tests

      See Examples

Compliance

Clipper

Platforms

All (64K)

Files

Library is rtl

Seealso

SPACE(), PADC(), PADL(), PADR()

PadR()

PADR()

Right-justifies an expression for a given width

Syntax

      PADR( <xVal>, <nWidth>, <cFill> ) --> cString

Arguments

<xVal> A Number, Character or Date value to pad

<nWidth> Width of output string

<cFill> Character to fill in the string

Returns

<cString> The right-justifies string of <xVal>

Description

This function takes an date, number, or character expression <xVal> and attempt to right-justify it within a string of a given width expressed as <nWidth>. The default character used to pad right side of <xVal> will be an blank space; however, this character may be explicitly specified the value of <cFill>.

If the length of <xVal> is longer then <nWidth>, this function will truncate the string <xVal> from the leftmost side to the length of <nWidth>.

Examples

      ? PADR( "Harbour", 20 )
      ? PADR( 34.5142, 20 )
      ? PADR( Date(), 35 )

Tests

      See examples

Compliance

Clipper

Platforms

All

Files

Library is rtl

Seealso

ALLTRIM(), PADC(), PADL()

PadL()

PADL()

Left-justifies an expression for a given width

Syntax

      PADL( <xVal>, <nWidth>, <cFill> )  --> cString

Arguments

<xVal> An number, Character or date to pad

<nWidth> Width of output string

<cFill> Character to fill in the string

Returns

<cString> The left-justifies string of <xVal>

Description

This function takes an date, number, or character expression <xVal> and attempt to left-justify it within a string of a given width expressed as <nWidth>. The default character used to pad left side of <xVal> will be an blank space; however, this character may be explicitly specified the value of <cFill>.

If the length of <xVal> is longer then <nWidth>, this function will truncate the string <xVal> from the leftmost side to the length of <nWidth>.

Examples

      ? PADL( "Harbour", 20 )
      ? PADL( 34.5142, 20 )
      ? PADL( Date(), 35 )

Tests

      See examples

Compliance

Clipper

Platforms

All

Files

Library is rtl

Seealso

ALLTRIM(), PADC(), PADR()

SP_CENTR

CENTR()

  Short:
  ------
  CENTR() Centers a string in x spaces

  Returns:
  --------
  <cCentered> => String centered

  Syntax:
  -------
  CENTR(cInString,[nSpaces])

  Description:
  ------------
  Centers <cInString> in [nSpaces] spaces

  [nSpaces] spaces is optional. Default is current
  string length

  Examples:
  ---------

   cString := "Superfunction "

   cString := CENTR(cString,20)     //   => "  Superfunction  "

  Notes:
  -------
  In Clipper 5.01, use PADC(), which does the same
  thing and faster. Here for compatibility.

  Source:
  -------
  S_CENTR.PRG