Compiler error E2029 '.' expected but ';' found

5.5k Views Asked by At

I get compiler error "[DCC Error] FormMain.pas(78): E2029 '.' expected but ';' found" but I cant see where to problem is because I copied this directly from http://blog.marcocantu.com/blog/xe5_anonymous_showmodal_android.html I use this kind of code:

procedure TForm1.ButtonMuutaClick(Sender: TObject);
var FormTiedot :TFormTiedot;
begin
FDQuery1.SQL.Clear;
FDQuery1.SQL.Add('SELECT * FROM Laskuttaja WHERE ID=:ID');
FDQuery1.ParamByName('ID').AsString := '1';
FDQuery1.Open();
  FDQuery1.First;
  FormTiedot := TFormTiedot.Create(nil);
  while(not FDQuery1.Eof) do begin
    FormTiedot.EditNimi.Text := FDQuery1.FieldByName('Nimi').AsString;
    FormTiedot.EditOsoite.Text := FDQuery1.FieldByName('Osoite').AsString;
    FormTiedot.EditY.Text := FDQuery1.FieldByName('Ytunnus').AsString;
    FDQuery1.Next;
  end;
  FormTiedot.ShowModal(procedure(ModalResult: TModalResult) begin if ModalResult = mrOK then begin
      // if OK was pressed and an item is selected, pick it
        FDQuery1.SQL.Clear;
        FDQuery1.SQL.Add('UPDATE Laskuttaja SET Nimi = '+QuotedStr(FormTiedot.EditNimi.Text)+', Osoite = ' + QuotedStr(FormTiedot.EditOsoite.Text) + ', Ytunnus=' + QuotedStr(FormTiedot.EditY.Text));
        FDQuery1.SQL.Add('WHERE ID=1');
        FDQuery1.ExecSQL;

      end;
      FormTiedot.DisposeOf;
    end);
    //FormTiedot.DisposeOf;
  //if FormTiedot.ShowModal = mrOk then begin
    //FDQuery1.SQL.Clear;
   // FDQuery1.SQL.Add('UPDATE Laskuttaja SET Nimi = '+QuotedStr(FormTiedot.EditNimi.Text)+', Osoite = ' + QuotedStr(FormTiedot.EditOsoite.Text) + ', Ytunnus=' + QuotedStr(FormTiedot.EditY.Text));
   // FDQuery1.SQL.Add('WHERE ID=1');

    //FDQuery1.ParamByName('Nimi').Value := FormTiedot.EditNimi.Text;
    //FDQuery1.ParamByName('Osoite').Value := FormTiedot.EditOsoite.Text;
    //Error Y-tunnus not found here
    //FDQuery1.ParamByName('Ytunnus').Value := FormTiedot.Edit1.Text;

  end;
end;
1

There are 1 best solutions below

0
On

You have a stray end in the code. The penulatimate end matches the begin of the method. The final one should be removed.

If you look at the code that you commented out, you commented out a begin but failed to comment out the matching end.

  //if FormTiedot.ShowModal = mrOk then begin   !! commented out begin !!
    //FDQuery1.SQL.Clear;
   // FDQuery1.SQL.Add('UPDATE Laskuttaja SET Nimi = '+QuotedStr(FormTiedot.EditNimi.Text)+', Osoite = ' + QuotedStr(FormTiedot.EditOsoite.Text) + ', Ytunnus=' + QuotedStr(FormTiedot.EditY.Text));
   // FDQuery1.SQL.Add('WHERE ID=1');

    //FDQuery1.ParamByName('Nimi').Value := FormTiedot.EditNimi.Text;
    //FDQuery1.ParamByName('Osoite').Value := FormTiedot.EditOsoite.Text;
    //Error Y-tunnus not found here
    //FDQuery1.ParamByName('Ytunnus').Value := FormTiedot.Edit1.Text;

  end;  !! and the matching end is not commented !!

It is a little odd that you say "I copied this directly from" when in fact the code here bears little obvious relationship to the code you link to. Clearly you did not copy it directly – you must have noticed that you edited it, commented parts out and so on.

The poor indentation of your code makes it hard for you to detect the error. You can always ask the IDE to format your code and it will fix your indentation. This is a good illustration of why it is important to layout your code carefully.