Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see How to Migrate to InterSystems IRIS, available on the WRC Distributions page (login required).

Focused $Order Loops

In the $Order loop, set ln = "", means “start at the beginning of the last names”. Similarly, quit:(ln = "") means “stop at the end of the last names”. You can modify either statement to focus this loop to produce fewer subscripts. If you set ln="B", for example, this loop will skip over “Agee”.

If you want this loop to produce only the names starting with a substring of a name (“Jone”, for example), you will set ln equal to the substring to start. You also need to alter the Quit statement so that the loop stops before it reaches names that start with letters after the substring. There are several ways to do this; the next page shows one approach. The simpleloop.mac code:

simpleloop ; loop through last names
    set ln = ""
    for {
        set ln = $order( ^PersonI("Name", ln) )
        quit:(ln = "")
        write !, ln