{"id":596,"date":"2025-07-21T09:36:11","date_gmt":"2025-07-21T09:36:11","guid":{"rendered":"https:\/\/tipcontrol.com\/?page_id=596"},"modified":"2025-07-21T09:43:49","modified_gmt":"2025-07-21T09:43:49","slug":"if-statement","status":"publish","type":"page","link":"https:\/\/tipcontrol.com\/?page_id=596","title":{"rendered":"if statement"},"content":{"rendered":"\n<p>The <code>if<\/code> statement is a fundamental control structure in Tipcontrol and similar to languages such as C++. It allows you to execute certain blocks of code conditionally, based on the evaluation of an expression.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Structure of an&nbsp;<code>if<\/code>&nbsp;Statement:<\/h4>\n\n\n\n<p><strong>Components<\/strong>:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Condition<\/strong>: An expression evaluated to determine whether it is\u00a0<code>true<\/code>\u00a0(non-zero) or\u00a0<code>false<\/code>\u00a0(zero).<\/li>\n\n\n\n<li><strong>Code Block<\/strong>: The block of code that executes if the condition evaluates to\u00a0<code>true<\/code>. This block is enclosed within curly braces\u00a0<code>{}<\/code>.<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">Optional&nbsp;<code>else<\/code>&nbsp;Clause<\/h4>\n\n\n\n<p>You can extend the <code>if<\/code> statement with an <code>else<\/code> clause to specify code to execute when the condition is <code>false<\/code>:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Simple Example<\/h4>\n\n\n\n<p>&nbsp; &nbsp; number = 10;<\/p>\n\n\n\n<p>&nbsp; &nbsp; \/\/ Check if the number is positive, negative, or zero<\/p>\n\n\n\n<p>&nbsp; &nbsp; if (number &gt; 0) {<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; lib.log(&#8220;The number is positive.&#8221;);<\/p>\n\n\n\n<p>&nbsp; &nbsp; } else if (number &lt; 0) {<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; lib.log(&#8220;The number is negative.&#8221;);<\/p>\n\n\n\n<p>&nbsp; &nbsp; } else {<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; lib.log(&#8220;The number is zero.&#8221;);<\/p>\n\n\n\n<p>&nbsp; &nbsp; };<\/p>\n\n\n\n<p><strong>Explanation<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Condition<\/strong>:\u00a0<code>number > 0<\/code>\u00a0checks if\u00a0<code>number<\/code>\u00a0is greater than zero.<\/li>\n\n\n\n<li><strong>Nested checks<\/strong>:\u00a0<code>else if<\/code>\u00a0provides additional conditional checks when the previous\u00a0<code>if<\/code>\u00a0condition is\u00a0<code>false<\/code>.<\/li>\n\n\n\n<li><strong><code>else<\/code>\u00a0Clause<\/strong>: Executes if none of the preceding conditions are\u00a0<code>true<\/code>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The if statement is a fundamental control structure in Tipcontrol and similar to languages such as C++. It allows you to execute certain blocks of code conditionally, based on the evaluation of an expression. Structure of an&nbsp;if&nbsp;Statement: Components: Optional&nbsp;else&nbsp;Clause You can extend the if statement with an else clause to specify code to execute when [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-596","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/tipcontrol.com\/index.php?rest_route=\/wp\/v2\/pages\/596","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tipcontrol.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/tipcontrol.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/tipcontrol.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/tipcontrol.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=596"}],"version-history":[{"count":2,"href":"https:\/\/tipcontrol.com\/index.php?rest_route=\/wp\/v2\/pages\/596\/revisions"}],"predecessor-version":[{"id":600,"href":"https:\/\/tipcontrol.com\/index.php?rest_route=\/wp\/v2\/pages\/596\/revisions\/600"}],"wp:attachment":[{"href":"https:\/\/tipcontrol.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}