{"id":3241,"date":"2025-04-17T10:29:26","date_gmt":"2025-04-17T10:29:26","guid":{"rendered":"https:\/\/webprojects.cloud\/wordpress\/splatco\/?post_type=spl_knowledgebase&#038;p=3241"},"modified":"2025-06-10T07:43:30","modified_gmt":"2025-06-10T07:43:30","slug":"builder-conditional-segments-if","status":"publish","type":"spl_knowledgebase","link":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/splat-pc-programming-software\/splat-pc-builder\/builder-conditional-segments-if\/","title":{"rendered":"Builder: Conditional segments ;&lt;=IF"},"content":{"rendered":"\n<p>Another way of including\/excluding segments from the build is called Conditional segments. Here&#8217;s how it works:<\/p>\n\n\n\n<p>Suppose in the SPLat source file you have this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">;&lt;=IF DEBUG&gt;\tSetMem\tStateNumber,6<\/pre>\n\n\n\n<p>The Builder tag is&nbsp;<code>;&lt;=IF DEBUG&gt;<\/code>&nbsp;(including the semicolon!)<\/p>\n\n\n\n<p>One of two things can happen:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>If the .b1d file lists DEBUG in the segment names, the final .spt file will contain<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\">\t\tSetMem\tStateNumber,6 <\/pre>\n\n\n\n<p>2. &nbsp;If the .b1d file&nbsp;<em>does not<\/em>&nbsp;list DEBUG in the segment names, the final .spt file will NOT contain the above&nbsp;<code>SetMem<\/code>&nbsp;instruction.<\/p>\n\n\n\n<p>In this case the generated code line (<code>SetMem<\/code>) is not repositioned. Also, the&nbsp;<code>&lt;=IF DEBUG&gt;<\/code>&nbsp;tag only affects the line it appears on. Rephrasing that: A normal Builder tags acts as a switch the applies until the next Builder tag.&nbsp;<code>&lt;=IF<\/code>&nbsp;tags only affect the current source line and do not result in the line being moved. Think of them as&nbsp;<em>block tags<\/em>&nbsp;versus&nbsp;<em>line tags<\/em>.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Example:<\/h6>\n\n\n\n<p>Consider the following source file, called test.spt:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">;&lt;MEQUSEG&gt;\nHourMeter\tmEQU\t6\t;In permanent memory\n;&lt;=IF DEBUG&gt;StateNumber\tmEQU\t0\t;For easy readout using SPLatLink feature in SPLat\/PC\n\n;&lt;CODESEG&gt;\nStart:\n\t\tGoSub\t\tInitialise\n;&lt;=IF DEBUG&gt;\t\tSetMem\tStateNumber,0\n;&lt;=IF DEBUG&gt;\t\tGoSub\t\tTraceState\t;Do some debug-only stuff\n...\n...\n\n;&lt;DEBUG&gt;;---- Some debug-only code ----\nTraceState:\t...\n\t\t\t...\n\t\tReturn\n<\/pre>\n\n\n\n<p>Consider now the following .b1d file<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">;<a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/glossary-of-terms\/#o5366\">Build<\/a> it with debug code<br>MEQUSEG<br>CODESEG<br>DEBUG<br>#---<br>test.spt<\/pre>\n\n\n\n<p>This will emit:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">HourMeter\tmEQU\t6\t;In permanent memory\nStateNumber\tmEQU\t0\t;For easy readout using SPLatLink feature in SPLat\/PC\n\nStart:\n\t\tGoSub\t\tInitialise\n\t\tSetMem\tStateNumber,0\n\t\tGoSub\t\tTraceState\t;Do some debug-only stuff\n...\n...\n\n;---- Some debug-only code ----\nTraceState:\t...\n\t\t\t...\n\t\tReturn<\/pre>\n\n\n\n<p>If on the other hand I add&nbsp;<code>DISCARD<\/code>&nbsp;after the segment name&nbsp;<code>DEBUG<\/code>&nbsp;in the bld file, I will get:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">HourMeter\tmEQU\t6\t;In permanent memory\n\nStart:\n\t\tGoSub\t\tInitialise\n...\n...<\/pre>\n\n\n\n<p>In other words, all the debug code will be stripped out automatically.<\/p>\n\n\n\n<p>Notice that the lines that are tagged with&nbsp;<code>;&lt;=IF DEBUG&gt;<\/code>&nbsp;are not moved to the debug segment, they are merely switched on (but get emitted in their original positions) by the presence of&nbsp;<code>DEBUG<\/code>&nbsp;without&nbsp;<code>DISCARD<\/code>.<\/p>\n\n\n\n<p>Similarly, if the segment in which a conditional segment is embedded is set to&nbsp;<code>DISCARD<\/code>, the conditional line(s) will also be discarded. That&#8217;s what happened in the last example above.<\/p>\n\n\n\n<p>Note that the tag&nbsp;<code>;&lt;=IF DEBUG&gt;<\/code>&nbsp;will work fine if there is no mention of&nbsp;<code>DEBUG<\/code>&nbsp;in the .b1d file. The scope of this tag (range of lines it affects) is only the line it is on. The other form,&nbsp;<code>;&lt;DEBUG&gt;<\/code>&nbsp;will produce an error if&nbsp;<code>DEBUG<\/code>&nbsp;is not listed in the b1d file. The scope of that form is all following lines up until the next Builder tag (or the end of the file). This is why I use&nbsp;<code>DISCARD<\/code>&nbsp;to turn the&nbsp;<code>DEBUG<\/code>&nbsp;tag on and off.<\/p>\n\n\n\n<p>Tip: You can turn the DISCARD qualifier off by using a semicolon &#8211; it becomes a comment and is ignored, e.g.:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">DEBUG ; DISCARD<\/pre>\n\n\n\n<p>That is safer than<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">; DEBUG<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Another way of including\/excluding segments from the build is called Conditional segments. Here&#8217;s how it works: Suppose in the SPLat source file you have this:&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":3236,"menu_order":3,"template":"","class_list":["post-3241","spl_knowledgebase","type-spl_knowledgebase","status-publish","hentry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Builder: Conditional segments ;&lt;=IF - SPLat Controls<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Builder: Conditional segments ;&lt;=IF - SPLat Controls\" \/>\n<meta property=\"og:description\" content=\"Another way of including\/excluding segments from the build is called Conditional segments. Here&#8217;s how it works: Suppose in the SPLat source file you have this:...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/splat-pc-programming-software\/splat-pc-builder\/builder-conditional-segments-if\/\" \/>\n<meta property=\"og:site_name\" content=\"SPLat Controls\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-10T07:43:30+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/splat-pc-programming-software\/splat-pc-builder\/builder-conditional-segments-if\/\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/splat-pc-programming-software\/splat-pc-builder\/builder-conditional-segments-if\/\",\"name\":\"Builder: Conditional segments ;&lt;=IF - SPLat Controls\",\"isPartOf\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website\"},\"datePublished\":\"2025-04-17T10:29:26+00:00\",\"dateModified\":\"2025-06-10T07:43:30+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/splat-pc-programming-software\/splat-pc-builder\/builder-conditional-segments-if\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/splat-pc-programming-software\/splat-pc-builder\/builder-conditional-segments-if\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/splat-pc-programming-software\/splat-pc-builder\/builder-conditional-segments-if\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SPLat\/PC programming software\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/splat-pc-programming-software\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"SPLat\/PC: Builder\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/splat-pc-programming-software\/splat-pc-builder\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Builder: Conditional segments ;&lt;=IF\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\",\"name\":\"SPLat Controls\",\"description\":\"OEM Embedded Machine Controllers\",\"publisher\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization\",\"name\":\"SPLat Controls\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg\",\"contentUrl\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg\",\"caption\":\"SPLat Controls\"},\"image\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Builder: Conditional segments ;&lt;=IF - SPLat Controls","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"Builder: Conditional segments ;&lt;=IF - SPLat Controls","og_description":"Another way of including\/excluding segments from the build is called Conditional segments. Here&#8217;s how it works: Suppose in the SPLat source file you have this:...","og_url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/splat-pc-programming-software\/splat-pc-builder\/builder-conditional-segments-if\/","og_site_name":"SPLat Controls","article_modified_time":"2025-06-10T07:43:30+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/splat-pc-programming-software\/splat-pc-builder\/builder-conditional-segments-if\/","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/splat-pc-programming-software\/splat-pc-builder\/builder-conditional-segments-if\/","name":"Builder: Conditional segments ;&lt;=IF - SPLat Controls","isPartOf":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website"},"datePublished":"2025-04-17T10:29:26+00:00","dateModified":"2025-06-10T07:43:30+00:00","breadcrumb":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/splat-pc-programming-software\/splat-pc-builder\/builder-conditional-segments-if\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/splat-pc-programming-software\/splat-pc-builder\/builder-conditional-segments-if\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/splat-pc-programming-software\/splat-pc-builder\/builder-conditional-segments-if\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/"},{"@type":"ListItem","position":2,"name":"SPLat\/PC programming software","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/splat-pc-programming-software\/"},{"@type":"ListItem","position":3,"name":"SPLat\/PC: Builder","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/splat-pc-programming-software\/splat-pc-builder\/"},{"@type":"ListItem","position":4,"name":"Builder: Conditional segments ;&lt;=IF"}]},{"@type":"WebSite","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/","name":"SPLat Controls","description":"OEM Embedded Machine Controllers","publisher":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webprojects.cloud\/wordpress\/splatco\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization","name":"SPLat Controls","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg","contentUrl":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg","caption":"SPLat Controls"},"image":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/spl_knowledgebase\/3241","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/spl_knowledgebase"}],"about":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/types\/spl_knowledgebase"}],"author":[{"embeddable":true,"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/users\/1"}],"up":[{"embeddable":true,"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/spl_knowledgebase\/3236"}],"wp:attachment":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/media?parent=3241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}