コード例 #1
0
        //End functie generare

        private void GenerateButton_Click(object sender, EventArgs e)
        {
            int    nrAnds = 0, nrOrs = 0, nrElementDeCautat = 0;
            string toSearch = "Empty", elementDeCautat = "";

            string[] vectorElementDeCautat = new string[10];
            string   functionName = "Vda_Calculate", variable, valoare, outputPath, functionType = "void";

            string[] vectorValori = new string[10];
            try
            {
                toSearch = File.ReadAllText(filePath);
            }
            catch (IOException ioe)
            {
                Console.WriteLine(ioe.ToString());
            }
            catch (ArgumentNullException ane)
            {
                Console.WriteLine(ane.ToString());
            }

            Console.WriteLine(toSearch);



            //Daca fisierul contine "InvalidDataError" se va deschide interfata de la Hoza
            if (toSearch.Contains("InvalidDataError"))
            {
                //Parametrii InvalidDataError++++++++++++++++++++++++++++++++++
                String[] liniiFis;

                ArrayList define               = new ArrayList();
                ArrayList richTextBox          = new ArrayList();
                String    conditia_din_functie = "";



                ArrayList operatoriLogici = new ArrayList();
                ArrayList stanga          = new ArrayList();
                ArrayList semn            = new ArrayList();
                ArrayList dreapta         = new ArrayList();

                //End Parametrii

                if (!File.ReadAllText(filePath).Contains("Preconditions:"))
                {
                    liniiFis = File.ReadAllLines(filePath);

                    foreach (String it in liniiFis)
                    {
                        //Operatorii logici
                        if (it.Equals("AND"))
                        {
                            operatoriLogici.Add("&&");
                        }
                        else if (it.Equals("OR"))
                        {
                            operatoriLogici.Add("||");
                        }
                    }
                }
                else
                {
                    liniiFis = File.ReadAllLines(filePath);
                    foreach (String it in liniiFis)
                    {
                        //Operatorii logici
                        operatoriLogici.Add("&&");
                    }
                }

                foreach (String it in liniiFis)
                {
                    //Operatorii logici
                    if (it.Equals("AND"))
                    {
                        operatoriLogici.Add("&&");
                    }
                    else if (it.Equals("OR"))
                    {
                        operatoriLogici.Add("||");
                    }

                    //Preconditii && Define
                    string pattern1 = @"""(\w*)""\s*(\S*)\s*'(\w*=\w*)'";
                    string pattern2 = @"""(\w*)""\s*(\S*)\s*'(\w*)'";
                    Match  match1   = Regex.Match(it, pattern1, RegexOptions.IgnoreCase);
                    Match  match2   = Regex.Match(it, pattern2, RegexOptions.IgnoreCase);

                    if (match1.Success && !it.Contains("InvalidDataError"))
                    {
                        if (match1.Groups[2].Value.Equals("<>"))
                        {
                            semn.Add("!=");
                        }
                        else
                        {
                            semn.Add(match1.Groups[2].Value);
                        }
                        richTextBox.Add("type " + match1.Groups[1].Value + "\n");
                        stanga.Add(match1.Groups[1].Value);
                        Match aux = Regex.Match(match1.Groups[3].Value, @"(\w*)=(\w*)", RegexOptions.IgnoreCase);
                        dreapta.Add("VDA_IST_" + aux.Groups[2].Value.ToUpper());
                        define.Add("#define " + "VDA_IST_" + aux.Groups[2].Value.ToUpper() + " " + aux.Groups[1].Value + "\n");
                    }
                    if (match2.Success && !it.Contains("InvalidDataError"))
                    {
                        if (match2.Groups[2].Value.Equals("<>"))
                        {
                            semn.Add("!=");
                        }
                        else
                        {
                            semn.Add(match2.Groups[2].Value);
                        }
                        richTextBox.Add("type " + match2.Groups[1].Value + "\n");
                        stanga.Add(match2.Groups[1].Value);
                        dreapta.Add("VDA_IST_" + match2.Groups[3].Value.ToUpper());
                        define.Add("#define " + "VDA_IST_" + match2.Groups[3].Value.ToUpper() + "\n");
                    }
                }

                for (int i = 0; i < dreapta.Count - 1; i++)
                {
                    conditia_din_functie += "(" + stanga[i] + semn[i] + dreapta[i] + ")" + operatoriLogici[i];
                    //File.AppendAllText(outputFile, "(" + stanga[i] + semn[i] + dreapta[i] + ")\n");
                    //File.AppendAllText(outputFile, "" + operatoriLogici[i]);
                }
                conditia_din_functie += "(" + stanga[dreapta.Count - 1] + semn[dreapta.Count - 1] + dreapta[dreapta.Count - 1] + ")";

                outputPath = filePath.Substring(0, filePath.Length - ((fileName.Length) + 1));
                InvalidDataError.InterfataInvalidDataError(define, richTextBox, conditia_din_functie, outputPath);
            }

            //Altfel se va deschide interfata de la Eric
            else
            {
                Match matchElemDeCautat = Regex.Match(toSearch, "IF\\s*\"([a-zA-z0-9]+)\"\\s*");
                if (matchElemDeCautat.Success)
                {
                    elementDeCautat = matchElemDeCautat.Groups[1].Value;
                    Console.WriteLine("elem de cautat---------------->" + elementDeCautat);
                    while (matchElemDeCautat.Success)
                    {
                        vectorElementDeCautat[nrElementDeCautat++] = matchElemDeCautat.Groups[1].Value;
                        matchElemDeCautat = matchElemDeCautat.NextMatch();
                    }
                }
                else
                {
                    Console.WriteLine("elem de cautat----------------------------------> NOT FOUND");
                }

                Match matchElemDeCautatAnd = Regex.Match(toSearch, "AND\\s*\"([a-zA-z0-9]+)\"\\s*");
                if (matchElemDeCautatAnd.Success)
                {
                    elementDeCautat = matchElemDeCautatAnd.Groups[1].Value;
                    Console.WriteLine("elem de cautat---------------->" + elementDeCautat);
                    while (matchElemDeCautatAnd.Success)
                    {
                        vectorElementDeCautat[nrElementDeCautat++] = matchElemDeCautatAnd.Groups[1].Value;
                        matchElemDeCautatAnd = matchElemDeCautatAnd.NextMatch();
                    }
                }

                Match matchElemDeCautatOr = Regex.Match(toSearch, "OR\\s*\"([a-zA-z0-9]+)\"\\s*");
                if (matchElemDeCautatOr.Success)
                {
                    elementDeCautat = matchElemDeCautatOr.Groups[1].Value;
                    Console.WriteLine("elem de cautat---------------->" + elementDeCautat);
                    while (matchElemDeCautatOr.Success)
                    {
                        vectorElementDeCautat[nrElementDeCautat++] = matchElemDeCautatOr.Groups[1].Value;
                        matchElemDeCautatOr = matchElemDeCautatOr.NextMatch();
                    }
                }



                Match matchFunctionName = Regex.Match(toSearch, "THEN:\\s*\"\\w*_([a-zA-z0-9]+)\"\\s*");
                if (matchFunctionName.Success)
                {
                    functionName = functionName + matchFunctionName.Groups[1].Value;
                    Console.WriteLine("function name-------------->" + functionName);
                }
                else
                {
                    Console.WriteLine("function name-------------------------> NOT FOUND");
                }

                Match matchVariable = Regex.Match(toSearch, "THEN:\\s*\"(\\w+)\"\\s*");
                if (matchVariable.Success)
                {
                    variable = matchVariable.Groups[1].Value;
                    Console.WriteLine("variable-------------->" + variable);
                }
                else
                {
                    variable = "NOT FOUND";
                    Console.WriteLine("variable------------------------->" + variable);
                }


                Match matchValoare = Regex.Match(toSearch, @"\'([0-9])");
                if (matchValoare.Success)
                {
                    int i = 0;
                    //valoare = matchValoare.Groups[1].Value;
                    while (matchValoare.Success)
                    {
                        vectorValori[i] = matchValoare.Groups[1].Value;
                        matchValoare    = matchValoare.NextMatch();
                        i++;
                    }


                    /* Console.WriteLine("valoare-------------->" + valoare);
                     * Console.WriteLine("valoare-------------->" + matchValoare.NextMatch().Groups[1].Value);
                     * Console.WriteLine("valoare-------------->" + matchValoare.NextMatch().NextMatch().Groups[1].Value);
                     */
                    for (int j = 0; j < vectorValori.Length; j++)
                    {
                        if (vectorValori[j] != null)
                        {
                            Console.WriteLine("valoare-------------->" + vectorValori[j]);
                        }
                    }
                }
                else
                {
                    valoare = "NOT FOUND";
                    Console.WriteLine("valoare------------------------->" + valoare);
                }

                Match numarAnd = Regex.Match(toSearch, "AND");
                if (numarAnd.Success)
                {
                    while (numarAnd.Success)
                    {
                        nrAnds++;
                        numarAnd = numarAnd.NextMatch();
                    }
                }
                Console.WriteLine("nrAnds------------------------->" + nrAnds);

                Match numarOr = Regex.Match(toSearch, "OR");
                if (numarOr.Success)
                {
                    while (numarOr.Success)
                    {
                        nrOrs++;
                        numarOr = numarOr.NextMatch();
                    }
                }
                Console.WriteLine("nrOrs------------------------->" + nrOrs);

                int   ElseIfCondition = 0;
                Match okElseIf        = Regex.Match(toSearch, "ELSE:\\s*IF");
                if (okElseIf.Success)
                {
                    ElseIfCondition = 1;
                }
                Console.WriteLine("ELSEIFCONDITION------------------------->" + ElseIfCondition);


                Console.WriteLine("file path ------------->" + filePath);

                void orCondition()
                {
                    int          k            = 0;
                    StreamWriter streamWriter = new StreamWriter(outputPath + "\\output1.c", false, Encoding.ASCII);

                    functieReadHoza = Cautare(RteVdaFile, vectorElementDeCautat[0]);
                    tipVarDarian    = regexFunctieDBC(DBCFile, vectorElementDeCautat[0]);
                    tipVar2Darian   = regexFunctieDBC(DBCFile, vectorElementDeCautat[0]);

                    int i = 0;

                    streamWriter.Write(
                        functionType + " " + functionName + "(" + functionType + ")" + "\r\n" +
                        "{" + "\r\n" +
                        tipVarDarian + " " + variable + ";" + "\r\n"
                        );

                    for (i = 0; i < vectorElementDeCautat.Length; i++)
                    {
                        if (vectorElementDeCautat[i] != null)
                        {
                            streamWriter.Write(
                                tipVar2Darian + " " + vectorElementDeCautat[i] + ";" + "\r\n" +
                                functieReadHoza + "(&" + vectorElementDeCautat[i] + ");" + "\r\n"
                                );
                        }
                    }

                    i = 0;
                    streamWriter.Write(
                        "if(" + vectorElementDeCautat[i] + " == " + vectorValori[k++] + ")"
                        );

                    for (i = 1; i < vectorElementDeCautat.Length; i++)
                    {
                        if (vectorElementDeCautat[i] != null)
                        {
                            streamWriter.Write(
                                " || (" + vectorElementDeCautat[i] + " == " + vectorValori[k++] + ")" + "\r\n"
                                );
                        }
                    }

                    streamWriter.Write(

                        "{" + "\r\n" +
                        "\t" + variable + " = " + vectorValori[k++] + ";" + "\r\n" +
                        "}" + "\r\n" +
                        "else" + "\r\n" +
                        "{" + "\r\n" +
                        "\t" + variable + " = " + vectorValori[k++] + ";" + "\r\n" +
                        "}" + "\r\n" +
                        "}" + "\r\n" + "\r\n");

                    streamWriter.Close();
                    MessageBox.Show("FileOutput a fost generat !!!");
                    this.Close();
                }

                void andCondition()
                {
                    int          k            = 0;
                    StreamWriter streamWriter = new StreamWriter(outputPath + "\\output1.c", false, Encoding.ASCII);

                    functieReadHoza = Cautare(RteVdaFile, vectorElementDeCautat[0]);
                    tipVarDarian    = regexFunctieDBC(DBCFile, vectorElementDeCautat[0]);
                    tipVar2Darian   = regexFunctieDBC(DBCFile, vectorElementDeCautat[0]);

                    int i = 0;

                    streamWriter.Write(
                        functionType + " " + functionName + "(" + functionType + ")" + "\r\n" +
                        "{" + "\r\n" +
                        tipVarDarian + " " + variable + ";" + "\r\n"
                        );

                    for (i = 0; i < vectorElementDeCautat.Length; i++)
                    {
                        if (vectorElementDeCautat[i] != null)
                        {
                            functieReadHoza = Cautare(RteVdaFile, vectorElementDeCautat[i]);
                            streamWriter.Write(
                                tipVar2Darian + " " + vectorElementDeCautat[i] + ";" + "\r\n" +
                                functieReadHoza + "(&" + vectorElementDeCautat[i] + ");" + "\r\n"
                                );
                        }
                    }

                    i = 0;
                    streamWriter.Write(
                        "if(" + vectorElementDeCautat[i] + " == " + vectorValori[k++] + ")"
                        );

                    for (i = 1; i < vectorElementDeCautat.Length; i++)
                    {
                        if (vectorElementDeCautat[i] != null)
                        {
                            streamWriter.Write(
                                " && (" + vectorElementDeCautat[i] + " == " + vectorValori[k++] + ")" + "\r\n"
                                );
                        }
                    }

                    streamWriter.Write(

                        "{" + "\r\n" +
                        "\t" + variable + " = " + vectorValori[k++] + ";" + "\r\n" +
                        "}" + "\r\n" +
                        "else" + "\r\n" +
                        "{" + "\r\n" +
                        "\t" + variable + " = " + vectorValori[k++] + ";" + "\r\n" +
                        "}" + "\r\n" +
                        "}" + "\r\n" + "\r\n");

                    streamWriter.Close();
                    MessageBox.Show("FileOutput a fost generat !!!");
                    this.Close();
                }

                void singleCondition()
                {
                    int k = 0;

                    StreamWriter streamWriter = new StreamWriter(outputPath + "\\output1.c", false, Encoding.ASCII);

                    if (ElseIfCondition == 0)
                    {
                        for (int i = 0; i <= vectorElementDeCautat.Length - 1; i++)
                        {
                            if (vectorElementDeCautat[i] != null)
                            {
                                functieReadHoza = Cautare(RteVdaFile, vectorElementDeCautat[i]);
                                tipVarDarian    = regexFunctieDBC(DBCFile, vectorElementDeCautat[i]);
                                tipVar2Darian   = regexFunctieDBC(DBCFile, vectorElementDeCautat[i]);


                                streamWriter.Write(
                                    functionType + " " + functionName + "(" + functionType + ")" + "\r\n" +
                                    "{" + "\r\n" +
                                    tipVarDarian + " " + variable + ";" + "\r\n" +
                                    tipVar2Darian + " " + vectorElementDeCautat[i] + ";" + "\r\n" +
                                    functieReadHoza + "(&" + vectorElementDeCautat[i] + ");" + "\r\n" +
                                    "if(" + vectorElementDeCautat[i] + " == " + vectorValori[k++] + ")" + "\r\n" +
                                    "{" + "\r\n" +
                                    "\t" + variable + " = " + vectorValori[k++] + ";" + "\r\n" +
                                    "}" + "\r\n" +
                                    "else" + "\r\n" +
                                    "{" + "\r\n" +
                                    "\t" + variable + " = " + vectorValori[k++] + ";" + "\r\n" +
                                    "}" + "\r\n" +
                                    "}" + "\r\n" + "\r\n"
                                    );
                            }
                        }
                    }
                    else
                    {
                        functieReadHoza = Cautare(RteVdaFile, vectorElementDeCautat[0]);
                        tipVarDarian    = regexFunctieDBC(DBCFile, vectorElementDeCautat[0]);
                        tipVar2Darian   = regexFunctieDBC(DBCFile, vectorElementDeCautat[0]);

                        int i = 0;
                        streamWriter.Write(
                            functionType + " " + functionName + "(" + functionType + ")" + "\r\n" +
                            "{" + "\r\n" +
                            tipVarDarian + " " + variable + ";" + "\r\n"
                            );

                        for (i = 0; i < vectorElementDeCautat.Length; i++)
                        {
                            if (vectorElementDeCautat[i] != null)
                            {
                                streamWriter.Write(
                                    tipVar2Darian + " " + vectorElementDeCautat[i] + ";" + "\r\n" +
                                    functieReadHoza + "(&" + vectorElementDeCautat[i] + ");" + "\r\n"
                                    );
                            }
                        }

                        i = 0;
                        streamWriter.Write(
                            "if(" + vectorElementDeCautat[i] + " == " + vectorValori[k++] + ")" + "\r\n" +
                            "{" + "\r\n" +
                            "\t" + variable + " = " + vectorValori[k++] + ";" + "\r\n" +
                            "}" + "\r\n" +
                            "else" + "\r\n" +
                            "if" + "(" + vectorElementDeCautat[++i] + "==" + vectorValori[k++] + ")" + "\r\n" +
                            "{" + "\r\n" +
                            "\t" + variable + " = " + vectorValori[k++] + ";" + "\r\n" +
                            "}" + "\r\n" +
                            "else" + "\r\n" +
                            "{" + "\r\n" +
                            variable + " = " + vectorValori[k++] + ";" + "\r\n" +
                            "}" + "\r\n" +
                            "}" + "\r\n" + "\r\n"
                            );
                    }

                    MessageBox.Show("FileOutput a fost generat !!!");
                    streamWriter.Close();
                    this.Close();
                }

                void multipleConditions(string[] vectorTipuriParametrii, string[] vectorParametriiFaraValori)
                {
                    int k = 0;

                    tipVarDarian    = valoriParametriiFaraValori[0];
                    tipVar2Darian   = valoriParametriiFaraValori[0];
                    functieReadHoza = Cautare(RteVdaFile, vectorElementDeCautat[0]);


                    StreamWriter streamWriter = new StreamWriter(outputPath + "\\output1.c", false, Encoding.ASCII);

                    streamWriter.Write(
                        functionType + " " + functionName + "(");

                    int i = 0;

                    for (i = 0; i < vectorTipuriParametrii.Length - 1; i++)
                    {
                        if (vectorTipuriParametrii[i + 1] != null)
                        {
                            streamWriter.Write(vectorTipuriParametrii[i] + " " + vectorParametriiFaraValori[i] + ",");
                        }
                    }

                    i = 0;
                    while (vectorTipuriParametrii[i + 1] != null)
                    {
                        i++;
                    }

                    streamWriter.Write(vectorTipuriParametrii[i] + " " + vectorParametriiFaraValori[i] + ")" + "\r\n");

                    streamWriter.Write(

                        "{" + "\r\n" +
                        tipVarDarian + " " + variable + ";" + "\r\n" +
                        "if(" + vectorElementDeCautat[i] + " == " + vectorValori[k++] + ")"
                        );

                    if (nrAnds > 0)
                    {
                        for (int j = 1; j < vectorElementDeCautat.Length; j++)
                        {
                            if (vectorElementDeCautat[j] != null)
                            {
                                streamWriter.Write(
                                    " && (" + vectorElementDeCautat[j] + " == " + vectorValori[k++] + ")" + "\r\n"
                                    );
                            }
                        }
                    }

                    if (nrOrs > 0)
                    {
                        for (int j = 1; j < vectorElementDeCautat.Length; j++)
                        {
                            if (vectorElementDeCautat[j] != null)
                            {
                                streamWriter.Write(
                                    " || (" + vectorElementDeCautat[j] + " == " + vectorValori[k++] + ")" + "\r\n"
                                    );
                            }
                        }
                    }

                    streamWriter.Write(
                        "{" + "\r\n" +
                        "\t" + variable + " = " + vectorValori[k++] + ";" + "\r\n" +
                        "}" + "\r\n" +
                        "else" + "\r\n" +
                        "{" + "\r\n" +
                        "\t" + variable + " = " + vectorValori[k++] + ";" + "\r\n" +
                        "}" + "\r\n" +
                        "}"
                        );
                    streamWriter.Close();
                    this.Close();
                }

                if (DBCOpen == true && RteOpen == true && inputOpen == true)
                {
                    outputPath = filePath.Substring(0, filePath.Length - ((fileName.Length) + 1));

                    try
                    {
                        Console.WriteLine("output path --------->" + outputPath);
                        try
                        {
                            //daca nu se gaseste vreun parametru in dbc sau vda_rte (folosind functiile de la Hoza si Darian)
                            if ((typeOfInputFile(DBCFile, elementDeCautat).Equals("null")))
                            {
                                parametriiFaraValori[indexParametriiFaraValori++] = elementDeCautat;

                                Console.WriteLine("++++++++++++=>ParamFaraVal");

                                for (int i = 0; i < parametriiFaraValori.Length; i++)
                                {
                                    if (parametriiFaraValori[i] != null)
                                    {
                                        Console.WriteLine(i + " " + parametriiFaraValori[i]);
                                    }
                                }

                                string promptValue = ParametriiPrompt.ShowDialog("Multiple unidentified variables have been found, please insert their values here",
                                                                                 "Variable names needed",
                                                                                 parametriiFaraValori);

                                try
                                {
                                    multipleConditions(valoriParametriiFaraValori, parametriiFaraValori);
                                }
                                catch (Exception exc)
                                {
                                    Console.WriteLine("Exception" + exc.Message);
                                }
                            }
                            else
                            {
                                //daca parametrii sunt gasiti in dbc sau rte_vda (folosind functiile de la Hoza si Darian)

                                if (nrAnds > 0)
                                {
                                    try
                                    {
                                        andCondition();
                                    }
                                    catch (Exception exc)
                                    {
                                        Console.WriteLine("Exception" + exc.Message);
                                    }
                                }
                                else if (nrOrs > 0)
                                {
                                    try
                                    {
                                        orCondition();
                                    }
                                    catch (Exception exc)
                                    {
                                        Console.WriteLine("Exception" + exc.Message);
                                    }
                                }
                                else
                                {
                                    try
                                    {
                                        singleCondition();
                                    }
                                    catch (Exception exc)
                                    {
                                        Console.WriteLine("Exception" + exc.Message);
                                    }
                                }
                            }
                        }
                        catch (FileNotFoundException fnfe)
                        {
                            Console.WriteLine(fnfe.ToString());
                            MessageBox.Show(
                                "File not found",
                                "Warning",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                        }
                        catch (IOException ioe)
                        {
                            MessageBox.Show(
                                "Something went wrong",
                                "Warning",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                            Console.WriteLine(ioe.ToString());
                        }
                    }
                    catch (NullReferenceException nre)
                    {
                        MessageBox.Show(
                            "Something went wrong",
                            "Warning",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Warning);
                        Console.WriteLine(nre.ToString());
                    }
                }
                else
                {
                    MessageBox.Show(
                        "You must select all 3 files",
                        "Warning",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Warning);
                }
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: m5eric/ProiectColectivHella
        ///EndHoza

        private void GenerateButton_Click(object sender, EventArgs e)
        {
            int    nrAnds = 0, nrOrs = 0, nrElementDeCautat = 0;
            string toSearch = "Empty", elementDeCautat = "";

            string[] vectorElementDeCautat = new string[10];
            string   functionName = "Vda_Calculate", variable, valoare, outputPath, functionType = "void";

            string[] vectorValori = new string[10];
            try
            {
                toSearch = File.ReadAllText(filePath);
            }
            catch (IOException ioe)
            {
                Console.WriteLine(ioe.ToString());
            }
            catch (ArgumentNullException ane)
            {
                Console.WriteLine(ane.ToString());
            }

            Console.WriteLine(toSearch);

            Match matchElemDeCautat = Regex.Match(toSearch, "IF\\s*\"([a-zA-z0-9]+)\"\\s*");

            if (matchElemDeCautat.Success)
            {
                elementDeCautat = matchElemDeCautat.Groups[1].Value;
                Console.WriteLine("elem de cautat---------------->" + elementDeCautat);
                while (matchElemDeCautat.Success)
                {
                    vectorElementDeCautat[nrElementDeCautat++] = matchElemDeCautat.Groups[1].Value;
                    matchElemDeCautat = matchElemDeCautat.NextMatch();
                }
            }
            else
            {
                Console.WriteLine("elem de cautat----------------------------------> NOT FOUND");
            }



            Match matchFunctionName = Regex.Match(toSearch, "THEN:\\s*\"\\w*_([a-zA-z0-9]+)\"\\s*");

            if (matchFunctionName.Success)
            {
                functionName = functionName + matchFunctionName.Groups[1].Value;
                Console.WriteLine("function name-------------->" + functionName);
            }
            else
            {
                Console.WriteLine("function name-------------------------> NOT FOUND");
            }

            Match matchVariable = Regex.Match(toSearch, "THEN:\\s*\"(\\w+)\"\\s*");

            if (matchVariable.Success)
            {
                variable = matchVariable.Groups[1].Value;
                Console.WriteLine("variable-------------->" + variable);
            }
            else
            {
                variable = "NOT FOUND";
                Console.WriteLine("variable------------------------->" + variable);
            }


            Match matchValoare = Regex.Match(toSearch, @"\'([0-9])");

            if (matchValoare.Success)
            {
                int i = 0;
                //valoare = matchValoare.Groups[1].Value;
                while (matchValoare.Success)
                {
                    vectorValori[i] = matchValoare.Groups[1].Value;
                    matchValoare    = matchValoare.NextMatch();
                    i++;
                }


                /* Console.WriteLine("valoare-------------->" + valoare);
                 * Console.WriteLine("valoare-------------->" + matchValoare.NextMatch().Groups[1].Value);
                 * Console.WriteLine("valoare-------------->" + matchValoare.NextMatch().NextMatch().Groups[1].Value);
                 */
                for (int j = 0; j < vectorValori.Length; j++)
                {
                    if (vectorValori[j] != null)
                    {
                        Console.WriteLine("valoare-------------->" + vectorValori[j]);
                    }
                }
            }
            else
            {
                valoare = "NOT FOUND";
                Console.WriteLine("valoare------------------------->" + valoare);
            }

            Match numarAnd = Regex.Match(toSearch, "AND");

            if (numarAnd.Success)
            {
                while (numarAnd.Success)
                {
                    nrAnds++;
                    numarAnd = numarAnd.NextMatch();
                }
            }
            Console.WriteLine("nrAnds------------------------->" + nrAnds);

            Match numarOr = Regex.Match(toSearch, "OR");

            if (numarOr.Success)
            {
                while (numarOr.Success)
                {
                    nrOrs++;
                    numarOr = numarOr.NextMatch();
                }
            }
            Console.WriteLine("nrOrs------------------------->" + nrOrs);


            Console.WriteLine("file path ------------->" + filePath);



            void singleCondition()
            {
                int k = 0;

                StreamWriter streamWriter = new StreamWriter(outputPath + "\\output1.c", false, Encoding.ASCII);

                for (int i = 0; i <= vectorElementDeCautat.Length - 1; i++)
                {
                    if (vectorElementDeCautat[i] != null)
                    {
                        functieReadHoza = Cautare(RteVdaFile, vectorElementDeCautat[i]);
                        tipVarDarian    = regexFunctieDBC(DBCFile, vectorElementDeCautat[i]);
                        tipVar2Darian   = regexFunctieDBC(DBCFile, vectorElementDeCautat[i]);


                        streamWriter.Write(
                            functionType + " " + functionName + "(" + functionType + ")" + "\r\n" +
                            "{" + "\r\n" +
                            tipVarDarian + " " + variable + ";" + "\r\n" +
                            tipVar2Darian + " " + vectorElementDeCautat[i] + ";" + "\r\n" +
                            functieReadHoza + "(&" + vectorElementDeCautat[i] + ");" + "\r\n" +
                            "if(" + vectorElementDeCautat[i] + " == " + vectorValori[k++] + ")" + "\r\n" +
                            "{" + "\r\n" +
                            "\t" + variable + " = " + vectorValori[k++] + ";" + "\r\n" +
                            "}" + "\r\n" +
                            "else" + "\r\n" +
                            "{" + "\r\n" +
                            "\t" + variable + " = " + vectorValori[k++] + ";" + "\r\n" +
                            "}" + "\r\n" +
                            "}" + "\r\n" + "\r\n"
                            );
                    }
                }

                streamWriter.Close();
                this.Close();
            }

            void multipleConditions(string[] vectorTipuriParametrii, string[] vectorParametriiFaraValori)
            {
                int k = 0;

                tipVarDarian  = valoriParametriiFaraValori[0];
                tipVar2Darian = valoriParametriiFaraValori[0];


                StreamWriter streamWriter = new StreamWriter(outputPath + "\\output1.c", false, Encoding.ASCII);

                streamWriter.Write(
                    functionType + " " + functionName + "(");

                int i = 0;

                for (i = 0; i < vectorTipuriParametrii.Length - 1; i++)
                {
                    if (vectorTipuriParametrii[i + 1] != null)
                    {
                        streamWriter.Write(vectorTipuriParametrii[i] + " " + vectorParametriiFaraValori[i] + ",");
                    }
                }

                i = 0;
                while (vectorTipuriParametrii[i + 1] != null)
                {
                    i++;
                }

                streamWriter.Write(vectorTipuriParametrii[i] + " " + vectorParametriiFaraValori[i] + ")" + "\r\n");

                streamWriter.Write(
                    "{" + "\r\n" +
                    tipVarDarian + " " + variable + ";" + "\r\n" +


                    "if(" + elementDeCautat + " == " + vectorValori[k++] + ")" + "\r\n" +
                    "{" + "\r\n" +
                    "\t" + variable + " = " + vectorValori[k++] + ";" + "\r\n" +
                    "}" + "\r\n" +
                    "else" + "\r\n" +
                    "{" + "\r\n" +
                    "\t" + variable + " = " + vectorValori[k++] + ";" + "\r\n" +
                    "}" + "\r\n" +
                    "}"
                    );
                streamWriter.Close();
                this.Close();
            }

            //bool tempOk = false;
            if (DBCOpen == true && RteOpen == true && inputOpen == true)
            {
                outputPath = filePath.Substring(0, filePath.Length - ((fileName.Length) + 1));
                if (nrAnds == 0 && nrOrs == 0)
                {
                    try
                    {
                        Console.WriteLine("output path --------->" + outputPath);
                        try
                        {
                            //daca nu se gaseste vreun parametru in dbc sau vda_rte (folosind functiile de la Hoza si Darian)
                            if ((typeOfInputFile(DBCFile, elementDeCautat).Equals("null")))
                            {
                                parametriiFaraValori[indexParametriiFaraValori++] = elementDeCautat;

                                Console.WriteLine("++++++++++++=>ParamFaraVal");

                                for (int i = 0; i < parametriiFaraValori.Length; i++)
                                {
                                    if (parametriiFaraValori[i] != null)
                                    {
                                        Console.WriteLine(i + " " + parametriiFaraValori[i]);
                                    }
                                }

                                string promptValue = ParametriiPrompt.ShowDialog("Multiple unidentified variables have been found, please insert their values here",
                                                                                 "Variable names needed",
                                                                                 parametriiFaraValori);

                                try
                                {
                                    multipleConditions(valoriParametriiFaraValori, parametriiFaraValori);
                                }
                                catch (Exception exc)
                                {
                                    Console.WriteLine("Exception" + exc.Message);
                                }

                                //tempOk = true;
                            }
                            else
                            {
                                //daca parametrii sunt gasiti in dbc sau rte_vda (folosind functiile de la Hoza si Darian)

                                try
                                {
                                    singleCondition();
                                }
                                catch (Exception exc)
                                {
                                    Console.WriteLine("Exception" + exc.Message);
                                }
                            }
                        }
                        catch (FileNotFoundException fnfe)
                        {
                            Console.WriteLine(fnfe.ToString());
                            MessageBox.Show(
                                "File not found",
                                "Warning",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                        }
                        catch (IOException ioe)
                        {
                            MessageBox.Show(
                                "Something went wrong",
                                "Warning",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                            Console.WriteLine(ioe.ToString());
                        }
                    }
                    catch (NullReferenceException nre)
                    {
                        MessageBox.Show(
                            "Something went wrong",
                            "Warning",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Warning);
                        Console.WriteLine(nre.ToString());
                    }
                }
            }
            else
            {
                MessageBox.Show(
                    "You must select all 3 files",
                    "Warning",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
            }
        }