KILL ^H SET ^H("D")=1 SET ^H("E")=1,^H("F")=1 S ^H("A")=1,^H("B")=1,^H("C")=1 ; ^-- ^H now contains the keys "A", "B", "C", "D", "E", "F" ; WRITE $ORDER(^H("")),! ; ^-- writes "A", the first key (in order) of ^H ; W $O(^H("C")),! ; ^-- writes "D", the next key after "C" in ^H ; W $O(^H("F")),! ; ^-- writes "", because "F" is the last key in ^H ; W $O(^H("D"),-1),! ; ^-- writes "C", the key before "D" in ^H ; W $O(^H("A"),-1),! ; ^-- writes "", because "A" is the first key in ^H ; SET K="" FOR SET K=$ORDER(^H(K)) QUIT:K="" DO .WRITE K WRITE ! ; ^-- writes "ABCDEF", all keys of ^H in order ; S K="" F S K=$O(^H(K,-1)) Q:K="" D .W K W ! ; ^-- writes "FEDCBA", all keys of ^H in reverse order (-1 passed as second argument to $ORDER) ; S K="B" F S K=$O(^H(K)) Q:K="" Q:K="E" D .W K W ! ; ^-- writes "CD", all keys of ^H following "B" and stopping at the end of keys or at "E", in order ; S K="B" F S K=$O(^H(K)) Q:K="" Q:K]]"E" D .W K W ! ; ^-- writes "CDE", all keys of ^H following "B" and stopping at the end of keys or at the first key sorting after "E", in order