You can do several thins: 1. use Else !! 2. Surround (I hope that the proper spelling) everything in try finally and then in the finally place the free statement. 3. Make a shorter code:
Result := (condition1) OR (condition2) OR (condition3) Will be the same as your if statment, but shorter. Ido On Sun, Aug 22, 2010 at 10:10, Dave Coventry <[email protected]> wrote: > I have a function that tests for a series of different conditions > according to a value in a 'case...of' block. > > Result:=false; > mylist:=TStringlist.Create; > case i of > 1: > begin > if condition1 then > begin > Result:=true; > break; > end; > if condition2 then > begin > Result:=true; > break; > end; > if condition3 then > begin > Result:=true; > end; > end; > 2:....; > 3:....; > end; > mylist.free; > > The above does not work as the 'case...of' is not considered to be a loop. > Error: BREAK not allowed. > > I could just exit the function, using 'exit' instead of 'break' but I > think I need to free the mylist TStrings. > > Is there a way of doing this or is my best way just to replace 'break' > with 'mylist.free' and 'exit'? > > -- > _______________________________________________ > Lazarus mailing list > [email protected] > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus >
-- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
