private void rpgForm_Load(object sender, EventArgs e) { string freeOut = "", fixedLine = ""; fixedLine = NppFunctions.GetLine(NppFunctions.GetLineNumber()); freeOut = RPGFree.getFree(fixedLine); if (freeOut != "") { textBox1.Text = fixedLine; textBox2.Text = freeOut; } else { this.Close(); MessageBox.Show("Unable to convert line."); } }
private void ConvertSelectedRPG() { if (this.ReadOnly) { return; } if (textEditor.SelectedText == "") { MessageBox.Show("Please highlight the code you want to convert and then try the conversion again.", "Fixed-To-Free", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { string[] lines = textEditor.SelectedText.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); string freeForm = ""; for (int i = 0; i < lines.Length; i++) { freeForm = RPGFree.getFree(lines[i]); if (freeForm != "") { switch (freeForm.Trim()) { case "*SAME;": //Do nothing! break; case "*BLANK;": lines[i] = ""; break; default: lines[i] = freeForm; break; } } } textEditor.SelectedText = String.Join(Environment.NewLine, lines); } }
public void ConvertSelectedRPG() { if (textEditor.SelectedText == "") { MessageBox.Show("Please highlight the code you want to convert and then try the conversion again.", "Fixed-To-Free", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { string[] lines = textEditor.SelectedText.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); string freeForm = ""; for (int i = 0; i < lines.Length; i++) { freeForm = RPGFree.getFree(lines[i]); if (freeForm != "") { lines[i] = freeForm; } } textEditor.SelectedText = String.Join(Environment.NewLine, lines); } }
private void rpgFileConvert_Load(object sender, EventArgs e) { this._curFile = NppFunctions.GetCurrentFileName(); this.Text = "RPG Conversion - " + this._curFile; if (File.Exists(this._curFile)) { string[] lines = File.ReadAllLines(this._curFile); //string[] newLines = new string[lines.Length]; Boolean isPI = false, isPR = false, isDS = false; string curLine = "", curLineStart = "", extraLine = ""; for (int i = 0; i < lines.Length; i++) { curLine = RPGFree.getFree(lines[i]); if (curLine.Contains(" ")) { curLineStart = curLine.TrimStart().Split(' ')[0].ToUpper().Trim(); } else { curLineStart = "*linestart"; } if (curLineStart != "DCL-PARM" && curLineStart != "DCL-SUBF" && curLine != "*NAMEREM") { if (isPR) { extraLine = "".PadLeft(7) + "End-Pr;"; isPR = false; } else if (isPI) { extraLine = "".PadLeft(7) + "End-Pi;"; isPI = false; } else if (isDS) { extraLine = "".PadLeft(7) + "End-Ds;"; isDS = false; } else { extraLine = ""; } if (extraLine != "") { AppendNewText(richTextBox2, extraLine, Color.Green); AppendNewText(richTextBox2, "", Color.Black); } } if (curLine == "*BLANK" || curLine == "*NAMEREM") { AppendNewText(richTextBox1, lines[i].TrimEnd(), Color.Red); } else if (curLine != "") { #region adding end-** blocks switch (curLineStart) { case "DCL-PR": isPR = true; break; case "DCL-PI": isPI = true; break; case "DCL-DS": isDS = true; break; } #endregion AppendNewText(richTextBox2, curLine, Color.Green); AppendNewText(richTextBox1, lines[i].TrimEnd(), Color.Red); } else { AppendNewText(richTextBox2, lines[i].TrimEnd(), Color.Black); AppendNewText(richTextBox1, lines[i].TrimEnd(), Color.Black); } } } else { this.Close(); MessageBox.Show("To convert a large section of source the file must be stored locally. Save the file first and then try again.", "Information about file conversion", MessageBoxButtons.OK, MessageBoxIcon.Information); } }