EMPTY() | Determine if the result of an expression is empty |
IF() | Return the result of an expression based on a condition |
IIF() | Return the result of an expression based on a condition |
QOUT() | Display a list of expressions to the console |
TRANSFORM() | Convert any value into a formatted character string |
TYPE() | Determine the type of an expression |
VALTYPE() | Determine the data type returned by an expression |
IF(<lCondition>, <expTrue>, <expFalse>) --> Value
IF() returns the evaluation of <expTrue> if <lCondition> evaluates to true (.T.) and <expFalse> if it evaluates to false (.F.). The value returned is the data type of the valid condition-expression.
IF() is a logical conversion function. It is one of the most powerful and versatile functions in xClipper. It provides a mechanism to evaluate a condition within an expression. With this ability you can convert a logical expression to another data type.
This example converts a logical data value to a numeric data value: lPaid = .T. ? IF(lPaid, 1, 0) // Result: 1 In this example a logical field is formatted depending on whether the Customer is past due or not: @ ROW() + 1, 25 SAY IF(lPaid, SPACE(10), "Go get 'em") If you are printing forms, you can print an indicating symbol in different columns depending on the value of a logical field: @ ROW(), IF(InHospital, 10, 12) SAY "X" You can also use IF() to force the LABEL FORM to print blank lines. Enter the following expression when you create the label with RL.EXE: IF(EMPTY(Company), CHR(255), Company)
[I]IF(<lCondition>, <expTrue>, <expFalse>) --> Value
IIF() returns the evaluation of <expTrue> if <lCondition> evaluates to true (.T.) and <expFalse> if it evaluates to false (.F.). The value returned is the data type of the valid condition-expression.
IIF() is a logical conversion function. It is one of the most powerful and versatile functions in xClipper. It provides a mechanism to evaluate a condition within an expression. With this ability you can convert a logical expression to another data type.
This example converts a logical data value to a numeric data value: lPaid = .T. ? IIF(lPaid, 1, 0) // Result: 1 In this example a logical field is formatted depending on whether the Customer is past due or not: @ ROW() + 1, 25 SAY IIF(lPaid, SPACE(10), "Go get 'em") If you are printing forms, you can print an indicating symbol in different columns depending on the value of a logical field: @ ROW(), IIF(InHospital, 10, 12) SAY "X" You can also use IIF() to force the LABEL FORM to print blank lines. Enter the following expression when you create the label with RL.EXE: IIF(EMPTY(Company), CHR(255), Company)
TRANSFORM(<exp>, <cSayPicture>) --> cFormatString
TRANSFORM() converts <exp> to a formatted character string as defined by <cSayPicture>.
TRANSFORM() is a conversion function that formats character, date, logical, and numeric values according to a specified picture string that includes a combination of picture function and template strings. TRANSFORM() formats data for output to the screen or the printer in the same manner as the PICTURE clause of the @...SAY command.
Function string: A picture function string specifies formatting rules that apply to the TRANSFORM() return value as a whole, rather than to particular character positions within <exp>. The function string consists of the @ character, followed by one or more additional characters, each of which has a particular meaning (see table below). If a function string is present, the @ character must be the leftmost character of the picture string, and the function string must not contain spaces. A function string may be specified alone or with a template string. If both are present, the function string must precede the template string, and the two must be separated by a single space.
TRANSFORM() Functions --------------------------------------------------------------------- Function Action --------------------------------------------------------------------- B Displays numbers left-justified C Displays CR after positive numbers D Displays date in SET DATE format E Displays date in British format R Nontemplate characters are inserted X Displays DB after negative numbers Z Displays zeros as blanks ( Encloses negative numbers in parentheses ! Converts alphabetic characters to uppercase ---------------------------------------------------------------------
Template string: A picture template string specifies formatting rules on a character-by-character basis. The template string consists of a series of characters, some of which have special meanings (see table below). Each position in the template string corresponds to a position in the value of the <exp> argument. Because TRANSFORM() uses a template, it can insert formatting characters such as commas, dollar signs, and parentheses.
Characters in the template string that have no assigned meanings are copied literally into the return value. If the @R picture function is used, these characters are inserted between characters of the return value; otherwise, they overwrite the corresponding characters of the return value. A template string may be specified alone or with a function string. If both are present, the function string must precede the template string, and the two must be separated by a single space.
TRANSFORM() Templates --------------------------------------------------------------------- Template Action --------------------------------------------------------------------- A,N,X,9,# Displays digits for any data type L Displays logicals as "T" or "F" Y Displays logicals as "Y" or "N" ! Converts an alphabetic character to uppercase $ Displays a dollar sign in place of a leading space in a numeric * Displays an asterisk in place of a leading space in a numeric . Specifies a decimal point position , Specifies a comma position ---------------------------------------------------------------------
This example formats a number into a currency format using a template: ? TRANSFORM(123456, "$999,999") // Result: $123,456 This example formats a character string using a function: ? TRANSFORM("to upper", "@!") // Result: TO UPPER