xHarbour Reference Documentation > Function Reference |
Checks if the passed argument is empty.
Empty( <expression> ) --> lIsEmpty
The function returns .T. (true) when the passed value is empty, otherwise .F. (false).
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 type | Valtype() | Description |
---|---|---|
Array | A | Array with zero elements |
Code block | B | No empty value |
Character | C | Null string and White space characters (CR/LF, Space(), Tabs) |
Date | D | Null date (CTOD("")) |
Hash | H | Hash with zero elements |
Logical | L | False (.F.) |
Memo | M | Same as character |
Numeric | N | The value zero |
Object | O | No empty value |
Pointer | P | No empty value |
NIL | U | NIL |
See also: | Len(), Valtype() |
Category: | Logical functions |
Source: | rtl\empty.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// 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
http://www.xHarbour.com