CharNoList()

CHARNOLIST()

Generates a list of all characters not contained in a string

Syntax

      CHARNOLIST( [<cString>] ) -> cCharacterList

Arguments

[<cString>] is the string for whom the function generates a list of all characters not contained in that string Default: “” (empty string)

Returns

<cCharacterList> a list of the characters that are not contained in <cString>

Description

The CHARNOLIST() function generates a list of those characters that are not contained in <cString>. This list can contain each character only once, so that its maximum length is 256. The list is alphabetically sorted.

Examples

      ? charnolist( charnolist( "Hello World !" ) ) // --> " !HWdelor"

Tests

      charnolist( charnolist( "Hello World !" ) ) == charslist( "Hello World !" )
      charnolist( charnolist( NIL ) ) == ""

Compliance

CHARNOLIST() is compatible with CT3’s CHARNOLIST().

Platforms

All

Files

Source is charlist.c, library is libct.

Seealso

CHARLIST(), CHARSLIST(), CHARHIST()

CharMix()

CHARMIX()

Mix two strings

Syntax

      CHARMIX( <cString1>[, <cString2>] ) --> cMixedString

Arguments

<cString1> String that will be mixed with the characters from <cString2>

[<cString2>] String whose characters will be mixed with the one from <cString1>. Default: ” ” (string with one space char)

Returns

<cMixedString> Mixed string

Description

The CHARMIX() function mixes the strings <cString1> and <cString2>. To do this it takes one character after the other alternatively from <cString1> and <cString2> and puts them in the output string. This procedure is stopped when the end of <cString1> is reached. If <cString2> is shorter than <cString1>, the function will start at the begin of <cString2> again. If on the other hand <cString2> is longer than <cString1>, the surplus characters will be omitted.

Examples

      ? CHARMIX( "ABC", "123" )    // "A1B2C3"
      ? CHARMIX( "ABCDE", "12" )   // "A1B2C1D2E1"
      ? CHARMIX( "AB", "12345" )   // "A1B2"
      ? CHARMIX( "HELLO", " " )    //  "H E L L O "
      ? CHARMIX( "HELLO", "" )     //  "HELLO"

Tests

      CHARMIX( "ABC", "123" )  == "A1B2C3"
      CHARMIX( "ABCDE", "12" ) == "A1B2C1D2E1"
      CHARMIX( "AB", "12345") == "A1B2"
      CHARMIX( "HELLO", " " )   == "H E L L O "
      CHARMIX( "HELLO", "" )   == "HELLO"

Compliance

CHARMIX() is compatible with CT3’s CHARMIX().

NOTE: CA-Tools version of CHARMIX() will hang if the second parameter is an empty string, this version will not.

Platforms

All

Files

Source is charmix.c, library is ct3.

Seealso

CHAREVEN(), CHARODD()

CharMirr()

CHARMIRR()

Mirror a string

Syntax

      CHARMIRR( <[@]cString>, [<lDontMirrorSpaces>] ) -> cMirroredString

Arguments

<[@]cString> is the string that should be mirrored [<lDontMirrorSpaces>] if set to .T., spaces at the end of <cString> will not be mirrored but kept at the end Default: .F., mirror the whole string

Returns

<cMirroredString> the mirrored string

Description

The CHARMIRR() function mirrors a string, i.e. the first character will be put at the end, the second at the last but one position etc.. One can use this function for index searches, but then, the spaces at the end of the string should not be mirrored. One can omit the return value of the function by setting the CSETREF() switch to .T., but <cString> must then be passed by reference to get a result.

Examples

      ? charmirr( "racecar" )        // "racecar"
      ? charmirr( "racecar  ", .T. ) // "racecar  "
      ? charmirr( "racecar  ", .F. ) // "  racecar"

Tests

      charmirr( "racecar" ) == "racecar"
      charmirr( "racecar  ", .T. ) == "racecar  "
      charmirr( "racecar  ", .F. ) == "  racecar"

