Getting error: ')' expected but ']' found

By: Angel Martinez

Abstract: explains why this error might occur and how to work around it

Problem:


The following code snippet raises the error: ')' expected but ']' found
procedure TForm1.Button1Click(Sender: TObject);
var
  d1, d2, d3: double;
begin
  d1 := 35000;
  d2 := 48000;
  d3 := ((d2 - d1) * 18000.);
end;

Solution and Explanation:


Add a space and or zero and the error will go away. Example:

d3 := ((d2 - d1) * 18000. ); 
d3 := ((d2 - d1) * 18000.0);


".)" is a special symbol in Pascal. It is equivalent to a "]". If you look up Special Symbols in Delphi help, you can get the full explanation.


Server Response from: ETNASC04