Has anyone encountered this particular issue in Water/Fire with the Case Statement in Hydrogen(C#). It appears there may be some hidden character in the standard input stream that is tripping the Default statement to be evaluated (see attached pic)? I used a Trim function to strip any possible CRLF’s, but to no avail. I copied the program to VS C#, VS REMObjects C# as well as JetBrains Rider - and they all work as expected. The problem seems to be relegated to the Water and Fire IDE’s - they both exhibit the same behavior on my PC Desktop as well as on my MacBook Pro laptop.
namespace CaseStatementTest1
{
static class Program
{
public static void Main(string[] args)
{
int totalAttempts = 3;
string doorChoice;
for (int i = 1 ; i <= totalAttempts; i++ )
{
Console.Write($"Choose a door between 1 - 5 and win a prize! This is attempt #{i}: ");
doorChoice = Console.ReadLine();
doorChoice = doorChoice.Trim(); // attempt to strip CRLF characters from input stream
switch (doorChoice)
{
case "1":
Console.WriteLine("You win a balloon!" );
break;
case "2":
Console.WriteLine("You win a stuffed animal!" );
break;
case "3":
Console.WriteLine("You win a bicycle!" );
break;
case "4":
Console.WriteLine("You win a car!" );
break;
case "5":
Console.WriteLine("You win a million dollars!" );
break;
default:
Console.WriteLine("That's not even a choice. You win nothing!" );
break;
}
Console.WriteLine();
}
Console.ReadLine();
Console.ReadLine(); //Two needed in Fire/Water to prevent Terminal from prematurely closing
}
}
}
OK, I believe I’ve narrowed it down. The issue seems to occur when the code is generated using the “Template: Console Application (Windows) - RemObjects.Hydrogene.Island.Windows.ConsoleApplication”.
Also, of note, is that the Windows Console program requires two ‘Console.ReadLine()’ methods to prevent the Terminal from prematurely closing. As where, the Classic_Net program only requires one 'Console.ReadLine() which leads me to believe there’s an errant CRLF somewhere in the Windows Console version.
This sounds like a bug in ReadLine on Island/Windows (or Island in general), yeah…
FWIW, on Mac I can not reproduce this, I changed your code to::
writeLn(1);
Console.ReadLine();
writeLn(2);
//Console.ReadLine(); //Two ReadLines needed to prevent Terminal from prematurely closing which leads me to believe there's a 'hidden' CRLF
and it emits “1”, I press enter once, and then it emits “2” and quits. Will test on Windows later in the day when I boot up my VM…
Side quesrtion: what version are you on, latest 2611? (not that think much changed here in the past few weeks that would effect this…)
FWIW, I can repro the with .2611 on Windows too (was a few builds behind before), same as above. But I cannot reproduce this on Mac, When you say Fire, do you mean building the app as Island/macOS, or as Island/Windows and running remotely.?
That’s correct … I was running Parallels on my Mac. So composing in Fire but building for Island/Windows which executed in Windows Parallel. That’s why I stated I was a bit premature with my first post of this thread and narrowed it down to Island/Windows only