Xbasic

Common Character Functions

Description

Some examples of common character functions and some guidance in using them.

  1. Create a new A5W page with the following content.

    <%a5
    dim ultext as C = "Four score and seven years ago"
    dim extraspaces as C = " Four score "
    dim allcaps as C = "SEVEN YEARS AGO"
    %>
    <html>
    <head>
    <meta name="generator" content="Alpha Anywhere HTML Editor">
    <title>Common Character Functions</title>
    </head>
    <body>
    <h1><font face=Verdana color=#0000ff>Some useful character
    manipulation functions</font></h1>
    <font face=Verdana size=2>
    <%a5
    ? "LOWER()changes \"" + ultext + "\" into \"" + LOWER(ultext) + "\"" + "<br>"
    ? "UPPER()changes " + QUOTE(ultext) + " into " + QUOTE(UPPER(ultext)) + "<br>"
    ? "W_UPPER()changes " + QUOTE(ultext) + " into " + QUOTE(W_UPPER(ultext)) + "<br>"
    ? "NW_LOWER()changes " + QUOTE(allcaps) + " into " + QUOTE(NW_LOWER(allcaps)) + "<br>"
    ? "LEFT(allcaps,5) changes " + QUOTE(allcaps) + " into " + QUOTE(LEFT(allcaps,5)) + "<br>"
    ? "RIGHT(allcaps,3) changes " + QUOTE(allcaps) + " into " + QUOTE(RIGHT(allcaps,3)) + "<p>"
    ? "LTRIM()changes " + QUOTE(extraspaces) + " into " + QUOTE(LTRIM(extraspaces)) + "<br>"
    ? "RTRIM()changes " + QUOTE(extraspaces) + " into " + QUOTE(RTRIM(extraspaces)) + "<br>"
    ? "ALLTRIM()changes " + QUOTE(extraspaces) + " into " + QUOTE(ALLTRIM(extraspaces)) + "<br>"
    </font>
    <p><font face=Verdana>Check out </font> <a href="http://support.alphasoftware.com/alphafivehelp/Xbasic/Character_Functions.htm"><font face=Verdana>Character Functions</font> </a><font
    face=Verdana> for more information.</font> </p>
    </body>
    </html>
    • Note in this example.

    • You can use the escape sequence \" to insert a quotation mark as a character, instead of as a formatting character.

    • You can use the QUOTE() function to save you the trouble of escaping quotation marks.

    • You can embed functions within functions,as in QUOTE(UPPER(ultext)).

    • Alpha Anywhere has more than 130 character manipulation functions that can do anything with text.

  2. Click File > Save As to save your page as "Common Character Functions"

  3. Click the 'lightning' icon to run the page in Live Preview. The result should look like this.

    images/WPT_Common_Character_Functions.gif

Example Functions

  • LOWER()

    Changes the case of the characters in a string to lower case.

  • UPPER()

    Changes the case of the characters in a string to upper case.

  • W_UPPER()

    Capitalizes the first character of each word.

  • NW_LOWER()

    Leaves the case of the first character of each word in unchanged and converts the remainder of the string to lower case.

  • LEFT()

    Returns a specified number of characters from the left (leading) side of a character string.

  • RIGHT()

    Returns a specified number of characters from the right (trailing) side of a character string.

  • LTRIM()

    Removes any invisible characters from the left side of a character string.

  • RTRIM()

    Removes any invisible characters from the right side of a character string.

  • ALLTRIM()

    Removes any invisible characters from the left and right sides of a character string.