Clara-Doc - Programmer Reference

Module: CTSTK

Methods

MethodDescription
CTSTK_ClearClears the stack of all its items.
CTSTK_ConstructorCreates a stack (an instance of type CTSTK).
CTSTK_CountReturns the number of items in the stack.
CTSTK_DestructorReleases the stack and its resources.
CTSTK_GetMaxReturns the maximum number of items that can be inserted in the stack.
CTSTK_ItemSizeReturns the size of the next available item in the stack.
CTSTK_IterNextReturns the value of the next available item in the stack within an iteration loop; the item is not removed from the stack.
CTSTK_IterNextSizeReturns the size of the next item to be retrieved within an iteration loop.
CTSTK_IterStartStarts an iteration loop.
CTSTK_PopReturns the next available stack item in last-in-first-out fashion.
CTSTK_PushInserts an item in the stack.
CTSTK_SetMaxSets the maximum number of items that can be held in the stack.



Description

Creating and disposing of CTSTK instances
Before using a CTSTK, a CTSTK instance has to be created (constructed). This is done by calling the CTSTK_Constructor method. A pointer to a CTSTK instance will be returned to the caller. This pointer will be used in calls to other CTSTK methods. Every time CTSTK_Constructor is called, a new CTSTK instance is created and accessible through the pointer that is returned. This allows for several CTSTK instances within the same porgram. Be sure to pass the appropriate pointer when calling CTSTK methods. Once a CTSTK instance is no longer needed, its resources have to be reclaimed via a call the the CTSTK_Destructor method (you must pass the pointer to the CTSTK instance that will be garbage collected). Call the CTSTK_Constructor method on every CTSTK instance once they are no longer needed. In between calls to the constructor and the destructor for a given CTSTK instance, you may call any CTSTK method on that CTSTK instance.
                                       
 /INCLUDE QINCSRC,CTBASE               
                                       
DRc               S             10I 0  
DpStack           S               *    
                                       
 /Free                                 
                                       
    pStack = CTSTK_Constructor();      
                     
                     
    // Use CTSTK instance via methods by using the pStack pointer                                   
    //
    // ...
    
    
    // We are done and need to gargabe collect CTSTK resources
    
    CTSTK_Destructor(pStack);          
                                       
    *InLR = *On;                       
    Return;                            
                                       
 /End-Free