It occurs all of the time, you track internal business function success or failure as an integer, and then you finally want to return it to NER / ER / TER as a char, but a double byte char because it’s unicode.
This is somewhat painful, but I have the remedy. It also uses the crazy ?: operator, which is sure to confuse all of your friends.
In this case if i is non 0, it’ll return 1, else it’ll return 0 – nice.
lpDS->cErrorCode=i?_J('1'):_J('0') ;
This could be written:
if (i != 0)
{
lpDS->cErrorCode=_J(‘1’) ;
}
else
{
lpDS->cErrorCode=_J(‘0’) ;
}
No comments:
Post a Comment