Official Everybody Edits Forums

Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?

You are not logged in.

#1 2015-08-17 23:43:52

ParadoxInTheVoid
Member
From: ̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺
Joined: 2015-02-18
Posts: 341

[Problem] Console printing when I don't want it to

With the included code if i just hit enter without putting in any arguments is prints out:

 - There was an error when trying to change value PREFIX.
 - There was an error when trying to change the value SEPERATOR.
public static void Main(string[] args)
        {
            string input = "  ";
            string appTitle = "CacheMoney";
            string consolePrefix = "CM";
            string consoleSeperator = "$";
            Dictionary<string, string> dictionary = new Dictionary<string, string>();
            while (input != "dah")
            {
                Console.ForegroundColor = ConsoleColor.White; Console.Write(consolePrefix); Console.ForegroundColor = ConsoleColor.Green; Console.Write(" " + consoleSeperator + " "); Console.ResetColor();
                Console.Title = appTitle;
                input = Console.ReadLine();
                string[] parse = input.Split(' ');
                if (parse[0] == "exit" || parse[0] == "quit")
                    input = "dah";
                if (parse[0] == "set")
                    try { if (parse[1] == "title") appTitle = parse[2]; } catch { Console.WriteLine(" - There was an error when trying to change the value TITLE."); }
                    try { if (parse[1] == "prefix" || parse[1] == "pre") consolePrefix = parse[2]; } catch { Console.WriteLine(" - There was an error when trying to change value PREFIX."); }
                    try { if (parse[1] == "seperator" || parse[1] == "sep") consoleSeperator = parse[2]; } catch { Console.WriteLine(" - There was an error when trying to change the value SEPERATOR."); }
                if (parse[0] == "mbox" || parse[0] == "messagebox")
                    try { MBOX(parse[1], input.Substring(parse[2].Length + 1 + parse[0].Length + 1)); } catch { Console.WriteLine(" - There was an error when trying to create a MessageBox."); }
                if (parse[0] == "print")
                    try { Console.WriteLine(" - " + parse[1]); } catch { Console.WriteLine(" - There was an error when trying to use the print function."); }
                if (parse[0] == "definition" || parse[0] == "define" || parse[0] == "def")
                    try { Console.WriteLine(dictionary[parse[1]]); } catch { Console.WriteLine(" - There was an error when trying to find a definition."); }
            }
        }

signature.png

Offline

#2 2015-08-17 23:51:34

ParadoxInTheVoid
Member
From: ̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺̺
Joined: 2015-02-18
Posts: 341

Re: [Problem] Console printing when I don't want it to

Nevermind, I decided to close off the if statements with '{}'s and it worked perfectly fine. This thread never happened.


signature.png

Offline

#3 2015-08-18 00:24:58

Processor
Member
Joined: 2015-02-15
Posts: 2,246

Re: [Problem] Console printing when I don't want it to

It never happened.


I have never thought of programming for reputation and honor. What I have in my heart must come out. That is the reason why I code.

Offline

Processor1439853898531462

Board footer

Powered by FluxBB

[ Started around 1732458154.8509 - Generated in 0.045 seconds, 13 queries executed - Memory usage: 1.36 MiB (Peak: 1.45 MiB) ]