Totel:14 Click:
1
2 3
WMLScript Interview Questions And Answers
Page 1
Questions 1 How to validate a user input using WMLScript?
Answer
I will explain you to validate a user input by using WMLScript.
Example I have given below, used to create an simple WML card. For that ask user to input your SSN(social security number).SSN is an identification number used by U.S.Social Security Administration.
We use WMLScript to verify whether the user’s input is formatted correctly. Following this verification, we will alert the user by the WMLScript to let them know whether their number was been accepted or not.
In this example we show typical usage of a WMLScript on the client.
We create a normal WML file containing the two cards: input card and the results card(program1).
Accepting input will result in the validateSSN() function which is being called. Note here that this function is stored in the separate .wmls file and is declared within this file using the keyword extern.
The extern allows a function to be called by another functions or the WML events that do exist outside the function’s source file. To keep the function "private", simply declare that function without using the keyword extern .
Example:
Program1 - WMLScriptExample.wml
<?xml version='1.0'?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="SSN" title="SSN:">
<do type="accept" label="Results">
<go href="WMLScriptExample.wmls#validateSSN($(SSN))"/>
</do>
<p>
Enter SSN: <input type="text" name="SSN"/>
</p>
</card>
<card id="Results" title="Results:">
<p>
You entered:
SSN: $(SSN)
</p>
</card>
</wml>
Program2 - WMLScriptExample.wmls
extern function validateSSN(SSN)
{
if (String.length(SSN) != 9)
{
WMLBrowser.setVar("SSN", "Error: String must be 9 digits long.");
}
WMLBrowser.go("WMLScriptExample.wml#Results");
};
Questions 2 What is WMLScript standard libraries?
Answer
We can't create new objects in WMLScript because WMLScript doesn't support object oriented programming.So,WMLScript provide us six pre-defined libraries to handle many comman tasks these are,
1.Lang:
This library functions are usefor data type manipulation,absolute value calculations and random number generation.
2.Float:
This provide us some typical functions are sqrt(),find(),replace() and trim() function.
3.String:
This provide us library functions length(),charAt(),find(),replace() and trim() function.
4.URL:
This provide us functions getPath(), getReferer() and getHost().
5.WMLBrowser:
This provide us functions next(), getCurrentCard(),go(),prev() and refresh().
6.Dialogs:
This provide us functions promt(), confirm() and alert().
Questions 3 What is WML function?
Answer
We can executed WMLScript Statements together as a unit are called as functions.Below I have declare a function using WMLScript.
extern function identifier(FormatParameterList)
Block ;
extern keyword is optional and used to specify the function which can be called from outside a current compilation unit in which that function is been defined.
We can declare a function in WMLScript like that,
function RunTime(d, s)
{
var t = d / s;
return t;
};
Where, t,d and s stand for time,distance and speed respectively.
Questions 4 How to use WMLScript WMLBrowser library?
Answer
WMLBrowser library has functions that are use to access browser variable.WMLBrowser library functions are,
1.getCurrentCard()
Using this we can return URL of current card.
2.getVar()
Use to return the values of variable.
3.go()
Use for goes to new card.
4.newContext()
Use to clear all variables.
5.prev()
Use for goes to the previous card.
6.refresh()
Use to refresh the current card.
7.setvar()
Use to set the values of variable.
Questions 5 What is WMLScript dialogs library?
Answer
Dialogs library has functios that we use to display alert messages.WMLScript dialogs library functions are,
1.alert()
Use to display a message and wait for conformation.
2.conferm()
Use to display a message and wait for answer.
3.promt()
Use to display a question and wait for input.
Goto Page:
1
2 3
WMLScript Objective Questions And Answers
WMLScript Objective Questions And Answers
WMLScript Interview Questions And Answers
WMLScript Subjective Questions And Answers
R4R,WMLScript Objective, WMLScript Subjective, WMLScript Interview Questions And Answers,WMLScript,WMLScript Interview,WMLScript Questions ,WMLScript Answers