Computers: Universe: Phrases

Unless you don't get out often enough, once you've typed...

LIST CUSTOMER.INVOICES CUSTOMER.NAME PRODUCT UNIT.PRICE QUANTITY VALUE

...a few times (and most probably mistyped it a few more) it has lost its charm as a form of entertainment. If you find yourself displaying the same group of fields in the same order over and over again, it would be useful if you could define a single word which would automatically collect them all together for you.

Well... you can't, so tough luck.

Only kidding. In fact, its simple. You can create a phrase dictionary record which will do exactly this. To create one for CUSTOMER.INVOICES, enter the command:

>ED DICT CUSTOMER.INVOICES MAIN.FIELDS
New record.

----: I
0001= PH Phrase including all the main fields
0002= CUSTOMER.NAME PRODUCT UNIT.PRICE QUANTITY VALUE
0003= (Press RETURN)
Bottom at line 2.
----: FI
"MAIN.FIELDS" filed in file "DICT CUSTOMER.INVOICES".
>

You may now enter the command:

LIST CUSTOMER.INVOICES MAIN.FIELDS

This will have exactly the same effect as the earlier command, and save your fingers.

Phrases have other advantages. Let us say that your application produces the original enquiry in several places. If you add a new field you would like to include in each of these places, you need to modify each in turn. If, on the other hand, each time the enquiry is used it uses the phrase MAIN.FIELDS, simply changing the phrase is sufficient.

If you create a phrase called @ - that is, just using the 'at' symbol as its key - you need not even name the phrase with your enquiry. Simply typing the command:

LIST CUSTOMER.INVOICES

...has the same effect as typing...

LIST CUSTOMER.INVOICES @

It's good practice to define an @ dictionary record for every file you create. In this way, someone can look at the most important fields in your file (which you decide in advance via your @ dictionary record) simply by entering the command LIST filename, without first having to consult the dictionary.

Similar to @ is @LPTR, which is the 'default phrase' used when you enter the command LIST filename LPTR: which sends the output to a 'line printer'.

The @ and @LPTR phrases are ignored if you enter any field names on your command line: UniVerse assumes you are then listing explicitly the fields you want, and does not alter this selection. If you want to list only record keys (which is what LIST displays in the absense of explicit field names if there is no @ phrase), you can use the command LIST filename ID.ONLY.

You can put other keywords in phrases besides field names. The subject of sorting your enquiry will be covered in more detail during the discussion of the RetrieVe query language, but for now note that you can sort your enquiry results by appending BY fieldname to your LIST command. If you put a BY clause in your phrase, even in your @ phrase, it will apply the sort whenever the phrase is used. In short, you can put any valid Retrieve clause into a phrase.