;+ ; NAME: stackpop ; ; PURPOSE: ; pops a variable off of a stack. ; NOTE ; If the stack only contains one item ; it becomes undefined after the item is popped off. ; ; see also stackpush.pro ; ; INPUTS: ; stack an array functioning as a stack ; KEYWORDS: ; OUTPUTS: ; returns the last element of the stack, and shortens the stack ; accordingly. ; ; HISTORY: ; Began 2002-04-01 00:48:36 by Marshall Perrin ;- function stackpop,stack checkargnum,n_params(),1,"stackpop,stack" n = n_elements(stack) if n gt 1 then begin var = stack[n-1] stack = stack[0:n-2] return,var endif else begin var = stack[0] b = temporary(stack) return,var endelse end