Ben Taylor wrote:
on a side note, personally, i tend to write code more like this:
this way, you dont have 'magic numbers' (ie -1) in the same variable as
your position indicator..
But you are relying on a side-effect of calling the function, which
is a sneaky way of introducing errors. ie:

  x := 127;
  // there is an item with status = ON?
  if FindFirstMatch(List, ON, x) then
    item := something
  else
    item := List[x];
  // Now what is the status of item?

In the end, sometimes you can only hold the callers hand so much,
and just let them break stuff if thats what they want to do.

  x := FindFirstMatch (List, OFF);
  item := List[x]; // Bang! there is no item List[-1]!

It also gets much trickier when you need more than just a simple
found/not found.

if you havent already, try reading a book called "Code Complete", it
discusses a lot of stuff like this..
Yeah, or read the windows help files, its riddled with the stuff.
Pulling a random example :
PC_STATUS RPC_ENTRY MesDecodeBufferHandleCreate();

Cheers, Kurt.

---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to