{"id":1057,"date":"2024-12-17T19:16:13","date_gmt":"2024-12-17T19:16:13","guid":{"rendered":"https:\/\/monkey.ploogie.co.uk\/?page_id=1057"},"modified":"2024-12-17T19:48:20","modified_gmt":"2024-12-17T19:48:20","slug":"a-simple-getopts","status":"publish","type":"page","link":"https:\/\/monkey.ploogie.co.uk\/index.php\/a-simple-getopts\/","title":{"rendered":"A Simple Getopts"},"content":{"rendered":"<p>For this script run with the arguments -a <numbher>  and\/or -b <number><\/p>\n<p>E.g<\/p>\n<p>.\/getopts -a 10 -b 1<\/p>\n<pre>\r\n#!\/usr\/bin\/env mwnci\r\nOPTIONS=rest(ARGV)\r\nA=0\r\nB=0\r\n\r\nmoreopts=true\r\nwhile (moreopts) {\r\n    switch (OPTIONS[0]) {\r\n        case \"-a\" {\r\n\t    A=int(OPTIONS[1]);\r\n\t    OPTIONS=shift(OPTIONS,2);\r\n\t }\r\n\r\n\t case \"-b\" {\r\n\t     B=int(OPTIONS[1]);\r\n\t     OPTIONS=shift(OPTIONS,2);\r\n\t }\r\n\t \r\n\t default {\r\n\t     moreopts=false;\r\n\t }\r\n    }\r\n}\r\n\r\n\r\nprintln(\"A=\", A)\r\nprintln(\"B=\", B)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>For this script run with the arguments -a and\/or -b E.g .\/getopts -a 10 -b 1 #!\/usr\/bin\/env mwnci OPTIONS=rest(ARGV) A=0 B=0 moreopts=true while (moreopts) { switch (OPTIONS[0]) { case &#8220;-a&#8221; { A=int(OPTIONS[1]); OPTIONS=shift(OPTIONS,2); } case &#8220;-b&#8221; { B=int(OPTIONS[1]); OPTIONS=shift(OPTIONS,2); } default { moreopts=false; } } } println(&#8220;A=&#8221;, A) println(&#8220;B=&#8221;, B)<\/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-1057","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/1057","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=1057"}],"version-history":[{"count":5,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/1057\/revisions"}],"predecessor-version":[{"id":1062,"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/1057\/revisions\/1062"}],"wp:attachment":[{"href":"https:\/\/monkey.ploogie.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=1057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}