/// <summary> /// Executes a script passed to the application, /// parsing the commands listed in a valid text file /// that has the extension '.mds' /// </summary> /// <param name="param"></param> public override void Execute(string param) { try { if (param != "" && param != null && param.Length < 5 && param.EndsWith(".mds")) { if (File.Exists(Paths.CurrentDirectory + Paths.Separator + param)) { string[] lines = File.ReadAllLines(param); foreach (string line in lines) { CommandConsole.Parse(line); //Console.WriteLine(""); } } else { } { CommandConsole.InvalidCommand(param, 2); } } else { Console.WriteLine("Not a valid Medliscript file."); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Executes the application. /// </summary> /// <param name="file">The file.</param> private static void ExecuteApp(string file) { string[] readlines = File.ReadAllLines(file); AppTitle = readlines[0].Substring(6); AppDesc = readlines[1].Substring(5); AppAuthor = readlines[2].Substring(7); ClearDraw(); foreach (string line in readlines) { if (line.StartsWith("Title=")) { AppTitle = line.Remove(0, 6); } else if (line.StartsWith("Desc=")) { AppDesc = line.Remove(0, 5); } else if (line.StartsWith("Author=")) { AppAuthor = line.Remove(0, 7); } else if (line == "clear") { ClearDraw(); } else if (line == "EOF") { } else { if (Console.CursorTop == 23) { ClearDraw(); } CommandConsole.Parse(line); } } }
/// <summary> /// Executes the specified parameter. /// </summary> /// <param name="param">The parameter.</param> public override void Execute(string param) { try { if (param.EndsWith(".mds")) { string[] lines = File.ReadAllLines(param); foreach (string line in lines) { CommandConsole.Parse(line); } Console.WriteLine(""); } else { Console.WriteLine("Not a valid Medli Shellscript file."); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }