Jump to content

Futurebasic/Language/Reference/typeof

From Wikibooks, open books for an open world

TYPEOF

[edit | edit source]

Function

[edit | edit source]

(+) Appearance (+) Standard (+) Console

Syntax

[edit | edit source]

dataType = TYPEOF({variable|typeName})

Description

[edit | edit source]

When FB compiles your program, it associates a unique integer with each data type that your program uses. The TYPEOF function returns the integer that's associated with the specified type. typeName should be the name of a type that was previously defined in a BEGIN RECORD statement or a #DEFINE statement; or the name of one of FutureBasic's built-in types (such as INT, LONG, etc.). variable can the name of any variable. In this case, TYPEOF returns the type ID number associated with the variable's type. Note that if the variable was not previously declared in a DIM statement, and has no type-identifier suffix, TYPEOF will assume that the variable's type is the default type (which is INT unless a DEF<type> statement applies). Example: This program uses TYPEOF to determine what kind of data a pointer points to.

  PRINT "The data you passed was: ";
  SELECT varType
  END SELECT

END program output: The data you passed was: 1623 The data you passed was: 426193 The data you passed was: Hello Note: The integer values returned by TYPEOF are determined dynamically at compile time. You should not count on TYPEOF(someType) to return the same value every time your program is compiled.

See Also

[edit | edit source]

SIZEOF; Appendix C: Data Types and Data Representation