TYPEOF Function

Identifies the data type of the passed in value.

Category: Information and Conversion
Returned data type: Character
Note: The returned value is one of the following strings: Boolean variable return Boolean, integer variable return integer, real variable return real, string variable return string.

Syntax

<string> TYPEOF(in_value)

Optional Argument

in value

variable that is evaluated.

Examples

Example 1

// Expression
string hello
hello="hello"
 
boolean error
error=false
 
// variable that will contain the type
string type 
type=typeof(hello)
 
// type should be string
if(type<>"string") then
   error=true

Example 2

string content
content = "Today is sunny"
 
hidden integer one
one =1
 
hidden real pi
pi=3.1415962
 
hidden boolean test
test=false
 
hidden string type
 
type= typeof(content);
 
if (type == "string")
   begin
        error_message="The data type for variable 'Content' is string"
   end
 
type=typeof(one)
if (type == "integer")
   begin
        error_message="The data type for variable 'one' is integer"
   end
type= typeof(pi);
 
if (type == "real")
   begin
        error_message="The data type for variable 'real' was real"
   end
 
type= typeof(test);
 
if (type == "boolean")
   begin
        error_message="The data type for variable 'test' was boolean"
   end