Completed code generation new method

This commit is contained in:
2014-12-09 00:52:02 +01:00
parent 1a78dcc16d
commit e0bcb9a91a
3 changed files with 88 additions and 47 deletions

View File

@ -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<string, string> testIndexes = new Dictionary<string, string>();
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";
}

View File

@ -23,24 +23,24 @@ namespace CobXmlSupport
/// <param name="new_Inds">innehåller en string array med aktuella index för den kommande variabeln</param>
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 ");
}

View File

@ -11,7 +11,7 @@ namespace CobXmlSupport
private CobRow qualifiedRow;
private List<CobRow> qualRows;
private Dictionary<string, string> 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<string, string> tmpInd in locIndexis)
indexStrs = locIndexis.Values.ToArray();
foreach (KeyValuePair<string, string> 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<string, string> 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()