The program is written in IDE lazarus 1.6. There is a class with this declaration:
DataForm = class public Choices:longint; BackUp:boolean; private nameForm:String; operationForm:TypeOperation; public function getForm():String; procedure setForm(const nForm:String); function getOperation():TypeOperation; procedure setOperation(const oForm:TypeOperation); end; And such a description:
function DataForm.getForm():String; begin getForm:=nameForm; end; procedure DataForm.setForm(const nForm : String); begin nameForm:=nForm; end; function DataForm.getOperation():TypeOperation; begin getOperation:=operationForm; end; procedure DataForm.setOperation(const oForm:TypeOperation); begin operationForm:=oForm; end; To work with the stack from the class of such objects uses uses gstack;
type iStack = specialize TStack<DataForm>; var TopForm: iStack; CurrentStatus:DataForm; In the form by pressing the button the following code is executed:
TopForm.CleanupInstance; CurrentStatus.setForm('fRoot'); CurrentStatus.setOperation(oRoot); TopForm.Push(CurrentStatus); CurrentStatus.setForm('fViewPatientStory'); CurrentStatus.setOperation(View); TopForm.Push(CurrentStatus); CurrentStatus.setForm('fViewPatient'); CurrentStatus.setOperation(View); ShowMessage(TopForm.Top().getForm()); TopForm.Pop; ShowMessage(TopForm.Top().getForm()); Issued 2 messages: fViewPatient. I need the items pushed to the stack to remain with the same values they were at the time of placement, and it turns out that any stack item refers to the CurrentStatus variable and when it changes, all values of the stack items change. Please help.
ссылкуto the same object on the stack. Create a new object and place it there. - kami