EMPTY() Determine if the result of an expression is empty ------------------------------------------------------------------------------ Syntax EMPTY(<exp>) --> lEmpty Arguments <exp> is an expression of any data type. Returns EMPTY() returns true (.T.) if the expression results in an empty value; otherwise, it returns false (.F.). The criteria for determining whether a value is considered empty depends on the data type of <exp> according to the following rules: List of Empty Values ------------------------------------------------------------------------ Data Type Contents ------------------------------------------------------------------------ Array Zero-length Character Spaces, tabs, CR/LF, or ("") Numeric 0 Date Null (CTOD("")) Logical False (.F.) Memo Same as character NIL NIL ------------------------------------------------------------------------ Description The EMPTY() function has a number of uses. You can use it to determine if a user entered a value into a Get object before committing changes to a database file. It can also determine whether a formal parameter is NIL or unsupplied. In addition, it can test an array for zero-length. Notes . Space characters: The EMPTY() function treats carriage returns, line feeds, and tabs as space characters and removes these as well. Examples . These examples illustrate use of EMPTY() against several different data types: ? EMPTY(SPACE(5)), EMPTY("") // Result: .T. .T. ? EMPTY(0), EMPTY(CTOD("")) // Result: .T. .T. ? EMPTY(.F.), EMPTY(NIL) // Result: .T. .T. . This example uses EMPTY() to determine whether the user entered a value into the first Get object before writing the new value to the database file: LOCAL cCust := SPACE(15), nAmount := 0 USE Sales NEW @ 10, 10 GET cCust @ 11, 10 GET nAmount PICTURE "999.99" READ // IF !EMPTY(cCust) APPEND BLANK REPLACE Sales->Cust WITH cCust, Sales->Amount ; WITH nAmount ENDIF . This example uses EMPTY() as part of the VALID clause to force the user to enter data into the current Get object: LOCAL cCode := SPACE(5) @ 2, 5 SAY "Enter code" GET cCode VALID !EMPTY(cCode) READ Files Library is CLIPPER.LIB.
See Also: LEN()