Home Delphi 2006 proper use of END

# Delphi 2006 proper use of END

nikname
1#
nikname Published in 2017-10-24 09:03:41Z
 Look at this code: if Poruka(BM_UWARN, GetMsg('Da li zaista želite da odbijete nalog?')) = mrOk then begin tmps := TRN.ss; TrnPom.ss := TRN.ss; RadnikOdbio.l := AdresniSlog.Rabotnik; if Zakljucaj(1011, tmps, 3) then begin FRazlogOdbNal.ShowModal; case FRazlogOdbNal.ModalResult of mrOk: BeBankComment.ss := FRazlogOdbNal.beRazlogOdbijanja.ss; else Otkljucaj(1011, tmps, 3); exit; end; end; end;  It is not important what this code does, what I need help with is did I use enough ENDs in this part of code. So the first END is of CASE statement. Second END closes BEGIN of if Zakljucaj(1011,tmps,3) and the last END is closing BEGIN of starting IF. Is this the right way to close them, does compiler now which end refers to which part of the code? And also, does compiler knows that the else part refers to case statement? If not, is there a way to explicitly do this?
gonutz
2#
 Your code is syntactically correct. The indentation is however a little off, you should not indent the begin of a block. The default behavior of the Rad Studio auto formatter is to align them like this: if Poruka(BM_UWARN, GetMsg('Da li zaista želite da odbijete nalog?')) = mrOk then begin tmps := TRN.ss; TrnPom.ss := TRN.ss; RadnikOdbio.l := AdresniSlog.Rabotnik; if Zakljucaj(1011, tmps, 3) then begin FRazlogOdbNal.ShowModal; case FRazlogOdbNal.ModalResult of mrOk: BeBankComment.ss := FRazlogOdbNal.beRazlogOdbijanja.ss; else Otkljucaj(1011, tmps, 3); exit; end; end; end;  The rest of what you state in your question is correct.