############################################################ # # Frame stack handling # Jari-Matti Auttila / 2002-12-13 # ############################################################ # # Function list: # # * stack_append(form) # - Append a form object to the end of the stack # # * stack_first as object; # - returns the first object in the stack # # * stack_previous # - returns the last added form from the stack # # * stack_pop_previous; # - same as above, but deletes the returned form from the stack # # * stack_del_previous; # - only deletes the last added form from the stack # # * stack_pop_first as object; # - returns and deletes the first item in the stack. # - all stack items are dropped down one bit. # # * stack_del_first; # - deletes the first item, but does not return anything # # * stack_reset; # - clears the whole stack # # * fReturnToPreviousScreen; # - this function always displays the last added frame # # * fOpenScreen(nextform); # - displays the form "nextform" # - automatically appends "nextform" to the stack # ############################################################ # Variable stack variables; numeric nStackMax = -1; object oStack[50]; end; function stack_append(object form); nStackMax = nStackMax + 1; oStack[nStackMax] = form; end; function stack_first as object; stack_first = oStack[0]; end; function stack_previous as object; stack_previous = oStack[nStackMax - 1]; end; function stack_pop_previous as object; stack_pop_previous = stack_previous; nStackMax = nStackMax - 1; end; function stack_del_previous; nStackMax = nStackMax - 1; end; function stack_pop_first as object; variables; numeric ind; end; stack_pop_first = stack_first; for ind = 0, ind < nStackMax - 1; oStack[ind] = oStack[ind + 1]; next ind + 1; nStackMax = nStackMax - 1; end; function stack_del_first; variables; numeric ind; end; for ind = 0, ind < nStackMax - 1; oStack[ind] = oStack[ind + 1]; next ind + 1; nStackMax = nStackMax - 1; end; function stack_reset; nStackMax = -1; end; # Return to the previous screen function fReturnToPreviousScreen; variables; object previous; end; previous = stack_pop_previous; previous.hidden = 0; end; # Open the next screen function fOpenScreen(object nextform); stack_append(nextform); nextform.hidden = 0; end;