Selection - Report
Validates a record
Type: Event
Return Data Type: Integer
Syntax
Function Selection Returns Integer
Description
Selection is used to validate a record. It is intended for override. The function should return an integer rpt_status value where:
| Constant | Meaning |
|---|---|
| RPT_OK (0) | The record is valid. |
| RPT_END (1) | The record represents the end of the file. |
| RPT_NOT_SELECT (2) | The record is not valid, but is not at the end of the file. |
| RPT_CANCEL (3) | Cancel a report. This would be an unusual return value. |
If you are using constrained finding, you will usually not override the handler. Your selection will be within the begin_constraints-end_constraints block. If you are not using constrained finding, you must use this handler to handle your custom constraints.
There is an advantage in using the selection function in conjunction with constrained finds in that an invalid record that is processed through the selection handler is tested for a keypress interrupt and can therefore be interrupted. A constrained find will not return any control to the report object until a valid record or no record is found. Depending on your constraint, this could "tie up" your machine for a long time. The advantage of constraints is that the finding is much faster.
As an example, the following could take a long time to process in a very large database. In the first example, the processing would be faster but the machine would appear to be locked up until a record is found:
Procedure OnConstrain
Constrain Vndr.Id GT 'J' // this is fast
Constrain as (Mid(Vndr.Name, 2, 3) ="zz") // this is slow
End_Procedure
In the second example, the report would take longer, but it could be interrupted at any time with a keypress.
Procedure OnConstrain
Constrain Vndr.Id GT 'J' // this is fast
End_Procedure
Function Selection returns Integer
If (Mid(Vndr.Name, 2, 3) ="zz" Function_return RPT_OK
Else Function_return RPT_NOT_SELECT
End_function
Return Value
Returns RPT_OK, RPT_END, RPT_NOT_SELECT or RPT_CANCEL