This section discusses the standard WML Script function library.
6.1 WML Script Rules
These standard function libraries provide a mechanism to extend the WML Script language. These specific function libraries must follow the rules of WML Script.
Supported data formats
The following WML Script format is used in the program definition, so that the format of program parameters and slewing values can be recorded.
Boolean
Integer
Float
String
Invalid
In addition, if both integer and floating point parameter value formats are acceptable, number can be used to record the parameter format. If the format used is the supported format, any can be used to record.
Data format conversion
The method of handling errors in the function library program is the same as that in the WML Script language.
The invalid program parameter will generate the invalid back-pass value.
If the program's parameters cannot be converted into the required parameter format, an invalid back-pass value will be generated.
The errors related to the program are derived and returned with an appropriate error code. As for this value, it depends on how each program is defined.
6.2 Lang function library
Name:Lang
Note: The programs contained in this function library are closely related to the core of the WML Script language.
abs
Program:abs(value)
Description: Return the absolute value of the given number.
If the given number is an integer, the integer is passed back.
If the given number is a floating point number, the floating point number is returned.
Parameter: value=number.
Return value: number or invalid.
Exception: var a =-3;
var b =(a);//b=3
min
Example: var a = -3
var b = (a);
var c = ();
var d = (45、76.3);//d=45(ingteger)
var e = (45、76.3);//e=45(ingteger)
max
Program:max(value1,value2)
Note: The value of the return value is given to the larger value between the two numbers. The value of the return value is the same as the selected value and the format. The selection method is as follows:
The WML Script operator data format integer and floating point conversion rules can be used to confirm the data format to perform comparison actions.
Parameter: value1 = number
value2 = number
Return value: number or invalid
Exception: None
Example: var a =-3;
var b =(a);//b=3
var c = ();
var d = (45、76.3);//d=45(ingteger)
var e = (45、76.3);//e=45(float)
parseInt
Program: parseInt(value)
Description: Return the integer value defined by the string value. The legal integer syntax is defined by the WML Script numerical string grammar or the near-value integer is a word. The following are additional analytical rules:
If the first character is not started by +, - or decimal numbers, the interpretation ends.
Result: The parsed string returns to the integer value.
Example: var i =("1234"); // i=1234
var j =("100 m/s"); // j=100
parseFloat
Program: parseFloat(value)
Description: Return the floating point value defined by the string value. The legal floating point syntax is defined by the WML Script numerical string grammar or the near-value integer real characters. The following are additional analytical rules:
The first character cannot be parsed into a floating-point expression, and the parsing ends.
End: The parsed string is converted back into a floating point number.
Parameters: value= string
Return value: floating point number or invalid
Exception: parsing errors are passed back to invalid
Example: var a =("123.7 Hz"); // a=123.7
var b =("7.34e2 Hz"); // b=7.34e2
var c =("70.0e-2 F"); // c=70.0e-2
var d =("-"); // d=0.1
var e =("100"); // e=100.0
var f =("Number:5.5"); // f=invalid
var g =("7.3e meters"); // g=invalid
var h =("7.3e- m/s"); // h=invalid
isInt
Program: isInt(value)
Note: If the pre-value value can be converted to an integer using parseInt(value), the Boolean value will be returned, otherwise the Boolean value will be passed back.
Parameter: value=arbitrary value
Return value: boolean value or invalid
Exception: None
Example: var a=("-123"); //ture
var a =("123.33"); //ture
var a =("string"); //false
var a =("#123"); //false
var a =("invalid"); //invalid
isFloat
Program: isFloat(value)
Note: If the pre-value value can be converted to an integer using parseInt(value), the Boolean value will be returned, otherwise the Boolean value will be passed back.
Parameter: value=arbitrary value
Return value: boolean value or invalid
Exception: None
Example: var a=("-123"); //ture
var a =("123.33"); //ture
var a =("string"); //false
var a =("#123"); //false
var a =("invalid"); //invalid
maxInt
Program:maxInt()
Description: Pass back the largest integer value.
Parameters: None
Return value: integer 2147483647
Exception: None
Example: var a =();
minInt
Program: minInt()
Description: Return the smallest integer value
Parameters: None
Return value: integer-2147483647
Exception: None
Example: var a =();
float
Program: float()
Note: If there is a floating point number, it will be sent back to ture, and if there is no, it will be sent back to false.
Parameters: None
Return value: Boolean value
Exception: None
Example: var floatsSupported = ();
exit
Program:exit(value)
Description: End the interpretation of the WML Script bitcode and then return to the control of the caller of the WML Script interpreter, and return the specified value. You can use this program to execute the end of the general program, and the execution of the WML Script bitcode must be stopped.
Parameters:valre=arbitrary value
Return value: None, the program ends the interpretation
Exception: None
Example:("Value:" + myVal);//Returns a string
Lang,exit(invalid);// Returns invalid
abort
Program:abort(errorDescription)
Description: Abort the interpretation of WML Script bitcode and then return to the control of the caller of the WML Script interpreter, and return an errorDescription. You can use this program to execute an abnormal abort. The caller detects a serious error, and the execution of WML Script must be interrupted.
If the format of the errorDescription is invalid, the string invalid is used instead of the errorDescription.
Parameters: errorDescription = string
Return value: None, the program ends the interpretation
Exception: None
Example:("Error:" + errVal); // Error value string
radndom
Program:random(value)
Note: Returning the integer value of a positive number, that is, it must be greater than or equal to zero, but it must be less than the given value value. Returning the value is a value randomly selected by the near normal distribution.
Parameters: value= integer
Return value: integer or invalid
Exception: If value is equal to 0, the program passes back 0
If the value is less than 0, the program returns invalid
Example: var a =10;
var b =(5.1)*a;//b=0..50
var c = ("string"); // c=invalid
reed
Program:seed(alue)
Note: Initialization requires random number order and an empty string is passed back
If the value is 0 or a positive integer, the given value is used to initialize, otherwise a randomly initialized value is used.
If the value is a floating point number, the exact integer value will be calculated first using ().
Parameters: value= integer
Return value: string or invalid]
Exception: None
Example: var a =(123);// a=""
var b =(20); // b=0..20
var c = ("seed"); // c=invalid (random seed //left unchanged)
characterSet
Program: characterSet()
Note: Returning the word set supported by the WML Script interpreter is just an integer to record the MIB Enum value set by IANA, which can only represent all word sets.
Parameters: None
Return value: integer
Exception: None
Example: Var charset = (); //charset = 4 for latinl
6.1 WML Script Rules
These standard function libraries provide a mechanism to extend the WML Script language. These specific function libraries must follow the rules of WML Script.
Supported data formats
The following WML Script format is used in the program definition, so that the format of program parameters and slewing values can be recorded.
Boolean
Integer
Float
String
Invalid
In addition, if both integer and floating point parameter value formats are acceptable, number can be used to record the parameter format. If the format used is the supported format, any can be used to record.
Data format conversion
The method of handling errors in the function library program is the same as that in the WML Script language.
The invalid program parameter will generate the invalid back-pass value.
If the program's parameters cannot be converted into the required parameter format, an invalid back-pass value will be generated.
The errors related to the program are derived and returned with an appropriate error code. As for this value, it depends on how each program is defined.
6.2 Lang function library
Name:Lang
Note: The programs contained in this function library are closely related to the core of the WML Script language.
abs
Program:abs(value)
Description: Return the absolute value of the given number.
If the given number is an integer, the integer is passed back.
If the given number is a floating point number, the floating point number is returned.
Parameter: value=number.
Return value: number or invalid.
Exception: var a =-3;
var b =(a);//b=3
min
Example: var a = -3
var b = (a);
var c = ();
var d = (45、76.3);//d=45(ingteger)
var e = (45、76.3);//e=45(ingteger)
max
Program:max(value1,value2)
Note: The value of the return value is given to the larger value between the two numbers. The value of the return value is the same as the selected value and the format. The selection method is as follows:
The WML Script operator data format integer and floating point conversion rules can be used to confirm the data format to perform comparison actions.
Parameter: value1 = number
value2 = number
Return value: number or invalid
Exception: None
Example: var a =-3;
var b =(a);//b=3
var c = ();
var d = (45、76.3);//d=45(ingteger)
var e = (45、76.3);//e=45(float)
parseInt
Program: parseInt(value)
Description: Return the integer value defined by the string value. The legal integer syntax is defined by the WML Script numerical string grammar or the near-value integer is a word. The following are additional analytical rules:
If the first character is not started by +, - or decimal numbers, the interpretation ends.
Result: The parsed string returns to the integer value.
Example: var i =("1234"); // i=1234
var j =("100 m/s"); // j=100
parseFloat
Program: parseFloat(value)
Description: Return the floating point value defined by the string value. The legal floating point syntax is defined by the WML Script numerical string grammar or the near-value integer real characters. The following are additional analytical rules:
The first character cannot be parsed into a floating-point expression, and the parsing ends.
End: The parsed string is converted back into a floating point number.
Parameters: value= string
Return value: floating point number or invalid
Exception: parsing errors are passed back to invalid
Example: var a =("123.7 Hz"); // a=123.7
var b =("7.34e2 Hz"); // b=7.34e2
var c =("70.0e-2 F"); // c=70.0e-2
var d =("-"); // d=0.1
var e =("100"); // e=100.0
var f =("Number:5.5"); // f=invalid
var g =("7.3e meters"); // g=invalid
var h =("7.3e- m/s"); // h=invalid
isInt
Program: isInt(value)
Note: If the pre-value value can be converted to an integer using parseInt(value), the Boolean value will be returned, otherwise the Boolean value will be passed back.
Parameter: value=arbitrary value
Return value: boolean value or invalid
Exception: None
Example: var a=("-123"); //ture
var a =("123.33"); //ture
var a =("string"); //false
var a =("#123"); //false
var a =("invalid"); //invalid
isFloat
Program: isFloat(value)
Note: If the pre-value value can be converted to an integer using parseInt(value), the Boolean value will be returned, otherwise the Boolean value will be passed back.
Parameter: value=arbitrary value
Return value: boolean value or invalid
Exception: None
Example: var a=("-123"); //ture
var a =("123.33"); //ture
var a =("string"); //false
var a =("#123"); //false
var a =("invalid"); //invalid
maxInt
Program:maxInt()
Description: Pass back the largest integer value.
Parameters: None
Return value: integer 2147483647
Exception: None
Example: var a =();
minInt
Program: minInt()
Description: Return the smallest integer value
Parameters: None
Return value: integer-2147483647
Exception: None
Example: var a =();
float
Program: float()
Note: If there is a floating point number, it will be sent back to ture, and if there is no, it will be sent back to false.
Parameters: None
Return value: Boolean value
Exception: None
Example: var floatsSupported = ();
exit
Program:exit(value)
Description: End the interpretation of the WML Script bitcode and then return to the control of the caller of the WML Script interpreter, and return the specified value. You can use this program to execute the end of the general program, and the execution of the WML Script bitcode must be stopped.
Parameters:valre=arbitrary value
Return value: None, the program ends the interpretation
Exception: None
Example:("Value:" + myVal);//Returns a string
Lang,exit(invalid);// Returns invalid
abort
Program:abort(errorDescription)
Description: Abort the interpretation of WML Script bitcode and then return to the control of the caller of the WML Script interpreter, and return an errorDescription. You can use this program to execute an abnormal abort. The caller detects a serious error, and the execution of WML Script must be interrupted.
If the format of the errorDescription is invalid, the string invalid is used instead of the errorDescription.
Parameters: errorDescription = string
Return value: None, the program ends the interpretation
Exception: None
Example:("Error:" + errVal); // Error value string
radndom
Program:random(value)
Note: Returning the integer value of a positive number, that is, it must be greater than or equal to zero, but it must be less than the given value value. Returning the value is a value randomly selected by the near normal distribution.
Parameters: value= integer
Return value: integer or invalid
Exception: If value is equal to 0, the program passes back 0
If the value is less than 0, the program returns invalid
Example: var a =10;
var b =(5.1)*a;//b=0..50
var c = ("string"); // c=invalid
reed
Program:seed(alue)
Note: Initialization requires random number order and an empty string is passed back
If the value is 0 or a positive integer, the given value is used to initialize, otherwise a randomly initialized value is used.
If the value is a floating point number, the exact integer value will be calculated first using ().
Parameters: value= integer
Return value: string or invalid]
Exception: None
Example: var a =(123);// a=""
var b =(20); // b=0..20
var c = ("seed"); // c=invalid (random seed //left unchanged)
characterSet
Program: characterSet()
Note: Returning the word set supported by the WML Script interpreter is just an integer to record the MIB Enum value set by IANA, which can only represent all word sets.
Parameters: None
Return value: integer
Exception: None
Example: Var charset = (); //charset = 4 for latinl
123Next pageRead the full text