OPERATOR:  typeof

The typeof operator is used to determine the type of a given expression. An integer is returned that defines the type.
There are five types recognized by WMLScript:
Type Integer
Integer 0
Floating-point 1
String 2
Boolean 3
Invalid 4

This example tests two expressions; the first is a floating-point number and the second is division by zero which is invalid.
Code for TypeofExample.wml
<?xml version="1.0"?>

<card id="card1">
   typeof example
   <do type="accept">
      <go href="TypeofExample.wmls#findtypeof()" />

<card id="card2">
   1st expression = $(expression1)
   <br />
   1st type = $(typeinteger1)
   <br />
   2cd expression = $(expression2)
   <br />
   2cd type = $(typeinteger2)


Code for TypeofExample.wmls
extern function findtypeof()
   var exp1 = 123.456;
   var int1 = typeof(exp1);
   WMLBrowser.setVar("expression1", exp1);
   WMLBrowser.setVar("typeinteger1", int1);
   var exp2 = 1/0;
   var int2 = typeof(exp2);
   WMLBrowser.setVar("expression2", exp2);
   WMLBrowser.setVar("typeinteger2", int2);

Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information