void cmdSaveAs(TclInterp interp, string[] argv)
        {
            //Create a file save box.
            interp.Eval("set types { {\"Text files\" {.txt .doc}} {\"All files\" {*}} }");
            interp.Eval("set file [tk_getSaveFile -filetypes $types]");

            string filename = interp.GetVar("file");

            Console.WriteLine(filename);

            if (filename != "")
            {
                //Get text from the text box
                interp.Eval("set data [.text get 1.0 end]");
                string data = interp.GetVar("data");

                //Open the file and dump it's contents into our text box.
                TextWriter file = File.CreateText(filename);
                file.Write(data);
                file.Close();
                interp.Eval("set data {}");

                //Change the titlebar to reflect filename change.
                string command = "wm title . \"C# Notepad Using TCL - ";
                command += filename;
                command += "\"";
                interp.Eval(command);
            }
        }
        void cmdOpen(TclInterp interp, string[] argv)
        {
            //Create a file open box.
            interp.Eval("set types { {\"Text files\" {.txt .doc}} {\"All files\" {*}} }");
            interp.Eval("set file [tk_getOpenFile -filetypes $types]");

            string filename = interp.GetVar("file");

            if (filename != "")
            {
                cur_filename = filename;
                //Clear the text box.
                interp.Eval(".text delete 1.0 end");

                //Open the file and dump it's contents into our text box.
                TextReader file = File.OpenText(filename);
                string     command;
                command  = ".text insert end {";
                command += file.ReadToEnd();
                command += "}";

                interp.Eval(command);
                file.Close();

                //Update titlebar to reflect filename changes.
                command  = "wm title . \"C# Notepad Using TCL - ";
                command += filename;
                command += "\"";
                interp.Eval(command);
            }
        }
        void cmdExit(TclInterp interp, string[] argv)
        {
            interp.Eval("set query [tk_messageBox -icon question -title \"Quit\" -message \"You may have unsaved changes,\nare you sure?\" -type yesno]");
            string result = interp.GetVar("query");

            if (result == "yes")
            {
                interp.Eval("exit");
            }
        }
        void cmdNew(TclInterp interp, string[] argv)
        {
            interp.Eval("set query [tk_messageBox -icon question -title \"New\" -message \"Are you sure?\" -type yesno]");
            string result = interp.GetVar("query");

            if (result == "yes")
            {
                interp.Eval(".text delete 1.0 end");

                //Update the titlebar to reflect filename
                interp.Eval("wm title . \"C# Notepad Using TCL - Untitled\"");
            }
        }
        void cmdSave(TclInterp interp, string[] argv)
        {
            //Create a file save box.
            if (cur_filename == null)
            {
                cmdSaveAs(interp, argv);
            }
            else
            {
                //Get text from the text box
                interp.Eval("set data [.text get 1.0 end]");
                string data = interp.GetVar("data");

                //Open the file and dump it's contents into our text box.
                TextWriter file = File.CreateText(cur_filename);
                file.Write(data);
                file.Close();
                interp.Eval("set data {}");
            }
        }