{"id":28,"date":"2010-06-09T08:53:51","date_gmt":"2010-06-09T08:53:51","guid":{"rendered":"http:\/\/www.electronic-products-development.com\/?p=28"},"modified":"2024-05-14T12:12:29","modified_gmt":"2024-05-14T11:12:29","slug":"state","status":"publish","type":"post","link":"https:\/\/ibex.tech\/c\/c\/state\/state","title":{"rendered":"State ? ( ) : ( ) Ternary Operator"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Usage Examples<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>(state ? true : false)  \/\/1:0\n\n#define\tUSART_DIR_TX(state)\t(state ? (&#91;true]) : (&#91;false]))\n\n#define OUTPUT_PIN(state) (state ? (LATAbis.LATA1 = 1) : (LATAbis.LATA1 = 0))  \/\/1:0\n\nbytesThisSector = (bytesLeftToWrite > 512) ? 512 : bytesLeftToWrite;\n\n#define LED_OUTPUT_ON(state)\t\t\t\t(state ? (rs485_leds_output |= 0x01) : (rs485_leds_output &amp;= ~0x01))<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Multiple actions within a ternary operator<\/h4>\n\n\n\n<p>You comma seperate them:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#define IO_BUTTONS_COL_1(state)\t\t(state ? (TRISBbits.TRISB1 = 1) : (TRISBbits.TRISB1 = 0, LATBbits.LATB1 = 0))<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Usage Examples Multiple actions within a ternary operator You comma seperate them:<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[115],"tags":[],"class_list":["post-28","post","type-post","status-publish","format-standard","hentry","category-state"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts\/28","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/comments?post=28"}],"version-history":[{"count":9,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts\/28\/revisions"}],"predecessor-version":[{"id":1575,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/posts\/28\/revisions\/1575"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/media?parent=28"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/categories?post=28"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/c\/wp-json\/wp\/v2\/tags?post=28"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}