What do you think after reading this? About type conversion in Delphi ??

Source: Internet
Author: User
What do you think after reading this? About type conversion in Delphi ?? Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiBase/html/delphi_20061215172228146.html
Inttostr (ABS (strtoint (booltostr (iadoquery. fieldvalues ['ifaccept '])

Because the ifaccept field is of the bit type, if the value in the database is 1, I want to use the conversion method to get 1 instead of using if for determination, finally, I wrote a bunch Code !!

Is there a simpler way ?? The overall feeling is that the type conversion Review of Delphi is too strict. I don't want to use it in C ++ builder !!

What's more strange is that if the booltostr function contains 1, the return value is-1. I really don't understand why does Borland's engineer directly give 1?

What do you think.

Iadoquery. fieldvalues ('ifaccept '). asstring

Or

Inttostr (ord (iadoquery. fieldvalues ('ifaccept '). asboolean ))

You can only say that your code is imaginative!


Setlength (trueboolstrs, 1 );
Setlength (falseboolstrs, 1 );
Trueboolstrs [0]: = '1 ';
Falseboolstrs [0]: = '0 ';

Booltostr (iadoquery. fieldvalues ('ifaccept '). asboolean, true );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.