Determine the type of an expression

     TYPE(<cExp>) --> cType


     <cExp> is a character expression whose type is to be determined.
     <cExp> can be a field, with or without the alias, a private or public
     variable, or an expression of any type.


     TYPE() returns one of the following characters:

     TYPE() Return Values
     Returns   Meaning
     A         Array
     B         Block
     C         Character
     D         Date
     L         Logical
     M         Memo
     N         Numeric
     O         Object
     U         NIL, local, or static
     UE        Error syntactical
     UI        Error indeterminate


     TYPE() is a system function that returns the type of the specified
     expression.  It can test expression validity as long as the expression
     uses CLIPPER.LIB functions and does not reference local or static
     variables, user-defined functions, or built-in functions supplied in

     TYPE() is like VALTYPE() but uses the macro operator (&) to determine
     the type of the argument.  This precludes the use of TYPE() to determine
     the type of local and static variables.  VALTYPE(), by contrast,
     evaluates an expression and determines the data type of the return
     value.  This lets you determine the type of user-defined functions as
     well as local and static variables.


     .  Array references:  References to private and public arrays
        return "A."  References to array elements return the type of the

     .  IF():  To return the appropriate data type for an IF()
        expression, TYPE() evaluates the condition, and then, returns the
        type of the evaluated path.  If either the IF() condition or the
        evaluated path are invalid, TYPE() returns "UE."

     .  Testing parameters:  TYPE() can only test the validity of
        parameters received using the PARAMETERS statement.  Testing a
        parameter declared as part of a FUNCTION or PROCEDURE declaration
        always returns "U" because local parameters do not have a symbol in
        the symbol table.  To determine whether an argument was skipped or
        left off the end of the argument list, compare the parameter to NIL
        or use VALTYPE().

     .  User-defined and EXTEND.LIB functions:  If a reference is made
        anywhere in an expression to a function not found in CLIPPER.LIB (a
        user-defined or EXTEND.LIB function), TYPE() returns "UI."  If the
        user-defined function is not linked into the current program, TYPE()
        returns "U."


     .  These examples demonstrate various results from invocations of

        ? TYPE('SUBSTR("Hi There", 4, 5)')      // Result: C
        ? TYPE("UDF()")                         // Result: UI
        ? TYPE('IF(.T., "true", 12)')           // Result: C

     .  This example shows two methods for testing for the existence
        and type of declared parameters:

        FUNCTION TestParams
           PARAMETERS cParam1, nParam2
           IF cParam1 = NIL
              ? "First parameter was not passed"
              cParam1 := "Default value"

           IF TYPE('nParam2') == "U"
              ? "Second parameter was not passed"
           . <statements>
           RETURN NIL

 Files   Library is CLIPPER.LIB.

See Also: VALTYPE()


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s