KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Records on the Record Stack cannot be modified or saved while on the stack
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac & Win
Published On: July 22, 2011

The 4D command PUSH RECORD pushes the current record of a Table onto that table’s record stack. The "current record" is the record that the record pointer is pointing to. The record pointer is moved by such commands as FIRST RECORD, NEXT RECORD, LAST RECORD, etc. Any record in the table that the record pointer is pointing to can be pushed onto that table's record stack. The record stack is not limited to having only one record on it. The record stack is a LIFO (Last In, First Out) meaning that the last record pushed onto the stack will be the first one popped of the stack.

To fully understand the record stack one has to know that records on the stack are the "loaded copies" of the original records, including any changes that have been made to the records before they were pushed onto the stack. While a record in on the record stack it is "locked" to all other processes and is in a "preserved" state for the process that pushed it. It is a mistake to assume that a record placed on the record stack using PUSH RECORD can be modified and/or saved while on the stack.

What "in a preserved state" means is that the copy of the record that 4D has loaded into memory is maintained in that state until it is popped on the stack. While on the stack that copy of the record cannot be changed nor can it be saved.

Executing a query for a record on the stack from within the process that pushed it does not pop that record off the stack, nor does it cause the record pointer to point to it and make it the current record. The query loads a fresh copy of the currently saved record. Because the record is not "locked" for the process that pushed it onto the stack, a Lock record alert is not displayed and the OK variable is still one. Any changes made to this freshly loaded copy do not affect the state of the "preserved" copy on the record stack. In effect, two modified copies of the same records now exist in memory within the same process.