I am a novice when it comes to powershell programming. I am currently taking a college course and have a question about a statement my teacher sent me in an email. We are working on a project to create a rock paper scissors game and the code has a while loop. I have used the following statement for this loop:<\/p>\n
Advertisement
while ($gamePlayControl -eq “True”) {<\/p>\n
“do stuff in loop”<\/p>\n
}<\/p>\n
I had some questions about our code as it was not lining up with some of the instructions and needed to know if our group needed to scrap our code and start from scratch. She sent me an email with a few tips, but one specifically said the following:<\/p>\n
\" If you are having issues with the main loop, try using this instead: \nWhile ($gamePlayControl -ne “False”)<\/p>\n
You are saying while it’s not equal to True, so that leaves a lot of options open, when what you really want is to loop as long as it’s not False, then you set it to False later.\"<\/p>\n
I thought “While ($gamePlayControl -eq “True”)” and “While ($gamePlayControl -ne “False”)” is saying the same thing. Is that true, or am I missing something? Thanks in advance.<\/p>","upvoteCount":3,"answerCount":8,"datePublished":"2021-04-23T18:54:56.000Z","author":{"@type":"Person","name":"michaelterry","url":"https://community.spiceworks.com/u/michaelterry"},"suggestedAnswer":[{"@type":"Answer","text":"
Hey everyone,<\/p>\n
I am a novice when it comes to powershell programming. I am currently taking a college course and have a question about a statement my teacher sent me in an email. We are working on a project to create a rock paper scissors game and the code has a while loop. I have used the following statement for this loop:<\/p>\n
while ($gamePlayControl -eq “True”) {<\/p>\n
“do stuff in loop”<\/p>\n
}<\/p>\n
I had some questions about our code as it was not lining up with some of the instructions and needed to know if our group needed to scrap our code and start from scratch. She sent me an email with a few tips, but one specifically said the following:<\/p>\n
\" If you are having issues with the main loop, try using this instead: \nWhile ($gamePlayControl -ne “False”)<\/p>\n
You are saying while it’s not equal to True, so that leaves a lot of options open, when what you really want is to loop as long as it’s not False, then you set it to False later.\"<\/p>\n
I thought “While ($gamePlayControl -eq “True”)” and “While ($gamePlayControl -ne “False”)” is saying the same thing. Is that true, or am I missing something? Thanks in advance.<\/p>","upvoteCount":3,"datePublished":"2021-04-23T18:54:57.000Z","url":"https://community.spiceworks.com/t/i-have-a-question-about-a-boolean-statement/797899/1","author":{"@type":"Person","name":"michaelterry","url":"https://community.spiceworks.com/u/michaelterry"}},{"@type":"Answer","text":"
Welcome<\/p>\n
If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n