Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRISOpens in a new window, see the InterSystems IRIS Migration Guide and Migrating to InterSystems IRIS, both available on the WRC Distributions pageOpens in a new window (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
        }
Copy code to clipboard
FeedbackOpens in a new window