Radiant receipts: Defining expressions

Counterpoint's Receipt Editor allows you to define Visual Basic expressions for the data fields and other controls on your receipts and other Point of Sale forms.

An expression is a sequence of logical operations that Counterpoint can evaluate to determine the value that appears in a control and whether a control appears on the printed receipt. Expressions are powerful and flexible tools, allowing you to combine multiple fields into a single control, specify formatting rules for fields, and define complex conditions to determine a control's Value and Visibility.

You can enter an expression into the Value field or the Hidden field for a control, or you can click the corresponding button to display the ClosedEdit Expression dialog, which allows you to build an expression using a drag-and-drop interface.

Expressions must always start with the equals sign (=). When you create an expression using the Edit Expression dialog, the equals sign is inserted at the beginning of the expression automatically.

To add a field, function, operator or other element to an expression, select the element from the tree on the left-hand side of the Edit Expression dialog and click the button.

When you add a function to an expression using the Edit Expression dialog, you must replace the placeholders in the parentheses with the actual parameters (i.e., fields and formulas) you want to use in the function.

Preview a Point of Sale form (by clicking the Preview tab on the Receipt Editor window) after you define an expression to test the expression. If the corresponding control displays syntax errors, edit your expression until it produces the result you expect.

For more information about expressions, refer to http://www.fyireporting.com/helpv4/expressions.php.

Sample expressions

ClosedData field

The simplest expression is one that binds an available database field from the Data tree to a control:

=Fields!TicketNumber.Value

If the field is in a particular section of the Data tree (e.g., the Store branch) the expression must include the name of the section, followed by .Value, followed by the field name:

=Fields!Store.Value.Address1

ClosedCombined fields

You can combine, or concatenate, string values using the + operator, as in the following expression, which combines the store's City, State, and ZIP Code into a single control:

=Fields!Store.Value.City+", "+Fields!Store.Value.State+" "+Fields!Store.Value.ZipCode

ClosedData formatting

Use the Format function to display data in a specific format, such as the currency format illustrated in the following expression:

=Format(Fields!Price.Value,"#,##0.00")

ClosedConditional expressions

A simple conditional expression that evaluates as TRUE or FALSE can be used to control the Visibility of a control on a receipt or Point of Sale form:

=Fields!TotalDiscountSavings.Value = 0

The =Iif function allows you to build complex conditional expressions that evaluate a condition and change what the control will display depending on whether the condition evaluates as TRUE or FALSE:

=Iif(Fields!Amount.Value>=0, Fields!PaymentCode.Value

ClosedConverting fields to other data types

You may need to use a Convert.To function to covert a field into a particular data type for use in a formula:

=Convert.ToString(Fields!PaymentCodeType.Value)!="CreditCard"