CSetRef()

CSetRef()

Determine return value of reference sensitive CT3 string functions

Syntax

      CSetRef( [<lNewSwitch>] ) -> lOldSwitch

Arguments

[<lNewSwitch>] .T. -> suppress return value .F. -> do not suppress return value

Returns

lOldSwitch old (if lNewSwitch is a logical value) or current state of the switch

Description

Within the CT3 functions, the following functions do not change the length of a string passed as parameter while transforming this string:

ADDASCII() BLANK() CHARADD() CHARAND() CHARMIRR() CHARNOT() CHAROR() CHARRELREP() CHARREPL() CHARSORT() CHARSWAP() CHARXOR() CRYPT() JUSTLEFT() JUSTRIGHT() POSCHAR() POSREPL() RANGEREPL() REPLALL() REPLLEFT() REPLRIGHT() TOKENLOWER() TOKENUPPER() WORDREPL() WORDSWAP()

Thus, these functions allow to pass the string by reference [@] to the function so that it may not be necessary to return the transformed string. By calling CSetRef (.T.), the above mentioned functions return the value .F. instead of the transformed string if the string is passed by reference to the function. The switch is turned off (.F.) by default.

Compliance

This function is fully CT3 compatible.

Platforms

All

Files

Source is ctstr.c, library is ct3.

Seealso

ADDASCII(), BLANK(), CHARADD(), CHARAND(), CHARMIRR(), CHARNOT(), CHAROR(), CHARRELREP(), CHARREPL(), CHARSORT(), CHARSWAP(), CHARXOR(), CRYPT(), JUSTLEFT(), JUSTRIGHT(), POSCHAR(), POSREPL(), RANGEREPL(), REPLALL(), REPLLEFT(), REPLRIGHT(), TOKENLOWER(), TOKENUPPER(), WORDREPL(), WORDSWAP()

CharRela()

CHARRELA

Correlates the character positions in paired strings

Syntax

       CHARRELA(<cSearchFor1>,<cString1>,<cSearchFor2>,
              <cString2>) --> nPosition

Arguments

<cSearchFor1> Designates the character that is searched for in <cString1>.

<cString1> Designates the character string to search with <cSearchFor1>.

<cSearchFor2> Designates the character that is searched for in <cString2>. <cString2> Designates the character string to search with <cSearchFor2>.

Returns

CHARRELA() returns the positions where <cSearchFor1> and <cSearchFor2> occur in the corresponding character strings.

Description

This function builds a relationship (CHAR RELAtion) between two character strings. It determines the positions where the characters in <cSearchFor1> appear in <cString1> and where the characters in <cSearchFor2> appear in <cString2>.

Note

. The function returns a value of 0 if no relationship is found.

Example

       Search for the first position in which a "b" appears in the first string
           and a "1" appears in the second:
           ? CHARRELA("b", "b b b b", "1", "bbb11111")      // 5

See also

CHARRELREP()

Harbour All Functions – C

CD / CHDIR / DirChange

CDoW

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

CLIPINIT
CMonth

Col

Cos

CosH

CountLeft
CountRight

CToBit

CToD

CToDoW
CToF
CToMonth
CToN

CurDir

CSetArgErr
CSetAtMuPa
CSetRef
CTCExit
CTCInit
CTExit
CTInit

CT_CHARRELREP

 CHARRELREP()
 Replaces characters in a string depending on their correlation
------------------------------------------------------------------------------
 Syntax

     CHARRELREP(<cSearchFor1>,<cString1>,<cSearchFor2>,
        <cString2>,<cReplaceExpression>) --> cString

 Arguments

     <cSearchFor1>  Designates one or more characters within <cString1>
     for which to search.

     <cString1>  Designates the character string where <cSearchFor1> is
     found.

     <cSearchFor2>  Designates one or more characters within <cString2>
     for which to search.

     <cString2>  [@]  Designates the character string where <cSearchFor2>
     is found.

     <cReplaceExpression>  Designates one or more characters to replace
     those at the established corresponding position within <cString2>.

 Returns

     The processed <cString2> is returned.

 Description

     This function is easier to use than it seems. If we proceed on the
     assumption that both search expressions and the replacement expression
     are only one character long, then the following steps occur:

     .  All positions are determined where <cSearchFor1> is found
        within <cString1>.

     .  All positions are found where <cSearchFor2> is found within
        <cString2>.

     .  The character in the <cString2> string is replaced by the
        character in the <cReplaceExpression>.

     This function can be used to simplify work with variables that contain
     screen memory.  If cPict1 contains the character "|"at position 34 and
     cPict2 contains the character "-" at the same position, then this
     position within cPict2 can be replaced with a new character, "+"', which
     represents the combination of the two.

     Multiple Exchanges 
     Both search expressions and the replacement expression can be longer
     than one character.  The previously described exchange procedure occurs
     repeatedly -- initially with the first character in the three character
     strings, then with the second, and so on.  The number of iterations is
     regulated by the length of <cSearchFor1>.  If <cSearchFor2> or the
     <cReplaceExpression> are shorter, then the last byte is used again.

 Notes

     .  The length of <cString2> determines the number of search
        procedures at any one time.  The length of <cSearchFor1> determines
        the number of possible exchanges.

     .  The return value of this function can be suppressed by
        implementing CSETREF() to save space in working memory.

     .  A use for multiple replacement using CHARRELREP() can be found
        in the accompanying sample programs.

 Example

     Determine every position where a "b" occurs in the first string and a
     "1" occurs in the second string.  The respective character is then
     exchanged for the one designated as the fifth parameter.

     ? CHARRELREP("b", "b b b b", "1", "bbb11111", "x")
                                                        //"bbb1x1x1"

