goto is an unstructured control flow statement. It makes code less readable and
maintainable, and is not recommended in modern code.
Use condition variables with structured control flow statements such as if,
for, while, Continue, or Break instead.
function Foo: Boolean;
var
Sentence: string;
begin
for I := 1 to 10 do begin
Sentence := Sentence + Readln;
if Input = '.' then begin
goto SentenceEnded;
end;
end;
ShowMessage('Cutting off the sentence here');
SentenceEnded:
ShowMessage('Sentence: ' + Sentence);
end;
function Foo: Boolean;
var
Sentence: string;
SentenceShown: Boolean;
begin
for I := 1 to 10 do begin
Sentence := Sentence + Readln;
if Input = '.' then begin
ShowMessage('Sentence: ' + Sentence);
SentenceShown := True;
Break;
end;
end;
if not SentenceShown then begin
ShowMessage('Cutting off the sentence here');
ShowMessage('Sentence: ' + Sentence);
end;
end;