{"id":2570,"date":"2025-04-16T05:46:10","date_gmt":"2025-04-16T05:46:10","guid":{"rendered":"https:\/\/webprojects.cloud\/wordpress\/splatco\/?post_type=spl_knowledgebase&#038;p=2570"},"modified":"2025-06-10T11:12:34","modified_gmt":"2025-06-10T11:12:34","slug":"if-elseif-else-endif-conditional-code-translation","status":"publish","type":"spl_knowledgebase","link":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/if-elseif-else-endif-conditional-code-translation\/","title":{"rendered":"#IF, #ELSEIF, #ELSE, #ENDIF (Conditional code translation)"},"content":{"rendered":"\n<figure class=\"wp-block-table is-style-stripes\"><table class=\"has-fixed-layout\"><tbody><tr><td>Oh Dear &#8211; it seems the\u00a0#ELSE\u00a0feature is currently broken in SPLat\/PC.\u00a0 As a work-around, you can use ELSEIF like this:<br><br>#IF EQ( YourThing )<br>; if TRUE<br>#ELSEIF EQ( 1, 1 ) ;ELSE is broken, so this is a workaround (it&#8217;s always TRUE and will only execute if everything prior is FALSE)<br>; otherwise<br>#ENDIF<br><br>If you&#8217;re using builder, then\u00a0<a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/splat-pc-programming-software\/splat-pc-builder\/builder-conditional-segments-if\/\">Builder Conditional Segments<\/a>\u00a0do work.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>From build 327 SPLat\/PC supports conditional code translation. What this means is that your .spt source file(s) can contain statements that control which lines actually get included in the final program.&nbsp;<strong>NOTE:<\/strong>&nbsp;These instructions do not work at&nbsp;<strong>RUN TIME<\/strong>, they are only used when&nbsp;<strong>COMPILING<\/strong>&nbsp;your SPLat program, so they allow you to include different pieces of code when compiling.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><br>Example:<br><br>Board: #EQU MMI<br><br>#IF EQ(Board, MMI)<br>iStart EQU 7<br>oMotor EQU 0<br><br>#ELSEIF EQ(Board, MS)<br>iStart EQU 15<br>oMotor EQU 10<br><br>#ELSE<br> Board type not defined<br><br>#ENDIF<br><\/code><\/pre>\n\n\n\n<p>What&#8217;s happening here?<\/p>\n\n\n\n<p>The first line defines &#8220;Board&#8221; as an&nbsp;<code>#EQU<\/code>&nbsp;constant with the value MMI (as a string). The second &#8211;&nbsp;<code>#IF<\/code>&nbsp;&#8211; line says &#8220;If Board = MMI&#8221; then use the lines that follow. Those lines allocate an input and an output. The&nbsp;<code>EQ(..,..)<\/code>&nbsp;is called a qualifying function, which must always evaluate to True or False.&nbsp; Then comes the&nbsp;<code>#ELSEIF<\/code>. It says &#8220;If the MMI test failed, try for MS instead&#8221;. If that test passes, then a different set of allocations will be used. The final&nbsp;<code>#ELSE<\/code>&nbsp;trips if neither the MMI nor the MS test passes, and results in an error, so the program translation will fail.<\/p>\n\n\n\n<p>As it stands the example will use MMI values. But I only have to edit one line, the very first one, to switch to allocations for (presumably) an MS121.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Conditional translation hash functions<\/h6>\n\n\n\n<p>There are four conditional translation hash functions:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><br>#IF<br>#ELSEIF<br>#ELSE<br>#ENDIF<br><\/pre>\n\n\n\n<p>A number of rules apply:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>They must appear in the order listed.<\/li>\n\n\n\n<li><code>#ELSEIF<\/code>&nbsp;and&nbsp;<code>#ELSE<\/code>&nbsp;are optional<\/li>\n\n\n\n<li>There can be more than one&nbsp;<code>#ELSEIF<\/code>&nbsp;but never more than one&nbsp;<code>#ELSE.<\/code><\/li>\n\n\n\n<li><code>#IF<\/code>&nbsp;and&nbsp;<code>#ELSEIF<\/code>&nbsp; must have one and only one&nbsp;<em>qualifying function<\/em>. That&#8217;s what determines if the condition will apply.<\/li>\n\n\n\n<li><code>#IF ... #ENDIF<\/code>&nbsp;blocks may be nested wholly within each other<\/li>\n\n\n\n<li>The #EQU constants used in the qualifying function must be defined before the #IF block.<\/li>\n<\/ol>\n\n\n\n<h6 class=\"wp-block-heading\">Qualifying functions<\/h6>\n\n\n\n<p>There are a number of qualifying functions that can be use with&nbsp;<code>#IF<\/code>&nbsp;and&nbsp;<code>#ELSEIF<\/code>. The arguments can be text strings or numbers, or #EQU defined constants that represent text strings or numbers. Some qualifying functions work on text strings, some on numerical values. The following tables summarises them.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>Function<\/td><td>What it does<\/td><td>Example<\/td><\/tr><tr><td><code>EQ(A,B)<\/code><\/td><td>Tests if two #EQUated constants are equal. If they can both be interpreted as numbers, the comparison is performed on the numerical values. If either is not numerical, they are tested for string equality ignoring case (Cat and caT are equal).<\/td><td><code>EQ(Cat,Dog) <\/code>fails<code>EQ(Cat,caT) <\/code>passes<code>EQ(12, 12.0) -<\/code>&nbsp;passes<\/td><\/tr><tr><td><code>NE(A,B)<\/code><\/td><td>Tests if two #EQUated constants are unequal. If they can both be interpreted as numbers, the comparison is performed on the numerical values. If either is not numerical, they are tested for string equality ignoring case.<\/td><td>&nbsp;<code>EQ(Cat,Dog) <\/code>passes<code>EQ(12, 12.0) <\/code>passes<\/td><\/tr><tr><td><code>GT(A,B)<\/code><\/td><td>Tests if A is numerically greater than B. Both must be numerical values.<\/td><td><code>RinseTime #EQU 2500<\/code><code>#IF GT(RinseTime, 1000)<\/code><\/td><\/tr><tr><td><code>GE(A,B)<\/code><\/td><td>Tests if A is numerically greater than or equal to B. Both must be numerical values.<\/td><td><code>#ELSEIF GT(RinseTime, 2000)<\/code><\/td><\/tr><tr><td><code>LT(A,B)<\/code><\/td><td>Tests if A is numerically less than B. Both must be numerical values.<\/td><td>&nbsp;<\/td><\/tr><tr><td><code>LE(A,B)<\/code><\/td><td>Tests if A is numerically less than or equal to B. Both must be numerical values.&nbsp;<\/td><td>&nbsp;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>&nbsp;The&nbsp;<code>#EQU<\/code>&nbsp;constants used in qualifying functions must be defined before they are used.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Oh Dear &#8211; it seems the\u00a0#ELSE\u00a0feature is currently broken in SPLat\/PC.\u00a0 As a work-around, you can use ELSEIF like this: #IF EQ( YourThing ); if&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2504,"menu_order":4,"template":"","class_list":["post-2570","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>#IF, #ELSEIF, #ELSE, #ENDIF (Conditional code translation) - 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=\"#IF, #ELSEIF, #ELSE, #ENDIF (Conditional code translation) - SPLat Controls\" \/>\n<meta property=\"og:description\" content=\"Oh Dear &#8211; it seems the\u00a0#ELSE\u00a0feature is currently broken in SPLat\/PC.\u00a0 As a work-around, you can use ELSEIF like this: #IF EQ( YourThing ); if...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/if-elseif-else-endif-conditional-code-translation\/\" \/>\n<meta property=\"og:site_name\" content=\"SPLat Controls\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-10T11:12:34+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\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/if-elseif-else-endif-conditional-code-translation\/\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/if-elseif-else-endif-conditional-code-translation\/\",\"name\":\"#IF, #ELSEIF, #ELSE, #ENDIF (Conditional code translation) - SPLat Controls\",\"isPartOf\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website\"},\"datePublished\":\"2025-04-16T05:46:10+00:00\",\"dateModified\":\"2025-06-10T11:12:34+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/if-elseif-else-endif-conditional-code-translation\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/if-elseif-else-endif-conditional-code-translation\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/if-elseif-else-endif-conditional-code-translation\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Programming reference\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Instructions arranged by function\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"# Hash commands and functions\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"#IF, #ELSEIF, #ELSE, #ENDIF (Conditional code translation)\"}]},{\"@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":"#IF, #ELSEIF, #ELSE, #ENDIF (Conditional code translation) - 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":"#IF, #ELSEIF, #ELSE, #ENDIF (Conditional code translation) - SPLat Controls","og_description":"Oh Dear &#8211; it seems the\u00a0#ELSE\u00a0feature is currently broken in SPLat\/PC.\u00a0 As a work-around, you can use ELSEIF like this: #IF EQ( YourThing ); if...","og_url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/if-elseif-else-endif-conditional-code-translation\/","og_site_name":"SPLat Controls","article_modified_time":"2025-06-10T11:12:34+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\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/if-elseif-else-endif-conditional-code-translation\/","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/if-elseif-else-endif-conditional-code-translation\/","name":"#IF, #ELSEIF, #ELSE, #ENDIF (Conditional code translation) - SPLat Controls","isPartOf":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website"},"datePublished":"2025-04-16T05:46:10+00:00","dateModified":"2025-06-10T11:12:34+00:00","breadcrumb":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/if-elseif-else-endif-conditional-code-translation\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/if-elseif-else-endif-conditional-code-translation\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/if-elseif-else-endif-conditional-code-translation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/"},{"@type":"ListItem","position":2,"name":"Programming reference","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/"},{"@type":"ListItem","position":3,"name":"Instructions arranged by function","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/"},{"@type":"ListItem","position":4,"name":"# Hash commands and functions","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/"},{"@type":"ListItem","position":5,"name":"#IF, #ELSEIF, #ELSE, #ENDIF (Conditional code translation)"}]},{"@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\/2570","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\/2504"}],"wp:attachment":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/media?parent=2570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}