{"id":26,"date":"2014-11-06T04:47:47","date_gmt":"2014-11-06T04:47:47","guid":{"rendered":"http:\/\/parablog-wordpress.dockerbox.rei.moe\/?p=26"},"modified":"2014-11-06T04:47:47","modified_gmt":"2014-11-06T04:47:47","slug":"powershell-for-loops","status":"publish","type":"post","link":"https:\/\/blog.lewys.eu\/?p=26","title":{"rendered":"Powershell For loops"},"content":{"rendered":"<p>For loops have three parts:<\/p>\n<p>For ($1; $2; $3){<\/p>\n<p>}<\/p>\n<p>$1 is the initial value<br \/>\n$2 is the condition<br \/>\n$3 is what to loop<\/p>\n<p>first, $1 is checked against the condition ($2) then, $3 is run and checked against the condition, if it still matches the condition, the loop continues.<br \/>\nif it no longer matches the condition, the loop exits.<\/p>\n<p>refer to le dodgy diagram<\/p>\n<p><a href=\"http:\/\/172.16.0.6:8683\/wp-content\/uploads\/2014\/11\/dodgediagram.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-28\" src=\"http:\/\/172.16.0.6:8683\/wp-content\/uploads\/2014\/11\/dodgediagram-300x246.png\" alt=\"dodgediagram\" width=\"300\" height=\"246\" srcset=\"https:\/\/blog.lewys.eu\/wp-content\/uploads\/2014\/11\/dodgediagram-300x246.png 300w, https:\/\/blog.lewys.eu\/wp-content\/uploads\/2014\/11\/dodgediagram.png 458w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Broken Example Code:<\/p>\n<p>&nbsp;<\/p>\n<p>#I couldnt figure out the factorials and it kept getting me confused and stuck so ill use addition instead. &gt;dealwithit.gif<\/p>\n<p>clear-host<br \/>\n$nums =@()<br \/>\n$array =@()<\/p>\n<p>[int]$times = read-host &#8220;how many sums will you do&#8221;<\/p>\n<p>For ($i=0; $i -lt $times; $i++)<br \/>\n{<\/p>\n<p>$num1 = read-host &#8220;enter a number&#8221;<br \/>\n$num2 = read-host &#8220;enter a second number&#8221;<\/p>\n<p>$num3 = [int]$num1 + [int]$num2<\/p>\n<p>$array = @($num1,$num2,$num3)<br \/>\nwrite-host $num1&#8243;+&#8221;$num2&#8243;=&#8221;$num3<br \/>\n}<br \/>\nFor ($i=0; $i -lt $times; $i++){<br \/>\nwrite-host &#8220;Nums&#8221;`t&#8221;Sum&#8221;<br \/>\nwrite-host $array[-$array.count]$array[-2] `t $array[-1]<br \/>\nwrite-host $array[$i]`t$<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For loops have three parts: For ($1; $2; $3){ } $1 is the initial value $2 is the condition $3 is what to loop first, $1 is checked against the condition ($2) then, $3 is run and checked against the condition, if it still matches the condition, the loop continues. if it no longer matches &hellip; <a href=\"https:\/\/blog.lewys.eu\/?p=26\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Powershell For loops<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,22],"tags":[16,5,3,2],"class_list":["post-26","post","type-post","status-publish","format-standard","hentry","category-educational","category-reference","tag-code","tag-notes","tag-powershell","tag-programming"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=\/wp\/v2\/posts\/26","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26"}],"version-history":[{"count":2,"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=\/wp\/v2\/posts\/26\/revisions"}],"predecessor-version":[{"id":29,"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=\/wp\/v2\/posts\/26\/revisions\/29"}],"wp:attachment":[{"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.lewys.eu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}