Declaration of Variable with Default Value in Procedures

2

Would you like to declare a variable with a default value in Procedures?

procedure TfrmManutencao01.FormShow(Sender: TObject);
var
  lPriAber : Boolean = True;
begin
.
.
.
end;

I know that as above Delphi does not accept.

    
asked by anonymous 29.11.2017 / 15:13

1 answer

4

Responding directly to the question: No, Cannot initialize local variables .

What you can do is declare the variable before the section implementation

var
  FormX    : TFormX;
  lPriAber : Boolean = True;

This way you can use it in the procedure.

If by chance you do not change its value, you can locally declare it as constant.

procedure TfrmManutencao01.FormShow(Sender: TObject);
const
  lPriAber : Boolean = True;
begin
..
end;

I still can not figure out the need.

    
29.11.2017 / 17:14