dBASE Expression Functions

 

A function can be used as a dBASE expression or as part of an dBASE

expression. Like operators, constants, and fields, functions return a value.

Functions always have a function name and are followed by a left and

right bracket. Values (parameters) may be inside the brackets.

 

ALLTRIM(CHAR_VALUE)

This function trims all of the blanks from both the beginning and the end

of the expression.

 

ASCEND(VALUE)

This function is not supported by dBASE, FoxPro or Clipper.

ASCEND() accepts all types of parameters, except complex numeric

expressions. ASCEND() converts all types into a Character type in

ascending order. In the case of numeric types, the conversion is done so

that the sorting will work correctly even if negative values are present.

 

CHR( INTEGER_VALUE )

This function returns the character whose numeric ASCII code is identical

to the given integer. The integer must be between 0 and 255.

Example: CHR(65) returns "A".

 

CTOD( CHAR_VALUE )

The character to date function converts a character value into a date value:

eg. " CTOD( "11/30/88" ) "

The character representation is always in the format specified by the

code4dateFormat member variable which is by default "MM/DD/YYYY".

 

DATE()

The system date is returned.

 

DAY( DATE_VALUE )

Returns the day of the date parameter as a numeric value from "1" to "31".

eg. "DAY(DATE())"

Returns "30" if it is the thirtieth of the month.

 

DESCEND(VALUE)

This function is not supported by dBASE or FoxPro. DESCEND() is

compatible with Clipper, only if the parameter is a Character type.

DESCEND() accepts any type of parameter, except complex numeric

expressions. DESCEND() converts all types into a character type in

descending order.

For example, the following expression would produce a reverse order

sort on the field ORD_DATE followed by normal sub-sort on

COMPANY.

eg. DESCEND(ORD_DATE) + COMPANY

See also ASCEND().

 

DELETED()

Returns .TRUE. if the current record is marked for deletion.

 

DTOC( DATE_VALUE )

DTOC( DATE_VALUE, 1 )

The date to character function converts a date value into a character value.

The format of the resulting character value is specified by the

code4dateFormat member variable which is by default "MM/DD/YYYY".

eg. " DTOC( DATE() ) "

Returns the character value "05/30/1987" if the date is May 30, 1987.

If the optional second argument is used, the result will be identical to the

dBASE expression function DTOS.

For example, DTOC( DATE(), 1 ) will return "19940731" if the date is

July 31, 1994.

 

DTOS( DATE_VALUE )

The date to string function converts a date value into a character value.

The format of the resulting character value is "CCYYMMDD".

e.g. ." DTOS( DATE() ) "

Returns the character value "19870530" if the date is May 30, 1987.

 

IIF( LOG_VALUE, TRUE_RESULT, FALSE_RESULT )

If 'Log_Value' is .TRUE. then IIF returns the 'True_Result' value.

Otherwise, IIF returns the 'False_Result' value. Both True_Result and

False_Result must be the same length and type. Otherwise, an error

results.

eg. "IIF( VALUE << 0, "Less than zero ", "Greater than zero" )"

e.g. ."IIF( NAME = "John", "The name is John", "Not John " )"

 

LEFT( CHAR_VALUE, NUM_CHARS )

This function returns a specified number of characters from a character

expression, beginning at the first character on the left.

eg. "LEFT( 'SEQUITER', 3)" returns "SEQ".

The same result could be achieved with "SUBSTR('SEQUITER', 1, 3)".

 

LTRIM( CHAR_VALUE )

This function trims any blanks from the beginning of the expression.

 

MONTH( DATE_VALUE )

Returns the month of the date parameter as a numeric.

eg. " MONTH( DT_FIELD ) "

Returns 12 if the date field's month is December.

 

RECCOUNT()

The record count function returns the total number of records in the

database:

eg. " RECCOUNT() "

Returns 10 if there are ten records in the database.

 

RECNO()

The record number function returns the record number of the current

record.

 

STOD( CHAR_VALUE )

The string to date function converts a character value into a date value:

eg. " STOD( "19881130" ) "

The character representation is in the format "CCYYMMDD".

 

STR( NUMBER, LENGTH, DECIMALS )

The string function converts a numeric value into a character value.

"Length" is the number of characters in the new string, including the

decimal point. "Decimals" is the number of decimal places desired. If the

number is too big for the allotted space, *'s will be returned.

eg. " STR( 5.7, 4, 2) " returns " '5.70' "

The number 5.7 is converted to a string of length 4. In addition, there will

be 2 decimal places.

eg. " STR( 5.7, 3, 2) " returns " '***' "

The number 5.7 cannot fit into a string of length 3 if it is to have 2

decimal places. Consequently, *'s are filled in.

 

SUBSTR( CHAR_VALUE, START_POSITION, NUM_CHARS)

A substring of the Character value is returned. The substring will be

'Num_Chars' long, and will start at the 'Start_Position' character of

'Char_Value'.

eg. " SUBSTR( "ABCDE", 2, 3 )" returns " 'BCD' "

eg. "SUBSTR( "Mr. Smith", 5, 1 )" returns " 'S' "

 

TIME()

The time function returns the system time as a character representation. It

uses the following format: HH:MM:SS.

eg. " TIME() " returns " 12:00:00 " if it is noon.

eg. " TIME() " returns " 13:30:00 " if it is one thirty PM.

 

TRIM(CHAR_VALUE)

This function trims any blanks off the end of the expression.

 

UPPER( CHAR_VALUE )

A character string is converted to uppercase and the result is returned.

 

VAL( CHAR_VALUE )

The value function converts a character value to a numeric value.

eg. "VAL( '10' )" returns "10". eg. "VAL( '-8.7' )" returns "-8.7".

 

YEAR( DATE_VALUE )

Returns the year of the date parameter as a numeric:

eg. "YEAR( STOD( '19920830' ) ) " returns " 1992 "