TYPE (Value?) TYPE (Value?)

Value

The value whose type should be returned.

Returns

Number Number

1 If the value is a number, 2 if the value is a text string, 4 if the value is a logical value, 16 if the value is an error, 64 if the value is an array, 32768 (2^15) if the value is a temporal value and 65536 (2^16) if the value is a color.

Returns the type of the given value. TYPE (42) TYPE (42) returns 1, indicating that 42 is a number.

These are the values returned by this function:

Values returned by TYPE
Type of value Return value
Number 1
Text 2
Logical (TRUE or FALSE) 4
Error 16
Array ( { ? } ) 64
Temporal (a date, a time of day or both) 32768 (2^15)
Color 65536 (2^16)

The codes 1, 2, 4, 16 and 64 are the ones used by spreadsheet programs. The codes 32768 and 65536 are fxEngine extensions, as spreadsheets have neither a temporal type nor a color type distinct from the number type. Extension codes are assigned in descending order starting at 65536 (2^16), so that they move away from the codes used by spreadsheet programs, which ascend from 1.

Examples

TYPE (42)
TYPE (42)

Returns 1, indicating that 42 is a number.

TYPE ("42")
TYPE ("42")

Returns 2, indicating that "42" is a text string.

TYPE (TRUE)
TYPE (TRUE)

Returns 4, indicating that TRUE is a logical value.

TYPE (Value1 / Value2)
TYPE (Value1 / Value2)

Returns 16, provided that Value2 is 0 or blank, which triggers a #DIV/0! error ("division by zero"). Otherwise, 1 is returned, indicating that the value is a number.

TYPE ({ 1, 2, 3 })
TYPE ({ 1; 2; 3 })

Returns 64, indicating that the value is an array.

TYPE ( TODAY ())
TYPE ( TODAY ())

Returns 32768, indicating that the value is a temporal value.

TYPE (Color.Red)
TYPE (Color,Red)

Returns 65536, indicating that the value is a color.

TYPE ( INDEX ({ 1, 2, 3 }, 1))
TYPE ( INDEX ({ 1; 2; 3 }; 1))

Returns 1, indicating that the first element of the array is a number.

fxEngine Shell Want this in your own terminal? A standalone version is coming. Get notified.
Loading fxEngine Shell