{"componentChunkName":"component---src-templates-default-template-tsx","path":"/ki-syntax/functions/if/","result":{"data":{"asciidoc":{"id":"c31facd1-17f1-5551-a32c-6e18ce9737ff","html":"<div id=\"toc\" class=\"toc\">\n<div id=\"toctitle\">Table of Contents</div>\n<ul class=\"sectlevel1\">\n<li><a href=\"#definition\">Definition</a></li>\n<li><a href=\"#usage\">Usage</a></li>\n<li><a href=\"#_example\">Example</a></li>\n</ul>\n</div>\n<div id=\"preamble\">\n<div class=\"sectionbody\">\n<div class=\"admonitionblock note\">\n<table>\n<tr>\n<td class=\"icon\">\n<i class=\"fa icon-note\" title=\"Note\"></i>\n</td>\n<td class=\"content\">\nAvoid using <code>if</code> constructs for large algorithms in a single KI. Please see the <a href=\"https://user-guides.engine.datagroup.de/7.0/ki-syntax/definitions/ki-structure/#branching-if\">Logical Branching</a> section for more information.\n</td>\n</tr>\n</table>\n</div>\n</div>\n</div>\n<div class=\"sect1\">\n<h2 id=\"definition\">Definition</h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p><code>if</code> allows conditional execution. It contains a condition to be evaluated first. If the condition is true, the <code>then</code> block gets executed. Otherwise if the condition is false, the optional <code>else</code> block gets executed.</p>\n</div>\n</div>\n</div>\n<div class=\"sect1\">\n<h2 id=\"usage\">Usage</h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>The <code>if</code> block will check the exit code of a command:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-elixir\" data-lang=\"elixir\">stdout: ExecuteOutput,\nexit: Error = execute(\n\"/some/command/path -with arguments\",\nhost: \"_AAE_\"\n)\n\nif Error then\n    log.error(\"command exited with non-zero exit code\")\nelse\n    log(\"execute returned ${ExecuteOutput}\")\nend</code></pre>\n</div>\n</div>\n</div>\n</div>\n<div class=\"sect1\">\n<h2 id=\"_example\">Example</h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>The following example will check the numerical exit code of a command:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-elixir\" data-lang=\"elixir\">if LOCAL::CODE == \"0\" then\n    persData = \"extracted\"\n    delete(GetPersonData)\nelse\n    persData = \"failed\"\n    log(\"failed to get data for Person: ${persNo}\")\nend</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>You can also use \"and\" and \"or\" to consider multiple conditions within a single <code>if</code> block.</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-elixir\" data-lang=\"elixir\">if LOCAL::CODE == \"0\" and LOCAL::Status == \"SUCCESS\" then\n    persData = \"extracted\"\n    delete(GetPersonData)\nend</code></pre>\n</div>\n</div>\n</div>\n</div>","document":{"main":"if","title":"if","subtitle":""},"fields":{"toc":true,"location":["ki-syntax","functions","if"]}},"sidebarYaml":{"id":"6f28bdca-d703-5e79-ae00-b0508f8ee82a","showIndex":true}},"pageContext":{"id":"c31facd1-17f1-5551-a32c-6e18ce9737ff","parent":"ki-syntax"}},"staticQueryHashes":["1010459453","1010459453","2356112386","2356112386","2603905930","2603905930","3026652197","3026652197","3167850324","3167850324","63159454","63159454"]}