You are here: Development Standards > OSAS Standards > Using String Templates > SELECT Verb

# SELECT Verb

One of the most useful things about using string templates in your applications is the availability of the SELECT verb for reading records from a data file. The SELECT verb handles record selection internally, and returns only records that match the criteria you specify.

Open Systems has implemented SELECT in the Inventory and Bill of Materials/Kitting applications for creating scratch files, for record searches, and for promotional price record selection.

In its simplest form, SELECT returns all records from a data file:

`0010 LET CHAN=UNT,F$="INVE"+STBL("CID")`
`0020 DIM INVE$:FATTR(INVE$)`
`0030 SELECT (CHAN)INVE$ FROM F$`

Line 0030 uses SELECT to request all the records from the file specified in F$ (INVExxx). After the SELECT you can simply perform READ RECORDs to access the information returned by SELECT from the file channel specified by CHAN:

`0040 READ RECORD(CHAN,END=REPORT_DONE)INVE$`
`0050 PRINT ....`
`0060 GOTO 0040`

When an end of file is encountered, all the records returned by the SELECT verb have been read.

SELECT becomes more powerful when you use the WHERE clause to limit the scope of the records returned. The following statement returns only the items with a status of Discontinued or Obsolete:

`0030 SELECT (CHAN)INVE$ FROM F$ WHERE INVE.STAT$=“D” OR INVE.STAT$=“O”`

The SORTBY clause can also be added to the SELECT verb to determine the order the records are returned. The following statement returns obsolete and discontinued items sorted by the status and then by the item ID:

`0030 SELECT (CHAN)INVE$ FROM F$ WHERE INVE.STAT$=“D” OR INVE.STAT$=“O” SORTBY`
`0030:INVE.STAT$+INVE.ITEM$`