This example demonstrates the use of the outline tree. TraverseTree is a recursive algorithm that traverses the outline tree to provide access to all outline members. It selects each member in turn, allowing processing on each, until it reaches the last member. A comment in the code notes the opportunity for added processing.
This algorithm incorporates several C Outline API commands.
EssOtlGetFirstMember() returns a member handle to the first member (the first dimension defined) in the outline.
EssOtlGetMemberInfo() gets information for the specified member.
EssOtlGetChild() returns the child of a member.
EssOtlGetNextSibling() returns the next sibling of a member.
Before executing this code, initialize the API and open the outline. Following this code, close the outline and terminate the API.
TraverseTree (ESS_HOUTLINE_T) { ESS_HMEMBER_T hMember; ESS_STS_T sts = 0; sts = EssOtlGetFirstMember(hOutline, &hMember); if (!sts && hMember) sts = TraverseTreeRecurse(hOutline, hMember); } TraverseTreeRecurse(ESS_HOUTLINE_T hOutline, ESS_HMEMBER_T hMember) { ESS_MEMBERINFO_T MbrInfo; ESS_HMEMBER_T, hChild; ESS_STS_T sts = 0; while (!sts && hMember) { sts = EssOtlGetMemberInfo (hOutline, hMember, &MbrInfo); /* ADD THE PROCESSING FOR EACH MEMBER HERE. */ if (!sts) { sts = EssOtlGetChild(hOutline, hMember, &hChild); if (!sts && hChild) { sts = TraverseTreeRecurse(hOutline, hChild); } } sts = EssOtlGetNextSibling(hOutline, hMember, &hMember); } return (sts); }