More Character Functions
Description
Some character functions and a brief description on how to use them.
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>More Character Functions</title> </head> <body> <p> <h1><font face=Verdana color=#0000ff>Some more useful character functions</font></h1> <font face=Verdana size=2> <%a5 ? "ATC()returns the position of 'seven' in " + QUOTE(ultext) + ", which is " + ATC("seven", ultext) + "<p>" ? "CHR()returns the character corresponding to a value. For example CHR(66) returns " + CHR(66) + "<p>" ? "LEN()returns the length of " + QUOTE(ultext) + ", which is " + LEN(ultext) + "<p>" ? "OCCURS()returns the number of times one string occurs in another. For example OCCURS(\"o\", ultext) returns " + OCCURS("o", ultext) + "<p>" ? "STRITRAN()replaces characters. For example STRITRAN(ultext, \"o\", \"X\") returns " + STRITRAN(ultext, "o", "X") + "<p>" ? "STR()converts a number to a string. For example STR(345.67,5,1) returns " + STR(345.67,5,1) + "<p>" ? "SUBSTR()extracts one string from another. For example SUBSTR(ultext,6,5) returns " + SUBSTR(ultext,6,5) + "<p>" ? "VAL()converts a string to a number. For example VAL(\"34 cows\") returns " + VAL("34 cows") + "<p>" ? "WORD()extracts the Nth word from a string. For example WORD(\"chickens;ducks;geese\",2,\";\") returns " + WORD("chickens;ducks;geese",2,";") + "<p>" %> </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 embed functions within functions,as in QUOTE(UPPER(ultext)).
Alpha Anywhere has more than 130 character manipulation functions that can do anything with text.
Click File > Save As to save your page as "More Character Functions".
Click the 'lightning' icon to run the page in Live Preview. The result should look like this.
Example Functions
ATC()
Returns the position of a string within another string.
CHR()
Returns the ASCII character corresponding to an integer.
LEN()
Returns the length of a character string.
OCCURS()
Returns the number of times one string appears in another string.
STRITRAN()
Replaces characters in a string.
STR()
Converts a number to a string.
SUBSTR()
Extracts one string from another.
VAL()
Converts a string to a number, where possible.
WORD()
Extracts the Nth word from a string.