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 Traverse Loops

In the Traverse() loop below, ln = "", means “start at the beginning of the last names”. Similarly, if ln = "" then exit do means “stop at the end of the last names”. You can modify either statement to focus this loop to produce fewer subscripts. If you assign 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, you will set ln equal to the substring to start. You also need to alter the If 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.

ln = ""
do
    ln = traverse(^PersonI("Name", ln) )
    if ln = "" then exit do
    println ln
loop
Copy code to clipboard
FeedbackOpens in a new window