private conftype parseConfigLine(string line) { if (line == null) { return(null); } int length = 0, pos = 0; while (pos < line.Length && (line[pos] == ' ' || line[pos] == '\t')) { pos++; } int i = pos; while (i < line.Length && line[i] != ' ' && line[i] != '\t' && line[i] != '=') { i++; length++; } if (length <= 0 || i >= line.Length || line[i] != '=') { return(null); } conftype conf = new conftype(line.Substring(pos, length)); pos = pos + length + 1; while (pos < line.Length && (line[pos] == ' ' || line[pos] == '\t')) { pos++; } i = pos; length = 0; while (i < line.Length && line[i] != '\n') { i++; length++; } if (length > 0) { conf.value = line.Substring(pos, length); } return(conf); }
private void scriptLoad() { if (File.Exists(this.scriptFile)) { String[] qs_lines = System.IO.File.ReadAllLines(this.scriptFile); int line = 0; // Go to the line of [Configuration] while (line < qs_lines.Length) { if (qs_lines[line].IndexOf("[Configuration]") != -1) { line++; break; } else { line++; } } // Read configurations this.configList = new List <conftype>(); while (line < qs_lines.Length && qs_lines[line].IndexOf("[Events and Actions]") == -1) { conftype conf = parseConfigLine(qs_lines[line]); if (conf != null) { this.configList.Add(conf); } else if (qs_lines[line].Length > 0) { Console.WriteLine("Unrecognized config line: " + qs_lines[line]); } line++; } // TODO: Need to add back! //this.configComboBox.SelectedIndex = -1; // Read actions line++; this.actions = new List <actionlinetype>(); while (line < qs_lines.Length) { actionlinetype action = parseActionLine(qs_lines[line]); if (action != null) { this.actions.Add(action); } else { Console.WriteLine("Unrecognized action in line " + (line + 1).ToString() + ", which will be removed if you save the current scripts!"); } line++; } checkQScript(this.configList, this.actions); //flashListBoxActions(); //if (this.actions.Count > 0) // listBoxActionsSelect(0); } }