# rptfilter

> Source: https://manual.pvxplus.com/report-writer/object-oriented-interface/rptfilter/overview

The **rptfilter** object is a data member of the **[pvxreport](https://manual.pvxplus.com/report-writer/object-oriented-interface/pvxreport/overview)** object interface, delegated to store and manipulate a data filter definition. One object is created for each filter. The **[pvxreport](https://manual.pvxplus.com/report-writer/object-oriented-interface/pvxreport/overview)** **GetFilter(** **)** method can be used to retrieve the object handle for an **rptfilter** object, which allows access to all the object's methods and properties.

## rptfilter Properties

The following table lists the properties of the **rptfilter** object:

| **Property** | **Description** |
| --- | --- |
| **CompareValue$** | Value to be used for comparison in the condition test. A value can consist of a table element, parameter, calculated field, literal or formula. Examples of formulas are "LITERAL"+STRINGVAL$ or Balance\*Tax.<br>Some conditions use more than one comparison value. Indicate which **CompareValue$** is being accessed by setting the **[ValNo](https://manual.pvxplus.com/report-writer/object-oriented-interface/rptfilter/overview#valno)** property to the index number of the desired **CompareValue$** property.<br>Default is the first **CompareValue$** until the **ValNo** index is otherwise set. |
| **ConditionCode** | Code number (-1, 1-12) indicating the type of condition:  <br>  <br> **-1** - Free form filter expression  <br> **0** - None   <br> **1** - Equal to   <br> **2** - Not equal to   <br> **3** - Less than   <br> **4** - Greater than   <br> **5** - Less than or equal to   <br> **6** - Greater than or equal to   <br> **7** - Between .. and .. inclusive   <br> **8** - Between .. and .. exclusive   <br> **9** - Any of .., .., .., etc.   <br> **10** - None of .., .., etc.   <br> **11** - Contains   <br> **12** - Starts with<br>*(Code number -1 was added in PxPlus 2022.)* |
| **Filter** | ***(Read Only)***<br>Contains a free-form PxPlus expression that can be evaluated to a 0/1 Boolean value.<br>***Example:***<br>InvoiceDate$>=StartDate$ AND InvoiceDate$\<=EndDate$<br>*(The Filter property was added in PxPlus 2022.)* |
| **IsCaseSensitive** | Boolean value (0/1) indicating whether the condition test should be case sensitive or not. |
| **MemFiles$** | Contains a string of memory file channel numbers used to access the memory files set up to process the **[IsAnyOf( )](https://manual.pvxplus.com/report-writer/object-oriented-interface/pvxreport/overview#isanyof)** method of the **\*rpt/pvxreport** class.<br>Each channel number is five characters long (e.g. 00054), and its position within the **MemFiles$** string is based on the sequence number associated with the **IsAnyOf( )** method.<br>*(The MemFiles$ property was added in PxPlus 2023.)* |
| **ValNo** | Index (1-8) to indicate which **[CompareValue$](https://manual.pvxplus.com/report-writer/object-oriented-interface/rptfilter/overview#compval)** property is being accessed. Valid indices are based on the type of condition. Default is **1** until otherwise set. |
| **Variable$** | Name of the table element, parameter or calculated field to be used in the condition test. This must start with an alpha character, optionally followed by alphanumeric, **.** (*period*) or **\_** (*underscore*) characters. Names of elements containing string values must be terminated by a **$** character.<br>Set to null if invalid. If the name of a string element is assigned, the **IsCaseSensitive** property is set to **1**. |

## rptfilter Methods

The following table lists the methods of the **rptfilter** object:

| **Method** | **Description** |
| --- | --- |
| GetCompareValue$(*idx*) | Returns the value of the **[CompareValue$](https://manual.pvxplus.com/report-writer/object-oriented-interface/rptfilter/overview#compval)** property whose index is given.<br>*idx -* Index of **CompareValue$** property. Assigned to **ValNo** property. Returns null if the index value is invalid. |
| **GetCondition$( )** | Returns the condition in the form of a PxPlus expression.<br>***Example:***<br>If the following properties are set …<br>```<br>Variable=CompanyId$<br>ConditionCode=1<br>IsCaseSensitive=0<br>ValNo=1<br>CompareValue$=CompanyNumber$<br>```<br>… then the return value would be:<br>CompanyId$=CompanyNumber$<br>Returns null if the information in the **[rptfilter](https://manual.pvxplus.com/report-writer/object-oriented-interface/rptfilter/overview)** object is invalid. |
| SetAnyOfValues(*Seq,Values$,Type$,Case$***)** | Create the memory file for an **[IsAnyOf( )](https://manual.pvxplus.com/report-writer/object-oriented-interface/pvxreport/overview#isanyof)** method reference based of the *Values$*, *Type$* and *Case$*. The channel number for the memory file is added to the **[MemFiles$](https://manual.pvxplus.com/report-writer/object-oriented-interface/rptfilter/overview#memfiles)** property string based on the sequence value.<br>\|  \|  \|<br>\| --- \| --- \|<br>\| *Seq* \| Sequence number to set up an **IsAnyOf( )** method. The first reference to an **IsAnyOf( )** method should have a sequence of 1, the second instance 2, etc. \|<br>\| *Values$* \| String of **\\|** *(pipe)* separated values to be tested in the **IsAnyOf( )** method. \|<br>\| *Type$* \| Type of value (**N**=Numeric or **S**=String) to be tested in the **IsAnyOf( )** method. \|<br>\| *Case$* \| Case flag for testing: **0** (Case insensitive) or **1** (Case sensitive). \|<br>*(The SetAnyOfValues( ) method was added in PxPlus 2023.)* |
| SetCompareValue(*idx,Val$***)** | Assigns a value to the **[CompareValue$](https://manual.pvxplus.com/report-writer/object-oriented-interface/rptfilter/overview#compval)** property whose index is given.<br>\|  \|  \|<br>\| --- \| --- \|<br>\| *idx* \| Index of **CompareValue$** property. Assigned to **[ValNo](https://manual.pvxplus.com/report-writer/object-oriented-interface/rptfilter/overview#valno)** property. \|<br>\| *Val$* \| Value to be assigned to specified **CompareValue$** property. \|<br>Returns **1** if successful or **0** if the index value is invalid. |
| **SetFilter( )**<br>SetFilter(*Expression$***)** | Set the **[Filter](https://manual.pvxplus.com/report-writer/object-oriented-interface/rptfilter/overview#filter)** property to a free-form filter consisting of a valid PxPlus expression that can be evaluated to a Boolean value (0/1). Sets **[ConditionCode](https://manual.pvxplus.com/report-writer/object-oriented-interface/rptfilter/overview#condcode)** to -1.<br>***Example:***<br>InvoiceDate$>=StartDate$ AND InvoiceDate$\<=EndDate$<br>If no expression is specified, the **Filter** is set to null and **ConditionCode** is set to **0**. |

## Example

This sample program creates the filter set and adds the filters to the filter set:

```
! invoicelist - Print a range of invoices
!
! This program prints a list of invoices, with an optional invoice range.
! It is a called program that accepts a report definition as the first argument
! and optional start and end invoice values as the second and third arguments.
!
! After loading the report, the program adds filters if the start and end
! values are supplied.
!
! Lastly, it generates the report to the Viewer.
!
     enter ReportName$,StartAt$,EndAt$,err=*next
!
     rpt=new("*rpt/pvxreport")
     if Rpt'open(ReportName$)=0 \
          then goto WrapUp
!
! Create the filter set
     if StartAt$+EndAt$<>"" \
          then Rpt'ClearFilters();
                  fs=Rpt'AddFilterSet()
! Now add the filters to the filter set
     if StartAt$<>"" \
          then fltr=fs'AddFilter();
                  fltr'Variable$="InvoiceNumber$";
                  fltr'ConditionCode=6;
                  fltr'IsCaseSensitive=0;
                  fltr'SetCompareValue(1,quo+StartAt$+quo)
     if EndAt$<>"" \
          then fltr=fs'AddFilter();
                  fltr'Variable$="InvoiceNumber$";
                  fltr'ConditionCode=5;
                  fltr'IsCaseSensitive=0;
                  fltr'SetCompareValue(1,quo+EndAt$+$FF$+quo)
!
! Now generate the report
Generate_Report:
     open (hfn,err=WrapUp,opt="Normal;"+Rpt'GetPageSetup$())"*viewer*";
     prt=lfo
     Rpt'OutputPrint(prt)
     Rpt'RunReport()
     close (prt)
WrapUp: \
     drop object Rpt
     end
```
