Quantcast
Channel: Planet Object Pascal
Viewing all articles
Browse latest Browse all 1725

Free Pascal Answers: Auto Completion in Lazarus

$
0
0

I have found these days a new auto-completion feature that already exist in Lazarus, it is variables auto-completion. Previously I was only using procedure header / method auto-completion, by typing method header inside class definition part then clicking Ctrl-Shift-C to get implementation part of the procedure/method.

Now someone in Lazarus forum told us that auto completion is available for variables, for example, you can write for loop without defining loop variable first:

 


begin
  for i:= 1 to 10 do
    Writeln(i);
end.

Then stop in i variable and click Ctrl-Shift-C and you will get an automatic definition with a proper type:

 


var
  i: Integer;
begin
  for i:= 1 to 10 do
    Writeln(i);
end.

 

Also you can use it with parameter values:


procedure getRandomNumber(var x: string);
begin
  x:= Random(100);
end;

begin
  GetRandomNumber(MyNumber);
  Writeln(MyNumber);
end.

 

Then stop at MyNumber and click Ctrl-Shift-C to get:


procedure getRandomNumber(var x: Integer);
begin
  x:= Random(100);
end;

var
  MyNumber: Integer;
begin

  GetRandomNumber(MyNumber);
  Writeln(MyNumber);

end.

I found it very useful, so that I liked to share.

Now you can stop defining variables before using it, just use the variable and auto-define it later.



Viewing all articles
Browse latest Browse all 1725

Trending Articles