SRL Archive - Help and Support

Access violation (edit1.Text)


Chris

2012-07-02 13:15:53

I have this:

procedure Start;
begin
writeln(edit1.text);
end;

and this:
Edit1 := TEdit.Create(MainForm); 
Edit1.Parent := MainForm;
Edit1.Top := 155;
Edit1.Left := 120;
Edit1.Width := 150;
Edit1.Height := 50;
Edit1.MaxLength := 20;
Edit1.Text := 'Username'

And its called like this:
Action.ExecuteProcedure := @Start; 
Action.ExecuteProcedure();

But it gives me:
Error: Exception: Access violation at line 383
line 383 = writeln(edit1.text);

Any ideas why this happens?

Brandon

2012-07-02 13:29:21

You can't do that unless your form is shown with nonmodal arguments..

Form.Show vs Form.ShowModal.

After the form is closed, the text box is destroyed. Accessing it is a violation. And the action should be OnKeyPress. I haven't seen ExecuteProc before.

Save the text to a variable then print it.

Chris

2012-07-03 10:30:28

From: Brandon
You can't do that unless your form is shown with nonmodal arguments..

Form.Show vs Form.ShowModal.

After the form is closed, the text box is destroyed. Accessing it is a violation. And the action should be OnKeyPress. I haven't seen ExecuteProc before.

Save the text to a variable then print it.


Thanks!
I thought the text inside the box would be saved inside Edit1.Text when the form would be closed, but now I understand how it works.
Rep+ & Back to scripting :)