2: Using the Demonstration Subscription System

2.6 Querying and Finding Records

Exercise 1

Goal: Locate the record for Life Magazine.

1. Press the QUERY key <F2>.

2. Enter the search pattern by typing life in the field labeled Magazine.

3. Press the FIND key <F3>. The word SEARCHING appears briefly in the lower left-hand corner of the screen. When the record is found, it is displayed in the form with the words FIND NEXT appearing in place of the word SEARCHING.

Exercise 2

Goal: Step through all records in the data file, one record at a time, beginning with the first record in the file.

1. Press the QUERY key <F2> and then the FIND key <F3>. The first record in the data file is displayed.

2. Press the FIND key <F3> again. The second record appears.

Comments:

A record is displayed each time the FIND key <F3> is pressed. When the end of the file is reached, the message No more is displayed. You may then press the FIND key <F3> to start the search over again at the first record.

Exercise 3

Goal: Locate all of the records in the file with the pattern mag in the magazine's title.

1. Press the QUERY key <F2>.

2. Enter the search pattern *mag* in the field labeled Title.

3. Press the FIND key <F3>. The first record found matching the search pattern is displayed.

4. Press the FIND key <F3> to display the next matching record.

Comments:

Each time the FIND key <F3> is pressed, the next record matching the search pattern is displayed.

There are two wild card characters available to aid in searches:

* - The asterisk (*) matches any character, string of characters, or no character. The pattern *life* entered in the field labeled Title would match the records for both Life Magazine and Boy’s Life. Any string containing the characters life would be found with the pattern *life*. The pattern life* matches any string beginning with life.

? - The question mark (?) will match any single character. The pattern ?ife entered in the field labeled Magazine would match the record for Life Magazine. The pattern ???? entered in the field labeled Magazine would match all records with a four-character magazine code.

You can use wild card patterns only in string or character fields; numeric, date, and time fields cannot be searched by wild card.

When form does a wild card search, form usually makes no distinction between upper-case and lower-case letters. If, however, the field containing the wild card is indexed and the first character of your pattern is not a wild card character (* or ?), form first does a case sensitive index search on the leading non wild card characters in your pattern to get to the first record that matches your pattern, then does a case insensitive search to find the actual matches. For example, in the Name field, the wild card pattern *tom* would match Tom Henley and Atom Ant. The wild card pattern tom*, however, would not match Tom Henley if the Name field is indexed.

Exercise 4

Goal: Locate a record matching the contents of more than one field.

1. Press the QUERY key <F2>.

2. Enter *mag* in the field labeled Title, and 17.00 in the field labeled Yearly Rate.

3. Press the FIND key <F3>. The first record matching the search pattern is displayed.

4. Press the FIND key <F3> again to display the next record which matches the search pattern. If no more matching records are found, the No more message is displayed.