This project is read-only.

I cannot figure out how to..?

Jul 20, 2011 at 10:38 AM

Hi I am working on a project and i need a way for the console to go back to its original state after the user types something in, or something that doesnt exist. For Example if the user types in help, then the help shows up but then after that the user cant type in anything else until it is restarted. How do I fix this?

This is my code.

Command = Console.ReadLine();
            if (Command == "Shutdown")
            {
                Cosmos.Sys.Deboot.ShutDown();
            }
            else if (Command == "Restart")
            {
                Cosmos.Sys.Deboot.Reboot();
            }
            else if (Command == "Hello")
            {
                Console.Write("Hello");
            }
            else if (Command == "About")
            {
                Console.Write("Example OS");
            }
            else if (Command == "Color")
            {
                Console.Write("There are three Colors Available; White, Green and Red. To make that the text color simply type in the Color");
                Console.Write("For Example, for Green type in 'Green' to make the text color Green");
                Console.Write("To Make It Your Background Color type in Background_Green");
                Console.Write("For Example, for a green Background type in Background_Green");
            }
            else if (Command == "Background_Green")
            {
                Console.BackgroundColor = ConsoleColor.Green;
            }
            else if (Command == "Calculator")
            {
                Console.WriteLine("Calculator In Development");
            }

 

Thanks in Advance.

Jul 21, 2011 at 12:00 AM
> This is my code.
>
> Command = Console.ReadLine();

Add a loop?
Jul 21, 2011 at 12:33 AM

 

while(true)
{
Command = Console.ReadLine();
            if (Command == "Shutdown")
            {
                Cosmos.Sys.Deboot.ShutDown();
            }
            else if (Command == "Restart")
            {
                Cosmos.Sys.Deboot.Reboot();
            }
            else if (Command == "Hello")
            {
                Console.Write("Hello");
            }
            else if (Command == "About")
            {
                Console.Write("Example OS");
            }
            else if (Command == "Color")
            {
                Console.Write("There are three Colors Available; White, Green and Red. To make that the text color simply type in the Color");
                Console.Write("For Example, for Green type in 'Green' to make the text color Green");
                Console.Write("To Make It Your Background Color type in Background_Green");
                Console.Write("For Example, for a green Background type in Background_Green");
            }
            else if (Command == "Background_Green")
            {
                Console.BackgroundColor = ConsoleColor.Green;
            }
            else if (Command == "Calculator")
            {
                Console.WriteLine("Calculator In Development");
            }

 
}
Jul 21, 2011 at 8:41 AM

Thank You Both, the while loop works great. Much Appreciated, Thanks.