From e0bcb9a91abb775a9fc830523328b5c52d73cd9d Mon Sep 17 00:00:00 2001 From: tfoman Date: Tue, 9 Dec 2014 00:52:02 +0100 Subject: [PATCH] Completed code generation new method --- CobXmlSupport/GenCobCode.cs | 33 +++++++++++++----- CobXmlSupport/IndStatus.cs | 62 +++++++++++++++++----------------- CobXmlSupport/qualifieldhlp.cs | 40 +++++++++++++++++----- 3 files changed, 88 insertions(+), 47 deletions(-) diff --git a/CobXmlSupport/GenCobCode.cs b/CobXmlSupport/GenCobCode.cs index d0f07b3..eefd217 100644 --- a/CobXmlSupport/GenCobCode.cs +++ b/CobXmlSupport/GenCobCode.cs @@ -1682,10 +1682,12 @@ namespace CobXmlSupport private void btnTestThings_Click(object sender, EventArgs e) { + bool adj = true; fromToMoves = new ShowCode(); fromToMoves.Parent = this; fromToMoves.Labeltext = "Testing to Creat \"move From \" Code"; + Dictionary testIndexes = new Dictionary(); IndexState lIs = new IndexState(testIndexes,rowList); //if (qldList == null) @@ -1705,28 +1707,43 @@ namespace CobXmlSupport indSt.handleStatus(tmpQfh.indexStrings); for (int i = 0; i < indSt.Returns; i++) { - fromToMoves.CodeShower.Text += "END-PERFORM" + "\r\n"; + fromToMoves.CodeShower.Text += " END-PERFORM" + "\r\n"; } if (indSt.NewInds != null) { foreach (string indTxt in indSt.NewInds) { - fromToMoves.CodeShower.Text += "PERFORM VARYING " + indTxt + " FROM 1 BY 1 UNTIL ??? " + "\r\n"; + fromToMoves.CodeShower.Text += " MOVE " + tmpQfh.qualCobRow.CountIn + "\r\n" + tmpQfh.indexRedText; + fromToMoves.CodeShower.Text += " TO " + tmpQfh.qualCobRow.CountIn.ToString().Replace(S.ettingPrefix, S.ettingExpPrefix) + "\r\n " + tmpQfh.indexRedText; + fromToMoves.CodeShower.Text += " PERFORM VARYING " + indTxt + " FROM 1 BY 1\r\n UNTIL " + + indTxt + " > " + tmpQfh.qualCobRow.CountIn.ToString() + "\r\n" + tmpQfh.indexRedText; } } //obs under development + if (tmpQfh.qualCobRow.FieldDef != "") + { + if (tmpQfh.qualCobRow.FieldName.ToUpper().Contains("_VALUE")) { } + else fromToMoves.CodeShower.Text += " IF " + tmpQfh.qualCobRow.CountIn.ToString() + "\r\n" + tmpQfh.indexText + " > 0 \r\n"; - fromToMoves.CodeShower.Text += "IF "+ tmpQfh.qualCobRow.CountIn.ToString()+ " > 0 \r\n"; - fromToMoves.CodeShower.Text += "MOVE " + tmpQfh.ToString(); - fromToMoves.CodeShower.Text += "TO " + tmpQfh.ToExpString(); - fromToMoves.CodeShower.Text += "ELSE \r\n"; - fromToMoves.CodeShower.Text += "MOVE 0 TO " + tmpQfh.qualCobRow.CountIn.ToString().Replace(S.ettingPrefix, S.ettingExpPrefix) + "\r\n"; + fromToMoves.CodeShower.Text += " MOVE " + tmpQfh.ToString(); + fromToMoves.CodeShower.Text += " TO " + tmpQfh.ToExpString(); + + if (tmpQfh.qualCobRow.FieldName.ToUpper().Contains("_VALUE")) { } + else + { + fromToMoves.CodeShower.Text += " MOVE " + tmpQfh.qualCobRow.CountIn + "\r\n" + tmpQfh.indexText; + fromToMoves.CodeShower.Text += " TO " + tmpQfh.qualCobRow.CountIn.ToString().Replace(S.ettingPrefix, S.ettingExpPrefix) + "\r\n" + tmpQfh.indexText; + fromToMoves.CodeShower.Text += " ELSE\r\n"; + fromToMoves.CodeShower.Text += " MOVE 0 TO " + tmpQfh.qualCobRow.CountIn.ToString().Replace(S.ettingPrefix, S.ettingExpPrefix) + "\r\n" + tmpQfh.indexText; + fromToMoves.CodeShower.Text += " END-IF\r\n"; + } + } } indSt.handleStatus(null); for (int i = 0; i < indSt.Returns; i++) { - fromToMoves.CodeShower.Text += "END-PERFORM" + "\r\n"; + fromToMoves.CodeShower.Text += " END-PERFORM" + "\r\n"; } diff --git a/CobXmlSupport/IndStatus.cs b/CobXmlSupport/IndStatus.cs index b960e08..905e970 100644 --- a/CobXmlSupport/IndStatus.cs +++ b/CobXmlSupport/IndStatus.cs @@ -23,24 +23,24 @@ namespace CobXmlSupport /// innehåller en string array med aktuella index för den kommande variabeln public void handleStatus(string[] new_Inds) { - Debug.WriteLine("------- present indexs -------"); - foreach (string prind in presentInds.ToArray()) - { - Debug.Write(prind + ", "); - } - Debug.WriteLine(""); - Debug.WriteLine("------- new indexs -------"); + //Debug.WriteLine("------- present indexs -------"); + //foreach (string prind in presentInds.ToArray()) + //{ + // Debug.Write(prind + ", "); + //} + //Debug.WriteLine(""); + //Debug.WriteLine("------- new indexs -------"); - if (new_Inds != null) - { - foreach (string nind in new_Inds) - { - Debug.Write(nind + ", "); - } - Debug.WriteLine(""); - } - else - Debug.WriteLine(" = null "); + //if (new_Inds != null) + //{ + // foreach (string nind in new_Inds) + // { + // Debug.Write(nind + ", "); + // } + // Debug.WriteLine(""); + //} + //else + // Debug.WriteLine(" = null "); returns = 0; @@ -76,21 +76,21 @@ namespace CobXmlSupport } else newInds = null; - Debug.WriteLine("------- returns -------"); - Debug.Write(returns); - Debug.WriteLine(""); + //Debug.WriteLine("------- returns -------"); + //Debug.Write(returns); + //Debug.WriteLine(""); - Debug.WriteLine("------- tillagda Inds -------"); - if (newInds != null) - { - foreach (string tlind in newInds) - { - Debug.Write(tlind + ", "); - } - Debug.WriteLine(""); - } - else - Debug.WriteLine(" = null "); + //Debug.WriteLine("------- tillagda Inds -------"); + //if (newInds != null) + //{ + // foreach (string tlind in newInds) + // { + // Debug.Write(tlind + ", "); + // } + // Debug.WriteLine(""); + //} + //else + // Debug.WriteLine(" = null "); } diff --git a/CobXmlSupport/qualifieldhlp.cs b/CobXmlSupport/qualifieldhlp.cs index 08b27c6..1002f64 100644 --- a/CobXmlSupport/qualifieldhlp.cs +++ b/CobXmlSupport/qualifieldhlp.cs @@ -11,7 +11,7 @@ namespace CobXmlSupport private CobRow qualifiedRow; private List qualRows; private Dictionary locIndexis; - private string qfhCode, qfhInd ; + private string qfhCode, qfhInd, qfhRedInd ; private string[] indexStrs; public CobRow qualCobRow @@ -27,6 +27,11 @@ namespace CobXmlSupport get { return qfhInd; } } + public string indexRedText + { + get { return qfhRedInd; } + } + public string[] indexStrings { get { return indexStrs; } @@ -69,7 +74,7 @@ namespace CobXmlSupport { if (qfhCode.Length > 0) { - qfhCode += " OF "; + qfhCode += " OF "; } if (exp) qfhCode += localCobRow.FieldName.Replace(S.ettingPrefix, S.ettingExpPrefix); else qfhCode += localCobRow.FieldName; @@ -91,26 +96,44 @@ namespace CobXmlSupport private void initLocIndexTxt() { qfhInd = ""; + qfhRedInd = ""; indexStrs = null; if (locIndexis!=null && locIndexis.Count > 0) { - indexStrs=new string[locIndexis.Count]; int indCnt = 0; - foreach (KeyValuePair tmpInd in locIndexis) + indexStrs = locIndexis.Values.ToArray(); + foreach (KeyValuePair tmpInd in locIndexis.Reverse()) { - indexStrs[indCnt++] = tmpInd.Value; - if (qfhInd.Length == 0) { - qfhInd = "( " + tmpInd.Value; + qfhInd = " ( " + tmpInd.Value; } else { - qfhInd += ",\r\n" + tmpInd.Value; + qfhInd += ",\r\n " + tmpInd.Value; } } qfhInd += " )\r\n"; + if (locIndexis.Count > 1) + { + foreach (KeyValuePair tmpInd in locIndexis.Reverse()) + { + indCnt++; + if (indCnt == locIndexis.Count) break; + if (qfhRedInd.Length == 0) + { + qfhRedInd = " ( " + tmpInd.Value; + } + else + { + qfhRedInd += ",\r\n " + tmpInd.Value; + } + } + qfhRedInd += " )\r\n"; + + } } + } @@ -143,6 +166,7 @@ namespace CobXmlSupport else break; } initLocIndexTxt(); + } public override string ToString()