ok, so i have my code but when the if statement is over i would like to go back to a line of code BEFORE the if statement. help?
5 replies to this topic
#1
Posted 11 January 2011 - 05:29 PM
|
|
|
#2
Posted 11 January 2011 - 07:32 PM
Could you post some code so we could see what you mean?
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.
Science is only an educated theory, which we cannot disprove.
#3
Posted 12 January 2011 - 10:00 AM
You could use goto if C# has something like that (I know that it's frowned upon, but it might solve your problem).
Greets,
artificial
Greets,
artificial
Sometimes words ain't enough to express something. That's why computer scientists use double words.
#4
Posted 12 January 2011 - 11:53 AM
Here's the code. i already tried goto(thats why its in a comment because i comment mistakes out so i can see what worked and what didn't)
[Code] //Commands;
String CommandsTrigger = Console.ReadLine();
if (CommandsTrigger == "HELP")||
(CommandsTrigger == "help")||
(CommandsTrigger == "Help")
{
Console.WriteLine("Clear | Clears console");
Console.WriteLine("About | Shows information");
Console.WriteLine("Game | Play Guess the Number");
String Activity = Console.ReadLine();
if (Activity == "Clear")
{
Console.Clear;
//goto case Commands;
}
if (Activity == "About")
{
Console.WriteLine("Operating system: Nova 1 Black Viper");
Console.WriteLine("Created by Austin DeLauney");
Console.WriteLine("Uses COSMOS boot kernel");
//goto case Commands;
}[/Code
]
[Code] //Commands;
String CommandsTrigger = Console.ReadLine();
if (CommandsTrigger == "HELP")||
(CommandsTrigger == "help")||
(CommandsTrigger == "Help")
{
Console.WriteLine("Clear | Clears console");
Console.WriteLine("About | Shows information");
Console.WriteLine("Game | Play Guess the Number");
String Activity = Console.ReadLine();
if (Activity == "Clear")
{
Console.Clear;
//goto case Commands;
}
if (Activity == "About")
{
Console.WriteLine("Operating system: Nova 1 Black Viper");
Console.WriteLine("Created by Austin DeLauney");
Console.WriteLine("Uses COSMOS boot kernel");
//goto case Commands;
}[/Code
]
#5
Posted 12 January 2011 - 12:11 PM
Interesting code. I haven't worked with console for a while but try this code:
static void Main(string[] args)
{
Console.WriteLine("Clear | Clears console");
Console.WriteLine("About | Shows information");
Console.WriteLine("Game | Play Guess the Number");
while (true)
{
String CommandsTrigger = Console.ReadLine();
if ((CommandsTrigger == "HELP") || (CommandsTrigger == "help") || (CommandsTrigger == "Help"))
{
Console.WriteLine("Clear | Clears console");
Console.WriteLine("About | Shows information");
Console.WriteLine("Game | Play Guess the Number");
}
else if (CommandsTrigger == "Clear")
{
Console.Clear();
//goto case Commands;
}
else if (CommandsTrigger == "About")
{
Console.WriteLine("Operating system: Nova 1 Black Viper");
Console.WriteLine("Created by Austin DeLauney");
Console.WriteLine("Uses COSMOS boot kernel");
//goto case Commands;
}
}
}
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.
Science is only an educated theory, which we cannot disprove.
#6
Posted 12 January 2011 - 02:26 PM
THANKS! i am making an operating system with cosmos. i had a lot of code so i didn't want to put the whole thing in so i put that snippet in to see what your method was for doing it
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









