Am 2014-07-27 12:51, schrieb Steve Gatenby:
I would find code in the form of ArrayLen := IncLength(ArrayName, 1); to be much more readable then SetLength(ArrayName, Length(ArrayName)+1); ArrayLen:= High(ArrayName);
Why? It is not clear which index ArrayLen will receive from IncLength. You need to look up (or remember) what exactly this function does while in the two-line version it is all clear and unambiguous. Especially, if you not only add 1 element but more as in ArrayLen := IncLength(ArrayName,2); SetLength(ArrayName, Length(ArrayName)+2); ArrayLen:= High(ArrayName); In the first version, which value will ArrayLen be set to? High(ArrayName) or High(ArrayName)-1? This is very clear in the second version. IMO it is not worth investing time into writing a function that obscures the code. If you look at it months later you may no longer know what IncLength does exactly, not to talk about if someone else has/wants to read your code. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal