ValType()

ValType()

Retrieves the data type of an expression

Syntax

      ValType( <xExp> ) --> <cRetType>

Arguments

<xExp> is any valid expression.

Returns

<cRetType> a character indicating the type of the passed expression.

        <cRetType>   Meaning
        ------------ ----------------------- 
        "A"          Array
        "B"          Block
        "C"          Character (string)
        "D"          Date
        "H"          Hash
        "L"          Logical
        "M"          Memo
        "N"          Numeric
        "O"          Object
        "P"          Pointer
        "S"          Symbol
        "T"          Date & Time Stamp 
        "U"          NIL

Description

This function returns one character which represents the data type of the argument.

Examples

PROCEDURE Main()
LOCAL aStru := { { 'AINCR', '+', 4, 0 },; // Auto increment
 { 'LMODT', '=', 8, 0 },; // Last modified date & time of this record
 { 'RVERS', '^', 8, 0 },; // Row version number; modification count of this record
 { 'DT_TM', '@', 8, 0 },; // Date & Time
 { 'DOUBL', 'B', 8, 0 },; // Double Floating point / 64 bit binary
 { 'CHARA', 'C', 6, 0 },; // Character
 { 'ODATE', 'D', 8, 0 },; // Only Date 
 { 'LOGIC', 'L', 1, 0 },; // Logical
 { 'MEMOR', 'M', 8, 0 },; // Memo 
 { 'NUMER', 'N', 5, 0 },; // Numeric 
 { 'INTEG', 'I', 2, 0 },; // Integer 
 { 'OTIME', 'T', 8, 0 },; // Only Time
 { 'VARIA', 'V', 8, 0 },; // Variant 
 { 'CURRE', 'Y', 8, 0 } } // Currency 64 bit integer with implied 4 decimal

 LOCAL aArray := {},; 
 bBlock := { || .T. },; 
 cString := 'This is a string',;
 cDate := DATE(),; 
 hHash := { => },;
 lLogic := ( 1 = 1 ),;
 nNumber := 1,;
 oObject := TBrowse(),;
 pPointer := hb_idleAdd( {|| 1 + 1 } ),;
 sSymbol := ( @STR() ),; 
 uUndef := NIL,;
 xTest

 DBCREATE( 'VT_Test', aStru, , .T., 'TEST' )
 DBAPPEND()

 * Types of FIELDS:
 ? ValType( TEST->AINCR ) // N 
 ? ValType( TEST->LMODT ) // T 
 ? ValType( TEST->RVERS ) // N 
 ? ValType( TEST->DT_TM ) // T 
 ? ValType( TEST->DOUBL ) // N 
 ? ValType( TEST->CHARA ) // C 
 ? ValType( TEST->ODATE ) // D 
 ? ValType( TEST->LOGIC ) // L 
 ? ValType( TEST->MEMOR ) // M 
 ? ValType( TEST->NUMER ) // N 
 ? ValType( TEST->INTEG ) // N 
 ? ValType( TEST->OTIME ) // T 
 ? ValType( TEST->VARIA ) // C 
 ? ValType( TEST->CURRE ) // N 
 ? 
 * Types of variables assigned value from FIELDS:
 ? ValType( xTest := TEST->AINCR ) // N 
 ? ValType( xTest := TEST->LMODT ) // T 
 ? ValType( xTest := TEST->RVERS ) // N 
 ? ValType( xTest := TEST->DT_TM ) // T 
 ? ValType( xTest := TEST->DOUBL ) // N 
 ? ValType( xTest := TEST->CHARA ) // C 
 ? ValType( xTest := TEST->ODATE ) // D 
 ? ValType( xTest := TEST->LOGIC ) // L 
 ? ValType( xTest := TEST->MEMOR ) // M 
 ? ValType( xTest := TEST->NUMER ) // N 
 ? ValType( xTest := TEST->INTEG ) // N 
 ? ValType( xTest := TEST->OTIME ) // T 
 ? ValType( xTest := TEST->VARIA ) // C 
 ? ValType( xTest := TEST->CURRE ) // N 
 ? 
 * Types of Variables 
 ? ValType( aArray ) // A
 ? ValType( bBlock ) // B
 ? ValType( cString ) // C
 ? ValType( cDate ) // D
 ? ValType( hHash ) // H
 ? ValType( lLogic ) // L
 ? ValType( nNumber ) // N
 ? ValType( oObject ) // O
 ? ValType( pPointer ) // P
 ? ValType( sSymbol ) // S
 ? ValType( uUndef ) // U 

RETURN


Compliance

ValType() is CA-Cl*pper compliant, with the addition of the new Harbour types: Hash, Date & Time Stamp, Pointer and Symbol.

Files

Library is core

Seealso

Type()

Advertisements

2 responses to “ValType()

  1. Pingback: Harbour All Functions – V | Viva Clipper !

  2. Pingback: Variable Management Functions | Viva Clipper !

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