Compliance

CHARMIRR() is compatible with CT3’s CHARMIRR().

Platforms

All

Files

Source is charmirr.c, library is ct3.

Seealso

CSETREF()

CharList()

CHARLIST()

Generates a list of all characters in a string

Syntax

      CHARLIST( [<cString>] ) -> cCharacterList

Arguments

[<cString>] is the string for whom the function generates a list of all characters Default: “” (empty string)

Returns

<cCharacterList> a list of the characters in <cString>

Description

The CHARLIST() function generates a list of those characters that are contained in <cString>. This list can contain each character only once, so that its maximum length is 256. The list lists those characters first that are occuring in <cString> first.

Examples

      ? charlist( "Hello World !" ) // --> "Helo Wrd!"

Tests

      charlist( "Hello World !" ) == "Helo Wrd!"
      charlist( NIL ) == ""

Compliance

CHARLIST() is compatible with CT3’s CHARLIST().

Platforms

All

Files

Source is charlist.c, library is libct.

Seealso

CHARNOLIST(), CHARSLIST(), CHARHIST()

CharHist()

CHARHIST()

Generates a character histogram of a string

Syntax

      CHARHIST( [<cString>] ) -> aCharacterCount

Arguments

[<cString>] is the string for whom the function generates a character histogram Default: “” (empty string)

Returns

<aCharacterCount> an array with 256 elements where the nth element contains the count of character #(n-1) in cString

Description

The CHARHIST() function generates a character histogram of those characters that are contained in <cString>. This histogram is stored in an 256-element array where the nth element contains the count of ASCII character #(n-1) in <cString>.

Examples

      ? charhist( "Hello World !" )[ 109 ] // --> 3  // Chr( 108 ) == "l"

