Skip to main content

Working With Indices

generated description: personi

Now let's look again at ^PersonI and $Order. In the example, even though ^PersonI can have up to four subscripts, we're traversing the children of the root: the first dimension. $Order returns the first valid subscript, in this case, “DOB”. Passing “DOB” as the subscript in turn returns the next valid subscript, “Name”. Passing “Name” returns “Phone”, and passing “Phone” causes $Order to return the empty string.

When we use $Order to traverse this level, it returns one of each subscript. In the view shown here, “DOB”, “Name”, and “Phone” repeat three times. This isn't an error, it's just the Portal's way of displaying globals. There is only one “DOB” node, one “Name” node, and one “Phone” node in the tree.

SAMPLES>write $order( ^PersonI("") )
SAMPLES>write $order( ^PersonI("DOB") )
SAMPLES>write $order( ^PersonI("Name") )
SAMPLES>write $order( ^PersonI("Phone") )

FeedbackOpens in a new tab