xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

Empty()

Checks if the passed argument is empty.

Syntax

Empty( <expression> ) -->  lIsEmpty

Arguments

<expression>
An expression of any data type whose value is tested for being empty.

Return

The function returns .T. (true) when the passed value is empty, otherwise .F. (false).

Description

The function tests if an expression yields an empty value. The status "Empty" exists for all data types, except Code block Object and Pointer. It is commonly used to test if a user has entered data into an input field. The following table list empty values:

Data types and their empty values
Data typeValtype()Description
ArrayAArray with zero elements
Code blockBNo empty value
CharacterCNull string and White space characters (CR/LF, Space(), Tabs)
DateDNull date (CTOD(""))
HashHHash with zero elements
LogicalLFalse (.F.)
MemoMSame as character
NumericNThe value zero
ObjectONo empty value
PointerPNo empty value
NILUNIL

Info

See also:Len(), Valtype()
Category: Logical functions
Source:rtl\empty.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example lists common empty values and outlines few values
// that could be considered empty, but which are not.

   PROCEDURE Main
      ? Empty( NIL )              // result: .T.

      ? Empty( 0 )                // result: .T.

      ? Empty( .F. )              // result: .T.

      ? Empty( CtoD("") )         // result: .T.

      ? Empty( "" )               // result: .T.
      ? Empty( "     " )          // result: .T.

      ? Empty( Chr( 0) )          // result: .F.
      ? Empty( Chr( 9) )          // result: .T.
      ? Empty( Chr(10) )          // result: .T.
      ? Empty( Chr(13) )          // result: .T.
      ? Empty( Chr(32) )          // result: .T.

      ? Empty( {} )               // result: .T.
      ? Empty( {0} )              // result: .F.

      ? Empty( {|| NIL } )        // result: .F.

      ? Empty( {=>} )             // result: .T.
  RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe