Sunday, June 12, 2011

3.8 Exit statements

3.8 Exit statements
The Exit statements abruptly terminates the current function or procedure.
If exiting a function, then Result contains the last set value.
Warning : use with caution - jumping is a concept at odds with structured coding - it makes code maintenance difficult.
examples :

var
name1, name2 : string;
begin
Result := 'Tanjung Kona';
repeat
if not InputQuery('Test program', 'First name :', name1)
then Exit;
if not InputQuery('Test program', 'Second name :', name2)
then Exit;
until (name <> '') or (name2 <> '');

Result := name1 + ' ' + name2;
end;

No comments:

Post a Comment