Tests

      charhist( "Hello World !" )[ 109 ] == 3
      eval( {|| AEval( charhist( "Hello World !" ), {| x | nTotal += x } ), nTotal == Len( "Hello World !" ) }

Compliance

CHARHIST() is only available in Harbour’s CT3 library.

Platforms

All

Files

Source is charlist.c, library is libct.

Seealso

CHARLIST(), CHARNOLIST(), CHARSLIST()

CharEven()

CHAREVEN()

Returns the characters on the even positions in a string

Syntax

      CHAREVEN( <cString> ) --> cEvenString

Arguments

<cString> processed string

Returns

<cEvenString> a string containing all character from even positions in <cString>

Description

The CHAREVEN() function looks for the characters on the even positions in a given string, collects them and returns them as a string.

Examples

      ? CHAREVEN( " H E L L O !" ) // -> "HELLO!"

Tests

      CHAREVEN( " 1 2 3 4 5" ) == "12345"
      CHAREVEN( " 1 2 3 4 " ) == "1234"
      CHAREVEN( " " ) == ""

Compliance

CHAREVEN() is compatible with CT3’s CHAREVEN().

Platforms

All

Files

Source is charevod.c, library is ct3.

Seealso

CHARODD(), CHARMIX()

CharAnd()

CHARAND()

Combine corresponding ASCII value of two strings with bitwise AND

Syntax

      CHARAND( <[@]cString1>, <cString2> ) --> cAndString

Arguments

<[@]cString1> first string <cString2> second string

Returns

<cAndString> string with bitwise AND combined ASCII values

Description

The CHARAND() function constructs a new string from the two strings passed as parameters. To do this, it combines the ASCII values of the corresponding characters of both strings with a bitwise AND-operation and places a character in the resulting string whose ASCII value equals to the result of that operation. If the first string is passed by reference, the resulting string is stored in <cString1>, too. By setting the CSETREF()-switch to .T., the return value can be omitted. If <cString2> is shorter than <cString1> and the last character of <cString2> has been processed, the function restarts with the first character of <cString2>.

Examples

      // clear the LSB
      ? charand( "012345678", chr( 254 ) ) // --> "002244668"
      ? charand( "012345678", chr( 254 ) + chr( 252 ) ) // --> "002044648"

Tests

      charand( "012345678", chr( 254 ) ) == "002244668"
      charand( "012345678", chr( 254 ) + chr( 252 ) ) == "002044648"

Compliance

CHARAND() is compatible with CT3’s CHARAND().

Platforms

All

Files

Source is charop.c, library is ct3.

Seealso

CHARADD(), CHARSUB(), CHARNOT(), CHAROR(), CHARXOR(), CHARSHL(), CHARSHR(), CHARRLL(), CHARRLR(), CSETREF()

CharAdd()

CHARADD()

Adds corresponding ASCII value of two strings

Syntax

      CHARADD( <[@]cString1>, <cString2> ) --> cAddString

Arguments

<[@]cString1> first string <cString2> second string

Returns

<cAddString> string with added ASCII values

Description

The CHARADD() function constructs a new string from the two strings passed as parameters. To do this, it adds the ASCII values of the corresponding characters of both strings and places a character in the resulting string whose ASCII value equals to that sum (modulo 256). If the first string is passed by reference, the resulting string is stored in <cString1>, too. By setting the CSETREF()-switch to .T., the return value can be omitted. If <cString2> is shorter than <cString1> and the last character of <cString2> has been processed, the function restarts with the first character of <cString2>.

Examples

      ? charadd( "012345678", chr( 1 ) ) // --> "123456789"
      ? charadd( "123456789", chr( 255 ) ) // --> "012345678"
      ? charadd( "0000", chr( 0 ) + chr( 1 ) + chr( 2 ) + chr( 3 ) )
                  // --> "0123"

Tests

      charadd( "012345678", chr( 1 ) ) == "123456789"
      charadd( "012345678", chr( 1 ) + chr( 2 ) ) == "133557799"
      charadd( "123456789", chr( 255 ) ) == "012345678"
      charadd( "123456789", chr( 255 ) + chr( 254 ) ) == "002244668"

Compliance

CHARADD() is compatible with CT3’s CHARADD().

Platforms

All

Files

Source is charop.c, library is ct3.

Seealso

CHARSUB(), CHARAND(), CHARNOT(), CHAROR(), CHARXOR(), CHARSHL(), CHARSHR(), CHARRLL(), CHARRLR(), CSETREF()

Celsius()

CELSIUS()

Temperature conversion Fahrenheit to Celsius

Syntax

      CELSIUS( nDegreeFahrenheit ) --> nDegreeCelsius

Arguments

<nDegreeFahrenheit> temperature in degree Fahrenheit

Returns

<nDegreeCelsius> temperate in degree Celsius

Description

CELSIUS() converts temperature values measured in the Fahrenheit scale to the Celsius scale.

Examples

      // melting point of water in standard conditions
      ? celsius( 32.0 )      // --> 0.0
      // boiling point of water in standard conditions
      ? celsius( 212.0 )     // --> 100.0

Tests

      celsius( 32.0 )  == 0.0
      celsius( 212.0 ) == 100.0

Compliance

CELSIUS() is compatible with CT3’s CELSIUS().

Platforms

All

Files

Source is num1.c, library is libct.

Seealso

FAHRENHEIT()

Ceiling()

CEILING()

Rounds up a number to the next integer

Syntax

      CEILING( <nNumber> ) -> nUpRoundedNumber

Arguments

<nNumber> number to round up

Returns

<nUpRoundedNumber> the rounded number

Description

The function CEILING() determines the smallest integer that is bigger than <nNumber>.

Examples

      ? ceiling( 1.1 )  // --> 2.0
      ? ceiling( -1.1 ) // --> -1.0

Tests

      ceiling( 1.1 )  == 2.0
      ceiling( -1.1 ) == -1.0

Compliance

CEILING() is compatible with CT3’s CEILING().

Platforms

All

Files

Source is math.c, library is libct.

Seealso

FLOOR