{"id":53,"date":"2024-09-25T03:45:04","date_gmt":"2024-09-25T02:45:04","guid":{"rendered":"http:\/\/monkey.ploogie.co.uk\/?page_id=53"},"modified":"2024-09-28T09:51:14","modified_gmt":"2024-09-28T08:51:14","slug":"switch","status":"publish","type":"page","link":"https:\/\/monkey.ploogie.co.uk\/index.php\/switch\/","title":{"rendered":"switch"},"content":{"rendered":"<h2>Syntax<\/h2>\n<pre>switch ( expression ) {\r\n    case a : { BLOCK }\r\n    . . .\r\n    case p ,q, r : { BLOCK }\r\n    case n: {BLOCK}\r\n    default: {BLOCK}\r\n}<\/pre>\n<h2>Parameters<\/h2>\n<div class=\"table-wrap\">\n<table class=\"confluenceTable tablesorter tablesorter-default\">\n<thead>\n<tr class=\"tablesorter-headerRow\">\n<th class=\"confluenceTh sortableHeader tablesorter-headerAsc\" data-column=\"0\">\n<div class=\"tablesorter-header-inner\">Parameter<\/div>\n<\/th>\n<th class=\"confluenceTh sortableHeader\" data-column=\"1\">\n<div class=\"tablesorter-header-inner\">Definition<\/div>\n<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"confluenceTd\"><em>a,b, &#8230; p,q,r, &#8230; n<\/em><\/td>\n<td class=\"confluenceTd\">values indicating the value of the variable that will cause the corresponding BLOCK to be executed<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\"><em>expression<\/em><\/td>\n<td class=\"confluenceTd\">PSL expression whose integer value specifies the PSL statement BLOCK that will be executed<\/td>\n<\/tr>\n<tr>\n<td class=\"confluenceTd\"><em>BLOCK<\/em><\/td>\n<td class=\"confluenceTd\">one or more statements that are executed when the corresponding <em>case<\/em> value equals variable<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2>Description<\/h2>\n<p>The\u00a0<em>switch<\/em> statement evaluates <em>expression<\/em> and based on its integer value executes a specific <em>BLOCK<\/em>. The\u00a0<em>case<\/em> labels correspond to the values of <em>expression<\/em> for which a specific <em>BLOCK<\/em> is available. <br class=\"atl-forced-newline\" \/><br class=\"atl-forced-newline\" \/>If the value of <em>expression<\/em> falls outside the range of the values in the\u00a0<em>case<\/em> labels, execution continues with the <em>BLOCK<\/em> corresponding to the <em>default<\/em> label. If no <em>default <\/em>label exists, execution will continue with the first statement following the\u00a0<em>switch<\/em> statement. <br class=\"atl-forced-newline\" \/><br class=\"atl-forced-newline\" \/>The <em>switch <\/em>statement is similar in form and function to the C <em>switch<\/em> statement. <br class=\"atl-forced-newline\" \/><br class=\"atl-forced-newline\" \/>The <code>switch<\/code> statement executes in almost the same way as a long sequence of <code>if<\/code> &#8211; <code>then<\/code> &#8211; <code>else<\/code> &#8211; <code>if<\/code> statements. A <code>case<\/code> or <code>default<\/code> clause is effectively a run-time statement that specifies a comparison against the value of <em>expression<\/em>:<\/p>\n<ul>\n<li>If the value of <em>expression<\/em> matches a <code>case<\/code>, execution moves inside the <em>BLOCK<\/em> for the <code>case<\/code> or <code>default<\/code> clause; and after completing <em>BLOCK<\/em>, execution continues after the entire switch statement (that is, there is no falling through to the next case clause).<\/li>\n<li>If the value of <em>expression<\/em> does not match a <code>case<\/code>, execution skips to the <code>default<\/code> clause; and if there is none, execution moves to the statement following the <code>switch<\/code> statement.<\/li>\n<\/ul>\n<p>Any statement within the <code>switch<\/code> statement case block that is not part of a <code>case<\/code> or <code>default<\/code> <em>BLOCK<\/em> executes only if all the <code>case<\/code> labels above it failed to match <em>expression<\/em> (that is, it executes as part of the normal sequence of control flow).<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Syntax switch ( expression ) { case a : { BLOCK } . . . case p ,q, r : { BLOCK } case n: {BLOCK} default: {BLOCK} } Parameters Parameter Definition a,b, &#8230; p,q,r, &#8230; n values indicating the value of the variable that will cause the corresponding BLOCK to be executed expression PSL &hellip; <a href=\"https:\/\/monkey.ploogie.co.uk\/index.php\/switch\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;switch&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-53","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/53","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=53"}],"version-history":[{"count":4,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/53\/revisions"}],"predecessor-version":[{"id":111,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/53\/revisions\/111"}],"wp:attachment":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=53"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}