See Also: CHARRELA() CSETREF() Introduction

 

Tools – String Manipulations

Introduction 
ADDASCII()   Adds a value to each ASCII code in a string
AFTERATNUM() Returns remainder of a string after nth appearance of sequence
ASCIISUM()   Finds sum of the ASCII values of all the characters of a string
ASCPOS()     Determines ASCII value of a character at a position in a string
ATADJUST()   Adjusts the beginning position of a sequence within a string
ATNUM()      Determines the starting position of a sequence within a string
ATREPL()     Searches for a sequence within a string and replaces it
ATTOKEN()    Finds the position of a token within a string
BEFORATNUM() Returns string segment before the nth occurrence of a sequence
CENTER()     Centers a string using pad characters
CHARADD()    Adds the corresponding ASCII codes of two strings
CHARAND()    Links corresponding ASCII codes of paired strings with AND
CHAREVEN()   Returns characters in the even positions of a string
CHARLIST()   Lists each character in a string
CHARMIRR()   Mirrors characters within a string
CHARMIX()    Mixes two strings together
CHARNOLIST() Lists the characters that do not appear in a string
CHARNOT()    Complements each character in a string
CHARODD()    Returns characters in the odd positions of a string
CHARONE()    Reduces adjoining duplicate characters in string to 1 character
CHARONLY()   Determines the common denominator between two strings
CHAROR()     Joins the corresponding ASCII code of paired strings with OR
CHARPACK()   Compresses (packs) a string
CHARRELA()   Correlates the character positions in paired strings
CHARRELREP() Replaces characters in a string depending on their correlation
CHARREM()    Removes particular characters from a string
CHARREPL()   Replaces certain characters with others
CHARSORT()   Sorts sequences within a string
CHARSPREAD() Expands a string at the tokens
CHARSWAP()   Exchanges all adjoining characters in a string
CHARUNPACK() Decompresses (unpacks) a string
CHARXOR()    Joins ASCII codes of paired strings with exclusive OR operation
CHECKSUM()   Calculates the checksum for a character string (algorithm)
COUNTLEFT()  Counts a particular character at the beginning of a string
COUNTRIGHT() Counts a particular character at the end of a string
CRYPT()      Encrypts and decrypts a string
CSETATMUPA() Determines setting of the multi-pass mode for ATXXX() functions
CSETREF()    Determines whether reference sensitive functions return a value
EXPAND()     Expands a string by inserting characters
JUSTLEFT()   Moves characters from the beginning to the end of a string
JUSTRIGHT()  Moves characters from the end of a string to the beginning
LIKE()       Compares character strings using wildcard characters
LTOC()       Converts a logical value into a character
MAXLINE()    Finds the longest line within a string
NUMAT()      Counts the number of occurrences of a sequence within a string
NUMLINE()    Determines the number of lines required for string output
NUMTOKEN()   Determines the number of tokens in a string
PADLEFT()    Pads a string on the left to a particular length
PADRIGHT()   Pads a string on the right to a particular length
POSALPHA()   Determines position of first alphabetic character in a string
POSCHAR()    Replaces individual character at particular position in string
POSDEL()     Deletes characters at a particular position in a string
POSDIFF()    Finds the first position from which two strings differ
POSEQUAL()   Finds the first position at which two strings are the same
POSINS()     Inserts characters at a particular position within a string
POSLOWER()   Finds the position of the first lower case alphabetic character
POSRANGE()   Determines position of first character in an ASCII code range
POSREPL()    Replaces one or more characters from a certain position
POSUPPER()   Finds the position of the first uppercase, alphabetic character
RANGEREM()   Deletes characters that are within a specified ASCII code range
RANGEREPL()  Replaces characters within a specified ASCII code range
REMALL()     Removes characters from the beginning and end of a string
REMLEFT()    Removes particular characters from the beginning of a string
REMRIGHT()   Removes particular characters at the end of a string
REPLALL()    Exchanges characters at the beginning and end of a string
REPLLEFT()   Exchanges particular characters at the beginning of a string
REPLRIGHT()  Exchanges particular characters at the end of a string
RESTTOKEN()  Recreates an incremental tokenizer environment
SAVETOKEN()  Saves the incremental tokenizer environment to a variable
SETATLIKE()  Provides an additional search mode for all AT functions
STRDIFF()    Finds similarity between two strings (Levenshtein Distance)
STRSWAP()    Interchanges two strings
TABEXPAND()  Converts tabs to spaces
TABPACK()    Converts spaces in tabs
TOKEN()      Selects the nth token from a string
TOKENAT()    Determines the most recent TOKENNEXT() position within a string
TOKENEND()   Determines if more tokens are available in TOKENNEXT()
TOKENINIT()  Initializes a string for TOKENNEXT()
TOKENLOWER() Converts initial alphabetic character of a token into lowercase
TOKENNEXT()  Provides an incremental tokenizer
TOKENSEP()   Provides separator before/after most recently retrieved TOKEN()
TOKENUPPER() Converts the initial letter of a token into upper case
VALPOS()     Determines numerical value of character at particular position
WORDONE()    Reduces multiple appearances of double characters to one
WORDONLY()   Finds common denominator of 2 strings on double character basis
WORDREPL()   Replaces particular double characters with others
WORDSWAP()   Exchanges double characters lying beside each other in a string
WORDTOCHAR() Exchanges double characters for individual ones