In the Mobile Channels scripting environment, there are five classes of statements:
The assignment statement is of the following form:
<variable> = <expression>
The IF statement provides conditional flow of control. The END IF part is required. The statements after a logical expression are not evaluated unless the logical expression evaluates to 1. The conditional statement is one of the following forms:
IF <logical expression> THEN
<statement>
END IF
– Or –
IF <logical expression> Then
<statement1>
Else
<statement2>
End IF
– Or –
IF <logical expression1> Then
<statement1>
ElseIF <logical expression2> Then
<statement2>
End IF
– Or –
IF <logical expression1> Then
<statement1>
ElseIF <logical expression2> Then
<statement2>
Else
<statement3>
End IF
There are two types of loop statements: FOR/NEXT and DO/WHILE:
In the following code example, the FOR loop iterates through the loop by setting the variable initially at numeric expression1 and incrementing this value by the STEP amount (expression 3) with each pass through the loop. When the optional STEP clause is omitted, the default clause of STEP 1 is invoked. The loop terminates when the variable reaches a value greater than expression2.
For <variable>=<expression1> To <expression2> [Step <expression3>]
<statements1>
Exit For ' Optional
<statements2>
Next
In the following code example, the DO WHLE loop continues until the logical expression, logExpression, returns 0. The EXIT statement provides a way to terminate a loop without satisfying the normal termination criteria. When EXIT is encountered, the loop breaks and execution resumes at the statement immediately following the loop. EXIT is usually used in conjunction with a conditional statement.
Do While <logExpression>
<statements1>
Exit While ' Optional
<statements2>
Loop
Active Server statements refer to the methods of pASP objects, such as Response and Request. The following code example shows how the Response.Write statement returns an output to the HTML stream.
Response.Write("<A HREF=mctp://MSNBC/ch2> Click here to jump to Sports </A>")
The Mobile Channels scripting environment exposes certain server variables. The Request.ServerVariables statement may be used to query the server variables. It takes a name string expression and returns a value string expression associated with the name. For example,
newURL = Request.ServerVariables("URL")
obtains the root URL for the page channel. The platform strings returned by
platStr = Request.ServerVariables("Platform")
are shown in the following table.
String | Platform |
“WIN32_CE” | Windows CE |
“WIN32_WINDOWS” | Windows 95/Windows 98 |
“WIN32_NT” | Windows NT |
Similarly, the Request.QueryString statement returns the value of a specified argument passed to the page as part of the URL. For example, if the URL for a page is named “mctp://MSNBC/ch2?city=seattle,” then the statement
theCity = Request.QueryString("city")
Assigns “seattle” to the theCity variable.
The SET statement assigns a variable to an instance of an object. Because the Mobile Channels scripting environment supports only the MobileChannels.Utilities pseudoobject, use the SET statement to create a MobileChannels.Utilities object. Then assign the object to an instance variable, as shown in the following code example.
Set MC = Server.Create("MobileChannels.Utilities")
In general, because line breaks are ignored when a statement is evaluated, statements can wrap to more than one line. The statement continuation character (“_”) is recommended, but not mandatory. For example,
MyVar = "This is an example of " & _
"a statement appearing " & _
"on multiple lines." & MyVar