SoFunction
Updated on 2025-04-14

Collected WML Script Standard Function Library page 3/3


6.4 string function library
Name: string
Description: This function library contains a collection of string programs. A string can be a character array. Each character has an index. The index of the first character float of the string is 0. The length of the string is the number of characters in the array.
You can use some special separator symbols to define different strings, so that you can access these separator symbols to the elements defined by the element index. The index value of the first element in the string is 0. Each string separator symbol will be separated back into two elements, but characters cannot be used as separator symbols.
A character with a space may be one of the following characters:
TAB: Horizontal tabulation
VT: Vertical jump positioning (ertival tabulation)
FF:Page jump (from feed)
SP: space
LF: Line feed
CR: carriage return
length
Program: length(string)
Description: Return the length (number of characters) given to the string.
Parameters: string= string
Return value: integer or invalid
Exception: None
Example: var a="ABC";
var b=(a); //b=3
var c=(""); //c=0
var d=(342); //d=3
is Empty
Program: is Empty(string)
Description: If the string length is zero, the Boolean value is true, otherwise it is passed back to false.
Parameters: string= string
Return value: boolean value or invalid
Exception: None
Example: var a="Hello;
var b="";
var c=(a); //c=false
var c=(b); //d=ture
var c=(ture); //e=false
charAt
Program: charAt()
Description: Return the character specified by the index value in string.
Parameters: string=number of characters
index=number (pass back to the character specified by index)
Return value: string or invalid
Exception: If the value of index exceeds the range of the string, the empty string is returned ("")
Example: var a="My name is Joe"
var b=(a,0); //b= "M"
var c=(a,100); //c= ""
var d=(34.0); //d="3"
var e=(a,"first"); //e=invalid
subString
Program: subString(string, startIndex, length)
Description: Pass back a new string instead of the given string. The given index value of this new string begins, and its length determines the length of the given.
If startIndex is less than 0, 0 will be used as the index value.
If length is greater than the number of remaining characters, lengthht will be replaced by the number of remaining characters.
If startIndex is a floating point number, the correct integer value will be calculated first using ().
Parameters: string=number of characters
startIndex=number
length=number
Return value: string or invalid
Exception: If startIndex is greater than the last index value, the return will be empty string ("")
If lengthht<=0, pass the empty string ("")
Example: var a="ABCD";
var b=(a,1,2); //b="BC"
var c=(a,2,5); //c="CD"
var d=(1234,0,2); //d="12"
find
Program: find(string,substring)
Description: Pass the index value of the first character that matches the string substring and the original string string to be searched for.
If there is no matching, the integer value -1 will be passed.
If two characters pass are equal, it is defined as inconsistent.
Parameters: string= string
substring=String
Return value: integer or invalid
Exception: None
Example: var a="abcde";
var b=(a,"cd"); //b=2
var c=(34.2,"de"); //c=-1
var d=(a,"gz"); //d=-1
var e=(34,"3"); //e=0
replace
Program:eplace(tring,oldSubString,newSubString)
Description: Pass a new string. This new string is replaced by the old character passed to the given string string using the new string newSubString string. If the two strings are equal, they are defined as consistent.
Parameters: string= string
oldSubString=String
newSubString=String
Return value: string or invalid
Exception: None
Example: var a="Hello  is up Joe?";
var newName="Don";
var oldName="Joe";
var c=(a,oldName,newName); //c="Hello  is up Don?"
var d=(a,oldName,newName); //c="Hello  is up Don?"
element
Program: element(string,separator)
Description: Return the number of elements of the string string separated by the separator symbol separator. The empty string ("") is a valid element, which means that the program will never return a value less than or equal to 0.
Parameters: string= string
separator=String
Return value: integer or invalid
Exception: If separator is an empty string, return invalid
Example: var a="My name is Joe;Age 50";
var b=(a,"");//b=6
var c=(a,";");//c=3
var d=("",";");//d=1
var e=("a","");//e=1
var f=(";",";");//f=2
var g=(";;,;",";,");//g=4
separator=;
elementAt
Program: elementAt(string, index, separator)
Description: Find the index element of the string string, which is separated by the separator symbol, and passes back the corresponding element.
If the index value is less than 0, the first element is passed back.
If the index value is greater than the number of elements, the last element is passed back.
If the string is an empty string, the empty string is passed back.
If the index value is a floating point number, you must first use () to calculate the correct index value.
Parameters: string= string
index=number
separator=String
Return value: string or invalid
Exception: If separator is an empty string, return invalid
Example: var a="Hello  is up Joe?";
var b=(a,0,""); //b="My"
var b=(a,14,";"); //c=" "
var b=(a,1,";"); //d="Age 50"
removeAt
Program: removeAt(string, index, separator)
Description: Remove the separator, which matches the index value index, and the element has a string string, and pass the new string back.
If the index value is less than 0, the first element is passed back.
If the index value is greater than the number of elements, the last element is passed back.
If the string is an empty string, the empty string is passed back.
If the index value is a floating point number, you must first use () to calculate the correct index value.
Parameters: string= string
element=String
index=number
separator=String
Return value: string or invalid
Exception: If separator is an empty string, return invalid
Example: var a=" A A;B C D";
var s= "";
var c=(a,1,s); //b="A B C D"
var d=(a,0,";"); //c=" B C D"
var e=(a,14,";"); //d="A A"
replaceAt
Program: replaceAT(string, index, separator)
Description: In a specific index, use the given element element instead and pass the new string back.
If the index value is less than 0, the first element is passed back.
If the index value is greater than the number of elements, the last element is passed back.
If the string is an empty string, the empty string is passed back.
If the index value is a floating point number, you must first use () to calculate the correct index value.
Parameters: string= string
element=String
index=number
separator=String
Return value: string or invalid
Exception: If separator is an empty string, return invalid
Example: var a= "B C; E";
var s="";
var d=(a,"A",0,s); //b="A C;E"
var e=(a,"F",5,";"); //d="B C;F"
InsertAt
Program:insertAt(string, index, separator)
Description: Insert element element with corresponding separator into the original string string string, element in a specific element
If the index value is less than 0, 0 will be used as the index value.
If the index value is greater than the number of elements, the element element will be attached to the end of the string string.
If the string string is an empty string, a new string containing the given element element is returned.
If the index value is a floating point number, you need to use () to calculate the correct index value first.
Parameters: string= string
element=String
index=number
separator=String
Return value: string or invalid
Exception: If separator is an empty string, return invalid
Example: var a= "B C; E";
var s="";
var b=(a,"A",0,s); //b="A B C;E"
var c=(a,"X",3,s); //c="B C;E X"
var d=(a,"D",1,";"); //d="B C;D;E"
var e=(a,"F",5,";"); //e="B C;E;F"
squeeze
Program:squeeze(string)
Description: Reduce all consecutive spaces in the string string to one space.
Parameters:stromg=String
Return value: string or invalid
Exception: None
Example: var a="Hello";
var b="Bye  you!";
var c=(a); //c="Hello"
var d=(b); //d="Bye  you!"
trim
Program:trim(string)
Description: Delete all the beginning and consecutive spaces in the string string.
Parameters: string= string
Return value: string or invalid
Exception: None
Example: var a="Hello";
var b="Bye  you!";
var c=(a); //c="Hello"
var d=(b); //d="Bye  you!"
compare
Program: compare(string, string2)
Note: The back-pass value of this program will indicate the vocabulary relationship between string1 and string2. This relationship is based on the character code of the natural word set, and its back-pass value is as follows:
If string1 is less than string2, pass -1.
If string1 is equal to string2, pass -1.
If string1 is greater than string2, pass -1.
Parameters: string1= string
string2=String
Return value: integer or invalid
Exception: None
Example: var a="Hello";
var b="Hello";
var c=(a,b); //c=0
var d=("Bye","Jon"); //d=-1
var e=("Jon","Bye"); //e=1
toString
Program: toString(value)
Description: Returning a string that can represent the given value value is the same as the conversion of WML Script, except that the invlaid value will return a "invalid" string.
Parameter: value=arbitrary value
Return value: string
Exception: None
Example: var a=(12); // a="12"
var a=(true); // b="true"
format
Program: format(format,value)
Note: Convert the given value into a string and the formatted string provided by the given format format. This format string can only be from one specific format and can be placed anywhere in the string. If more than one format needs to be used, the leftmost format can be used. As for other formats, there are empty strings instead. These formats are as follows:
[width][.precision]type
If the width parameter is non-negative, it is a near-code integer. This parameter controls the minimum number of characters and appears. If the output word count is less than the specified width width, a blank will be added to the left of the string until it meets the minimum width requirement. The width parameter will never be a value value and is deleted. If the output word count is greater than the specific width or the specified width is not specified, all characters in the value will be displayed.
The precision parameter is a non-negative decimal integer. The quotation mark must be preceded by the (.) symbol. Its purpose is to set the accuracy of the input value. The solution to this value is related to the format given:
d Define the minimum number of appearances of the number. If the number in the value exceeds the precision value, the input value will be added 0 to its left. If the number of numbers exceeds the precision value, the value of the value will not be deleted. The preset precision value is 1. If the precision value is set to 0 and the value page is converted to 0, the result will be an empty string.
f Define the number of numbers after decimal decimal. If the decimal point appears, at least one digit after the decimal point is needed. This value will be rounded to the approximate number value. The preset precision is 6. If the precision is 0 or there is no number after the decimal point (.), the decimal point will not appear. When the number of numbers after the decimal point of the value value is less than the value of the precision, the letter 0 is added until the column is filled (such as: ("%2.3f", 1.2) will be "1.200")
s Defines the maximum number of characters to be displayed. The preset value is to display all characters. When the width value is greater than the precision value, the width value can be ignored. Unlike the width value, precision may only cause rounding of floating point values ​​or deletion of input values.
The type parameter is the only format parameter. After it appears in any format bar as an option, the type character determines that the given value will be interpreted into an integer, a floating point number or a string. The supported type parameters are as follows:
d Integer: The format of the input value [-]dddd, where dddd is one or more decimal numbers.
f Floating point number: The format of the input value [-], here dddd is one or more decimal numbers. The number before the decimal point is related to the size of the number, and the number after the decimal point is related to the accuracy.
s Standard: The appearance of characters is related to accuracy.
Percent characters (%) can be represented by additional percentage characters in the format string (%%).
Parameters:format=String
value=Arbitrary value
Return value: string or invalid
Exception; invalid format will return invalid value.
Example: var a=45;
var b=-45;
var c="now";
var d=1.2345678;
var e=("e:%6d",a); //e="e:45"
var e=("%6d",b); //f="-45"
var e=("e:%6d",a); //g="0045"
var e=("%6.4d",b); //h="-0045"
var e=("Do it %s",c); //i="Do it now"
var e=("%3f",d); //j="1.2345678"
var e=("%10.2f%%",a); //k="1.23%."
var e=("%3f %2f",a); //l="1.234567."
var e=("%.0d",0); //m=""
var e=("%.7d","Int"); //n="invalid"
var e=("%s",ture); //o="ture"
Previous page123Read the full text