Hi, everyone.
I’m building the simple state machine described in the documentation here: State Machine
You’re asked to guess a number between 1 and 100. You input something, and you’re told if your guess is higher or lower until you guess the integer.
I wanted to add some more functionality in case some makes a guess outside of the accepted range (ie, <1 or >100) or enters something that is not the Int32 type. So, I added a Try-Catch (see attached project).
My catches work; a message box appears after someone enters an incorrect guess. It will say “Your guess is not between 1 and 100.” or tell us the System.Exception message.
The problem is, right after it does this, I want it to ask me to guess again. Instead, it tells me that my guess is “too low” or “too high” and then asks me to guess again. For some reason, it is catching the exception and evaluating the previous intGuess, then asking us to guess again. I don’t want it to evaluate intGuess at this point.
Can anyone take a look at this file and figure out why it’s doing this?
Main.xaml (26.6 KB)
Update 1: Here’s a picture of the State Machine. I added the “Reset State” as a way to try to get this to stop evaluating intGuess after an Exception, but it did not fix the issue.
Update 2: I reworked it a bit, and now it’s doing something similar, but still unwanted. The message box with the exception message is now appearing twice at the points I have indicated with an arrow. Here is the new workflow, too.
Main.xaml (33.8 KB)