Delphi Compiler Directive to Evaluate Arguments in Reverse

Posted by Peter Turner on Stack Overflow See other posts from Stack Overflow or by Peter Turner
Published on 2010-06-16T15:03:48Z Indexed on 2010/06/16 16:02 UTC
Read the original article Hit count: 345

Filed under:
|

I was really impressed with this delphi two liner using the IFThen function from Math.pas. However, it evaluates the DB.ReturnFieldI first, which is unfortunate because I need to call DB.first to get the first record.

DB.RunQuery('select awesomedata1 from awesometable where awesometableid = "great"');
result := IfThen(DB.First = 0, DB.ReturnFieldI('awesomedata1'));

Obviously this isn't such a big deal, as I could make it work with five robust liners. But all I need for this to work is for Delphi to evaluate DB.first first and DB.ReturnFieldI second. I don't want to change math.pas and I don't think this warrants me making a overloaded ifthen because there's like 16 ifthen functions.

Just let me know what the compiler directive is, if there is an even better way to do this, or if there is no way to do this and anyone whose procedure is to call db.first and blindly retrieve the first thing he finds is not a real programmer.

© Stack Overflow or respective owner

Related posts about delphi

Related posts about compiler-directives