{"id":2523,"date":"2025-04-16T04:55:18","date_gmt":"2025-04-16T04:55:18","guid":{"rendered":"https:\/\/webprojects.cloud\/wordpress\/splatco\/?post_type=spl_knowledgebase&#038;p=2523"},"modified":"2025-06-10T11:30:08","modified_gmt":"2025-06-10T11:30:08","slug":"semaphore-formatting-function-ssource-trueoutput-falseoutput","status":"publish","type":"spl_knowledgebase","link":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/hmi-controller-instructions\/formatting-functions\/semaphore-formatting-function-ssource-trueoutput-falseoutput\/","title":{"rendered":"Semaphore formatting function s(Source, TrueOutput, FalseOutput)"},"content":{"rendered":"\n<p>The semaphore formatting function provides a convenient way of converting a semaphore value to something readable. It &#8220;enables&#8221; one of two alternative &#8220;messages&#8221;, depending on whether a semaphore value is true or false. As we shall see, it extends that idea quite a bit further than just semaphores and just text messages. For example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#<a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/glossary-of-terms\/#o5243\">HMI<\/a> Print(s(*sHeater, \"Heater is on \", \"Heater is off\")<\/pre>\n\n\n\n<p>If the semaphore&nbsp;<code>sHeater<\/code>&nbsp;is True, this will display&nbsp;<code>Heater is on <\/code>. Otherwise it will display&nbsp;<code>Heater is off.<\/code><\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Source specifiers<\/h6>\n\n\n\n<p>The following are the allowable source specifiers<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>Form<\/td><td>Meaning<\/td><td>Example<\/td><\/tr><tr><td><code>*sName<\/code><\/td><td>The True\/False value of a\u00a0<a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/glossary-of-terms\/#o414\">RAM<\/a>\u00a0semaphore. It\u00a0<em>must<\/em>\u00a0have been defined in a\u00a0<code><a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/directives\/defsem-directive\/\">defSEM<\/a><\/code>.<\/td><td><code>#HMI Print(s(*sMySem, \"True\", \"False\"))<\/code><\/td><\/tr><tr><td><code>=x<\/code><\/td><td>Contents of the\u00a0<a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/glossary-of-terms\/#o3808\">X<\/a>\u00a0register. Any non-zero value is treated as True.<\/td><td><code>#HMI Print(s(=x, \"NonZero\", \"Zero\"))<\/code><\/td><\/tr><tr><td><code>=y<\/code><\/td><td>Contents of the Y register. Any non-zero value is treated as True.<\/td><td><code>#HMI Print(s(=y, \"NonZero\", \"Zero\"))<\/code><\/td><\/tr><tr><td><code>=h<\/code><\/td><td>Contents of the H register. Any non-zero value is treated as True.<\/td><td><code>#HMI Print(s(=h, \"NonZero\", \"Zero\"))<\/code><\/td><\/tr><tr><td><code>=m<\/code><\/td><td>Contents of the M register. Any non-zero value is treated as True.<\/td><td><code>#HMI Print(s(=m, \"NonZero\", \"Zero\"))<\/code><\/td><\/tr><tr><td><code>=s<\/code><\/td><td>Contents of the S register. Any non-zero value is treated as True.<\/td><td><code>#HMI Print(s(=s, \"NonZero\", \"Zero\"))<\/code><\/td><\/tr><tr><td><code>Constant<\/code><\/td><td>Contents of an EQUated constant. Any non-zero value is treated as True.<\/td><td><code>Foo EQU 56<\/code><code>...<\/code><code>#HMI Print(s(Foo, \"NonZero\", \"Zero\"))<\/code><\/td><\/tr><tr><td>A number 0 &#8211; 255<\/td><td>An immediate numeric value. Any non-zero value is treated as True.<\/td><td><code>#HMI Print(s(165, \"NonZero\", \"Zero\"))<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h6 class=\"wp-block-heading\">index\/jndex modifiers<\/h6>\n\n\n\n<p>RAM semaphore references can also have index\/jndex modifiers<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>Form<\/td><td>What is sourced<\/td><td>Example code<\/td><\/tr><tr><td><code>*+ss<\/code><\/td><td>Whatever is in RAM semaphore<code> ss<\/code>, with\u00a0<code><a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/precodes\/iasj-precode-d16\/\">IasJ:<\/a><\/code>\u00a0applied<\/td><td><code>#HMI Print(s(*+sMySem, \"True\", \"False\"))<\/code><\/td><\/tr><tr><td><code>*-ss<\/code><\/td><td>Whatever is in RAM semaphore<code> ss<\/code>, with\u00a0<code><a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/precodes\/noj-precode-d16\/\">NoJ:<\/a><\/code>\u00a0applied<\/td><td><code>#HMI Print(s(*-sMySem, \"True\", \"False\"))<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>NOTE: The modifier (<code>+<\/code>\u00a0or\u00a0<code>-<\/code>) must be after the asterisk. jndexing applies only to code running inside a\u00a0<a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-multitrack\/multitrack-advanced-multi-channel-operations\/\">MultiTrack<\/a>\u00a0task.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">TrueOutput, FalseOutput arguments<\/h6>\n\n\n\n<p>The arguments defining what is to be displayed for the true and false alternatives can be any of:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A literal text string in quotes;<\/li>\n\n\n\n<li>Any other formatting function.<\/li>\n<\/ul>\n\n\n\n<p>The second of the above masks a great deal of power in this formatting function.<\/p>\n\n\n\n<p>Examples:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&#8220;Plain vanilla&#8221; selection of two text alternatives:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">#HMI Print(s(sAlive, \"Life is good\", \"Farewell, oh cruel world\")<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Switch between number and text. In this example, if the sSensorFail semaphore is true, a fault message is displayed. Otherwise, the value of a floating point variable is displayed.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">#HMI Print(s(*sSensorFail, \"Bad sensor!\", f(fTemperature, 5, 1))<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Nested semaphore formatting functions. This line effectively checks two fault conditions and displays an alarm message if either is tripped, otherwise displays &#8220;All good&#8221;.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">#HMI Print(s(*sSensorFail, \"Bad sensor\", s(*sOverflow, \"Overflow\", \"All good\")))  <\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The semaphore formatting function provides a convenient way of converting a semaphore value to something readable. It &#8220;enables&#8221; one of two alternative &#8220;messages&#8221;, depending on&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2520,"menu_order":2,"template":"","class_list":["post-2523","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>Semaphore formatting function s(Source, TrueOutput, FalseOutput) - 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=\"Semaphore formatting function s(Source, TrueOutput, FalseOutput) - SPLat Controls\" \/>\n<meta property=\"og:description\" content=\"The semaphore formatting function provides a convenient way of converting a semaphore value to something readable. It &#8220;enables&#8221; one of two alternative &#8220;messages&#8221;, depending on...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/hmi-controller-instructions\/formatting-functions\/semaphore-formatting-function-ssource-trueoutput-falseoutput\/\" \/>\n<meta property=\"og:site_name\" content=\"SPLat Controls\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-10T11:30:08+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=\"2 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\/hmi-controller-instructions\/formatting-functions\/semaphore-formatting-function-ssource-trueoutput-falseoutput\/\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/hmi-controller-instructions\/formatting-functions\/semaphore-formatting-function-ssource-trueoutput-falseoutput\/\",\"name\":\"Semaphore formatting function s(Source, TrueOutput, FalseOutput) - SPLat Controls\",\"isPartOf\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website\"},\"datePublished\":\"2025-04-16T04:55:18+00:00\",\"dateModified\":\"2025-06-10T11:30:08+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/hmi-controller-instructions\/formatting-functions\/semaphore-formatting-function-ssource-trueoutput-falseoutput\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/hmi-controller-instructions\/formatting-functions\/semaphore-formatting-function-ssource-trueoutput-falseoutput\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/hmi-controller-instructions\/formatting-functions\/semaphore-formatting-function-ssource-trueoutput-falseoutput\/#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\":\"# HMI Controller Instructions\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/hmi-controller-instructions\/\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"Formatting functions\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/hmi-controller-instructions\/formatting-functions\/\"},{\"@type\":\"ListItem\",\"position\":7,\"name\":\"Semaphore formatting function s(Source, TrueOutput, FalseOutput)\"}]},{\"@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":"Semaphore formatting function s(Source, TrueOutput, FalseOutput) - 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":"Semaphore formatting function s(Source, TrueOutput, FalseOutput) - SPLat Controls","og_description":"The semaphore formatting function provides a convenient way of converting a semaphore value to something readable. It &#8220;enables&#8221; one of two alternative &#8220;messages&#8221;, depending on...","og_url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/hmi-controller-instructions\/formatting-functions\/semaphore-formatting-function-ssource-trueoutput-falseoutput\/","og_site_name":"SPLat Controls","article_modified_time":"2025-06-10T11:30:08+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 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\/hmi-controller-instructions\/formatting-functions\/semaphore-formatting-function-ssource-trueoutput-falseoutput\/","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/hmi-controller-instructions\/formatting-functions\/semaphore-formatting-function-ssource-trueoutput-falseoutput\/","name":"Semaphore formatting function s(Source, TrueOutput, FalseOutput) - SPLat Controls","isPartOf":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website"},"datePublished":"2025-04-16T04:55:18+00:00","dateModified":"2025-06-10T11:30:08+00:00","breadcrumb":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/hmi-controller-instructions\/formatting-functions\/semaphore-formatting-function-ssource-trueoutput-falseoutput\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/hmi-controller-instructions\/formatting-functions\/semaphore-formatting-function-ssource-trueoutput-falseoutput\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/hmi-controller-instructions\/formatting-functions\/semaphore-formatting-function-ssource-trueoutput-falseoutput\/#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":"# HMI Controller Instructions","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/hmi-controller-instructions\/"},{"@type":"ListItem","position":6,"name":"Formatting functions","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/hash-commands-and-functions\/hmi-controller-instructions\/formatting-functions\/"},{"@type":"ListItem","position":7,"name":"Semaphore formatting function s(Source, TrueOutput, FalseOutput)"}]},{"@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\/2523","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\/2520"}],"wp:attachment":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/media?parent=2523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}