/* Any controlled variable may behave as a stack. */ declare s float controlled; /* to push a value on the stack. */ allocate s; s = 10; /* To pop a value from the stack. */ put (s); free s; /* to peek at the top of stack> */ put (s); /* To see whether the stack is empty */ if allocation(s) = 0 then ... /* Note: popping a value from the stack, or peeking, */ /* would usually require a check that the stack is not empty. */ /* Note: The above is a simple stack for S. */ /* S can be any kind of data structure, an array, etc. */ /* Example to push ten values onto the stack, and then to */ /* remove them. */ /* Push ten values, obtained from the input, onto the stack: */ declare S float controlled; do i = 1 to 10; allocate s; get list (s); end; /* To pop those values from the stack: */ do while (allocation(s) > 0); put skip list (s); free s; end; /* The values are printed in the reverse order, of course. */