home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / gstobjects_1 / stack / Example / p / mymain < prev   
Encoding:
Text File  |  1994-09-23  |  793 b   |  41 lines

  1.  
  2. #include "mymain.h"
  3. #include "stack.h"
  4.  
  5. procedure mymain;
  6. (* The real program, we will test the stack object *)
  7.   var s : Stack;
  8.  
  9. begin
  10.  
  11.   (* create a new stack *)
  12.   s := stack_New;
  13.  
  14.   (* push a few numbers onto it *)
  15.   stack_Push(s,1);
  16.   stack_Push(s,2);
  17.   stack_Push(s,3);
  18.  
  19.   (* output the top two elements *)
  20.   writeln('Top = ',stack_Top(s),'  NextToTop = ',stack_NextToTop(s));
  21.  
  22.   (* pop a value off and output it *)
  23.   writeln('top was = ',stack_Pop(s));
  24.  
  25.   (* pop off some more values ignoring the result, note that pop does
  26.      nothing to an empty stack
  27.   *)
  28.   stack_Pop(s);
  29.   stack_Pop(s);
  30.   stack_Pop(s);
  31.  
  32.   (* check the stack is now empty *)
  33.   writeln('stack = ',stack_Top(s));
  34.  
  35.   (* dispose of the stack now we have finished with it *)
  36.   stack_Dispose(s);
  37.  
  38.   (* thats all *)
  39.  
  40. end;
  41.