// Copyright 1999-2001 by Lowell Dennis (Cyberclops, LLC) // // $Workfile: stack.vdm $ // // Stack macros for VEDIT (5.00 or greater) // // $Log: X:/bios/lowell/tools/vedit/stack.vdv $ // // Rev 1.0 04 Oct 2001 10:21:50 Lowell // Initial revision. // ///////////////////////////////////////////////////////////////////// // INIT_STACK Initializes a stack // Call with: // #80 = Stack buffer number // Exits with: // RV = 0, if no error // :INIT_STACK: Num_Push(81,81) #81 = Buf_Num // Save original buffer Buf_Switch(#80) // Switch to stack buffer Buf_Empty(OK) // Clear buffer Num_Ins(0,LEFT) // Indicate empty stack Buf_Switch(#81) // Return to original buffer Num_Pop(81,81) return(0) ///////////////////////////////////////////////////////////////////// // PUSH Stores data on a stack // Call with: // #80 = Stack buffer number // #81 = Text register containing data to be pushed // Exits with: // RV = 0, if no error // RV = 1, if no data to be pushed // :PUSH: if (Reg_Size(#81) == 0) { // If nothing to push ... Get_Key("No data to push onto stack!!!",STATLINE) Key_Purge() return(1) } Num_Push(82,83) #82 = Buf_Num // Save original buffer Buf_Switch(#80) // Switch to stack buffer EOF // Make sure at EOF #83 = CP // Get current stack position Reg_Ins(#81) // Put data item on stack Ins_Newline() // Skip to beginning of next line Num_Ins(#83,LEFT) // Indicate start position of data item Buf_Switch(#82) // Return to original buffer Num_Pop(82,83) return(0) ///////////////////////////////////////////////////////////////////// // POP Retrieves data from a stack // Call with: // #80 = Stack buffer number // #81 = Text register into which data is to be poped // Exits with: // RV = 0, if no error // Retrieved data placed in data text register // RV = 1, if stack is empty // :POP: Num_Push(82,83) #82 = Buf_Num // Save original buffer number Buf_Switch(#80) // Switch to stack buffer EOF // Make sure at EOF Line(-1) // Move to start position indicator #83 = Num_Eval() // Get start position of last data item if (#83 == 0) { // If nothing to pop ... Buf_Switch(#82) // Switch back to original buffer Get_Key("No data on stack to pop!!!",STATLINE) Num_Pop(82,83) return(1) } Del_Line() // Delete position indicator Del_Char(-NC) // Delete newline RCB(#81,#83,CP,DELETE) // Remove data from stack Buf_Switch(#82) // Switch back to original buffer Num_Pop(82,83) return(0)