{"id":593,"date":"2025-07-21T09:43:52","date_gmt":"2025-07-21T09:43:52","guid":{"rendered":"https:\/\/tipcontrol.com\/?page_id=593"},"modified":"2025-07-21T09:43:53","modified_gmt":"2025-07-21T09:43:53","slug":"for-statement","status":"publish","type":"page","link":"https:\/\/tipcontrol.com\/?page_id=593","title":{"rendered":"for statement"},"content":{"rendered":"\n<p>In this section we introduce you the language to program TipControl. It is used in the Macros and Events Section.<\/p>\n\n\n\n<p>for &#8211; loop<br>if<br>while<br>dowhile<br>return<\/p>\n\n\n\n<p>The <code>for<\/code> loop in TipControl is similar to languages like C++, it is a control structure that allows code to be executed repeatedly based on a condition. The <code>for<\/code> loop is especially useful when you know in advance how many times you need to execute a block of code.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Structure of a&nbsp;<code>for<\/code>&nbsp;Loop<\/h4>\n\n\n\n<p>A typical <code>for<\/code> loop is structured as follows:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Initialization<\/strong>: This step is executed once before the loop begins. It is often used to set an initial counter variable.<\/li>\n\n\n\n<li><strong>Condition<\/strong>: Before each iteration of the loop, this expression is evaluated. If the condition is&nbsp;<code>true<\/code>, the loop body is executed. If it is&nbsp;<code>false<\/code>, the loop terminates.<\/li>\n\n\n\n<li><strong>Update<\/strong>: This step is executed after each iteration of the loop body. It is typically used to increment or decrement the loop counter.<\/li>\n<\/ol>\n\n\n\n<p>Let&#8217;s look at a simple example to illustrate how a <code>for<\/code> loop works:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\/\/ This loop will print numbers 1 to 5<\/h4>\n\n\n\n<h4 class=\"wp-block-heading\">&nbsp; &nbsp; for (i = 1, i &lt;= 5,i+=1) {<\/h4>\n\n\n\n<h4 class=\"wp-block-heading\">&nbsp; &nbsp; &nbsp; &nbsp; lib.log(&#8220;Number:\u201d + &nbsp;i);<\/h4>\n\n\n\n<h4 class=\"wp-block-heading\">}<\/h4>\n\n\n\n<p><strong>Explanation<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Initialization<\/strong>:&nbsp;<code>i = 1&nbsp;<\/code>&nbsp;initializes the loop counter&nbsp;<code>i<\/code>&nbsp;to&nbsp;<code>1<\/code>.<\/li>\n\n\n\n<li><strong>Condition<\/strong>:&nbsp;<code>i &lt;= 5;<\/code>&nbsp;checks whether&nbsp;<code>i<\/code>&nbsp;is less than or equal to&nbsp;<code>5<\/code>. If this condition is true, the loop continues; otherwise, it exits.<\/li>\n\n\n\n<li><strong>Update<\/strong>:&nbsp;<code>i+=1<\/code>&nbsp;increments the loop counter&nbsp;<code>i<\/code>&nbsp;by&nbsp;<code>1<\/code>&nbsp;after each iteration, i++ like in C is not supported yet<\/li>\n<\/ul>\n\n\n\n<p>Each time through the loop, the value of <code>i<\/code> is printed, resulting in the following output:<\/p>\n\n\n\n<p>Number: 1 Number: 2 Number: 3 Number: 4 Number: 5<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this section we introduce you the language to program TipControl. It is used in the Macros and Events Section. for &#8211; loopifwhiledowhilereturn The for loop in TipControl is similar to languages like C++, it is a control structure that allows code to be executed repeatedly based on a condition. The for loop is especially [&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-593","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/tipcontrol.com\/index.php?rest_route=\/wp\/v2\/pages\/593","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=593"}],"version-history":[{"count":1,"href":"https:\/\/tipcontrol.com\/index.php?rest_route=\/wp\/v2\/pages\/593\/revisions"}],"predecessor-version":[{"id":609,"href":"https:\/\/tipcontrol.com\/index.php?rest_route=\/wp\/v2\/pages\/593\/revisions\/609"}],"wp:attachment":[{"href":"https:\/\/tipcontrol.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}