public override string CodeOutput(int level)
        {
            string     levelString = new string ('\t', level);
            string     Code        = "";
            Conditions ThisParent  = ((Conditions)this.Parent.Parent);

            if (ThisParent.comboBox2.SelectedIndex != -1)
            {
                string type = "";
                Dictionary <string, string> constant = Util.GetVariableType(this);
                CheckLetters.CheckVariables(ThisParent.comboBox2.Text, this.textBox1.Text, Util.GetVariableType(this), true);
                if (constant[ThisParent.comboBox2.Text] == "string")
                {
                    type = "\"" + textBox1.Text + "\"";
                }
                else if (constant[ThisParent.comboBox2.Text] == "char")
                {
                    type = "\'" + textBox1.Text + "\"";
                }
                else
                {
                    type = textBox1.Text;
                }
                Code = levelString + "case " + type + ":" + statementBlock1.CodeOutput(level, false);
            }
            else
            {
                Form1.MessageBoxValue("caseの定数が入力されていません", true);
            }
            return(Code);
        }
        public override string CodeOutput(int level)
        {
            string levelString = new string('\t', level);
            string Code        = "";

            if (comboBox1.SelectedIndex != -1)
            {
                if (string.IsNullOrEmpty(textBox1.Text) == false)
                {
                    CheckLetters.CheckName(textBox1.Text, true);
                    List <String> vList = Util.GetVariableList(this, 0);
                    if (vList.Contains(textBox1.Text) == true)
                    {
                        Form1.MessageBoxValue("同じ名前が存在します", false);
                    }
                    else
                    {
                        Code = levelString + "List<" + itemType + ">" + textBox1.Text + " = new List<" + itemType + ">();";
                    }
                }
                else
                {
                    Form1.MessageBoxValue("リストの名前が設定されていません", true);
                }
            }
            else
            {
                Form1.MessageBoxValue("リストの型が設定されていません", true);
            }
            return(Code);
        }
        /// <summary>
        /// 名前をチェックする
        /// </summary>
        /// <param name="TextName">名前</param>
        /// <param name="type">True:エラー、False:警告</param>
        public static void CheckName(string TextName, bool type)
        {
            if (TextName == "")
            {
                return;
            }
            bool TrueOrFalse = Regex.IsMatch(TextName, "^[0-9]");

            if (TrueOrFalse == false)
            {
                TrueOrFalse = true;
                for (int i = 0; i < TextName.Length; i++)
                {
                    if (TextName[i] != 'i')
                    {
                        TrueOrFalse = false;
                    }
                }
            }
            if (TrueOrFalse == true)
            {
                Form1.MessageBoxValue("初めの文字が数、又はループで使われるの文字になっています。", type);
            }
            if (String.IsNullOrWhiteSpace(TextName) == true)
            {
                Form1.MessageBoxValue("文字が入力されていないかスペースのみになっています。", type);
            }
        }
        private void ArrayType_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (arrayType.SelectedIndex)
            {
            case -1:
                Form1.MessageBoxValue("変数の型が選択されていません", false);
                break;

            case 0:
                itemType = "int";
                break;

            case 1:
                itemType = "string";
                break;

            case 2:
                itemType = "char";
                break;

            case 3:
                itemType = "double";
                break;

            case 4:
                itemType = "byte";
                break;

            case 5:
                itemType = "bool";
                break;
            }
        }
Exemple #5
0
        public override String CodeOutput(int level)
        {
            string levelString = new string('\t', level);
            string Code        = "";

            List <String> vList = Util.GetVariableList(this, 0);

            if (vList.Contains(comboBox1.Text))
            {
                List <String> vList1 = Util.GetVariableList(this, 2);
                if (vList1.Contains(comboBox1.Text))
                {
                    Code = levelString + comboBox1.Text + " = " + "Console.ReadLine();\r\n";
                }
                else
                {
                    Form1.MessageBoxValue("string型の変数しか使えません", true);
                }
            }
            else
            {
                if (comboBox1.SelectedIndex == -1)
                {
                    Code = levelString + "Console.ReadLine();\r\n";
                }
                else
                {
                    Form1.MessageBoxValue("宣言されていない変数です", true);
                }
            }


            return(Code);
        }
        private void TextBox1_TextChanged(object sender, EventArgs e)
        {
            CheckLetters.CheckName(textBox1.Text, false);
            List <String> vList = Util.GetVariableList(this, 0);

            if (vList.Contains(textBox1.Text) == true)
            {
                Form1.MessageBoxValue("同じ名前が存在します", false);
            }
        }
        public override string CodeOutput(int level)
        {
            string levelString = new string('\t', level);
            string CodeOutput  = "";

            if (VariableDefine.NameList.Contains(textBox1.Text))
            {
                Form1.MessageBoxValue("同じ名前の変数が既にあります", true);
            }
            else
            {
                VariableDefine.NameList.Add(textBox1.Text);
            }
            if (itemType == "")
            {
                Form1.MessageBoxValue("配列の型が選択されていません", true);
            }
            else
            {
                if (string.IsNullOrWhiteSpace(textBox1.Text))
                {
                    Form1.MessageBoxValue("配列の宣言で配列の名前が入力されていません", true);
                }
                else
                {
                    CheckLetters.CheckName(textBox1.Text, true);


                    if (string.IsNullOrWhiteSpace(textBox2.Text))
                    {
                        Form1.MessageBoxValue("配列の宣言で配列の数の値が入力されていません", true);
                    }
                    else
                    {
                        int OkNumber;
                        if (int.TryParse(textBox2.Text, out OkNumber))
                        {
                            if (OkNumber < 0)
                            {
                                Form1.MessageBoxValue("配列の宣言の配列の数で不正な数値が入力されています", true);
                            }
                            else
                            {
                                CodeOutput = levelString + itemType + "[] " + textBox1.Text + " = new " + itemType + "[" + OkNumber + "];\r\n";
                            }
                        }
                        else
                        {
                            Form1.MessageBoxValue("配列の宣言の配列の数で数値以外が入力されています", true);
                        }
                    }
                }
            }
            return(CodeOutput);
        }
        private void TextBox2_TextChanged(object sender, EventArgs e)
        {
            CheckLetters.CheckNumbers(textBox2.Text, false);
            List <String> vList = Util.GetVariableList(this, 0);

            if (vList.Contains(textBox2.Text) == true)
            {
                Form1.MessageBoxValue("同じ名前が存在します", false);
            }
            ((StatementBlock)this.Parent).CheckName("nothingnothing", "nothingnothing", false);
        }
 private void ComboBox2_DropDown(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex == -1)
     {
         Form1.MessageBoxValue("先に代入する変数を選択してください", false);
     }
     else
     {
         List <string> vList = Util.GetVariableList(this, Type);
         comboBox2.Items.Clear();
         comboBox2.Items.AddRange(vList.ToArray());
     }
 }
        /// <summary>
        ///定数が変数に入るかを確認する
        /// </summary>
        /// <param name="name">変数名</param>
        /// <param name="name2">定数</param>
        /// <param name="TypeDictionary">変数のDictionary</param>
        /// <param name="type">True:エラー False:警告</param>
        public static void CheckVariables(string name, string name2, Dictionary <string, string> TypeDictionary, bool type)
        {
            switch (TypeDictionary[name])
            {
            case "int":
                int num;
                if (int.TryParse(name2, out num) == false)
                {
                    Form1.MessageBoxValue("値が型にあっていません", type);
                }
                break;

            case "double":
                double num1;
                if (double.TryParse(name2, out num1) == false)
                {
                    Form1.MessageBoxValue("値が型にあっていません", type);
                }
                break;

            case "byte":
                byte num2;
                if (byte.TryParse(name2, out num2) == false)
                {
                    Form1.MessageBoxValue("値が型にあっていません", type);
                }
                break;

            case "bool":
                if (name2.Length >= 5 || type == true)
                {
                    if (name2 == "true" || name2 == "false")
                    {
                    }
                    else
                    {
                        Form1.MessageBoxValue("この型はtrueかfalseのみ対応しています", type);
                    }
                }

                break;

            case "char":
                char num3;
                if (char.TryParse(name2, out num3) == false)
                {
                    Form1.MessageBoxValue("値が型にあっていません", type);
                }
                break;
            }
        }
 /// <summary>
 /// 変数と変数を確認
 /// </summary>
 /// <param name="name">変数1</param>
 /// <param name="name1">変数2</param>
 /// <param name="TypeDictionary">変数のDictionary</param>
 /// <param name="type">True:エラー False:警告</param>
 public static void CheckVariablesAndVariables(string name, string name1, Dictionary <string, string> TypeDictionary, bool type)
 {
     if (TypeDictionary.ContainsKey(name) && TypeDictionary.ContainsKey(name1))
     {
         if (TypeDictionary[name] != TypeDictionary[name1])
         {
             Form1.MessageBoxValue("型が異なります", type);
         }
     }
     else
     {
         Form1.MessageBoxValue("現在使われていない変数です", type);
     }
 }
        public static void CheckNumbers(string TxetType, bool type)
        {
            int number1;

            if (TxetType == "")
            {
                return;
            }

            if (int.TryParse(TxetType, out number1))
            {
            }
            else
            {
                Form1.MessageBoxValue("入力が不正です", type);
            }
        }
Exemple #13
0
        private void ComboBox4_SelectedIndexChanged(object sender, EventArgs e)
        {
            Dictionary <string, string> TypeDictionary = Util.GetVariableType(this);

            if (string.IsNullOrWhiteSpace(comboBox4.Text) == false)
            {
                if (string.IsNullOrWhiteSpace(comboBox2.Text) == false)
                {
                    List <string> vList = Util.GetVariableList(this, 0);
                    if (vList.Contains(comboBox2.Text) == false || vList.Contains(comboBox4.Text) == false)
                    {
                        Form1.MessageBoxValue("未宣言の変数が使われています", true);
                    }
                    else
                    {
                        CheckLetters.CheckVariablesAndVariables(comboBox2.Text, comboBox4.Text, TypeDictionary, false);
                    }
                }
            }
        }
        private void TextBox1_TextChanged(object sender, EventArgs e)
        {
            CheckLetters.CheckName(textBox1.Text, false);
            List <String> vList = Util.GetVariableList(this, 0);

            if (vList.Contains(textBox1.Text) == true)
            {
                Form1.MessageBoxValue("同じ名前が存在します", false);
            }
            else
            {
                if (string.IsNullOrEmpty(textBox1.Text) == false)
                {
                    ((StatementBlock)this.Parent).CheckName(textBox1.Text, Name, true);
                }
                else
                {
                    ((StatementBlock)this.Parent).CheckName(textBox1.Text, Name, false);
                }
                Name = textBox1.Text;
            }
        }
Exemple #15
0
        public override string CodeOutput(int level)
        {
            string CodeOutput    = "";
            string childcontrol  = this.statementBlock1.CodeOutput(level, true);
            string childcontrol2 = this.statementBlock2.CodeOutput(level, true);
            string levelString   = new string('\t', level);

            Dictionary <string, string> TypeDictionary = Util.GetVariableType(this);
            string value;

            if (comboBox1.SelectedIndex == 0)
            {
                List <string> vList = Util.GetVariableList(this, 0);
                if (comboBox2.SelectedIndex == -1)
                {
                    Form1.MessageBoxValue("条件の変数又は定数が入力されていません", true);
                }
                else if (comboBox3.SelectedIndex == -1)
                {
                    Form1.MessageBoxValue("条件が正しくありません", true);
                }
                else if (vList.Contains(comboBox1.Text))
                {
                    Form1.MessageBoxValue("未宣言の変数が使われています", true);
                }
                else
                {
                    if (checkBox1.Checked)
                    {
                        CheckLetters.CheckVariables(comboBox2.Text, comboBox4.Text, TypeDictionary, true);
                        if (TypeDictionary[comboBox2.Text] == "char")
                        {
                            value = "\'" + comboBox4.Text + "\'";
                        }
                        else if (TypeDictionary[comboBox2.Text] == "string")
                        {
                            value = "\"" + comboBox4.Text + "\"";
                        }
                        else
                        {
                            value = comboBox4.Text;
                        }
                    }
                    else
                    {
                        if (Util.VariableConfirmation(this).Contains(comboBox2.Text) == false || Util.VariableConfirmation(this).Contains(comboBox4.Text) == false)
                        {
                            Form1.MessageBoxValue("条件で使われている変数は未割当です", true);
                        }
                        if (string.IsNullOrWhiteSpace(comboBox4.Text) == true)
                        {
                            Form1.MessageBoxValue("条件の変数が入力されていません", true);
                        }
                        else
                        {
                            CheckLetters.CheckVariablesAndVariables(comboBox2.Text, comboBox4.Text, TypeDictionary, true);
                        }
                        value = comboBox4.Text;
                    }

                    if (checkBox2.Checked)
                    {
                        CodeOutput = levelString + "if(" + comboBox2.Text + ConditionsType + value + ")\r\n" + childcontrol + levelString + "else\r\n" + childcontrol2;
                    }
                    else
                    {
                        CodeOutput = levelString + "if(" + comboBox2.Text + ConditionsType + value + ")\r\n" + childcontrol;
                    }
                }
            }
            else if (comboBox1.SelectedIndex == 1)
            {
                if (comboBox2.SelectedIndex == -1)
                {
                    Form1.MessageBoxValue("変数が入力されていません", true);
                }
                else
                {
                    if (Util.VariableConfirmation(this).Contains(comboBox2.Text) == false)
                    {
                        Form1.MessageBoxValue("条件で使われている変数は未割当です", true);
                    }
                    CodeOutput = levelString + "switch(" + comboBox2.Text + ")\r\n" + childcontrol;
                }
            }


            return(CodeOutput);
        }
        public static void CheckValue(string type, string Value, bool Type2)
        {
            switch (type)
            {
            case "int":
                int a;
                if (int.TryParse(Value, out a))
                {
                }
                else
                {
                    Form1.MessageBoxValue("入力が不正です", Type2);
                }
                break;

            case "double":
                double a2;
                if (double.TryParse(Value, out a2))
                {
                }
                else
                {
                    Form1.MessageBoxValue("入力が不正です", Type2);
                }
                break;

            case "string":
                break;

            case "bool":
                if (Value.Length >= 5)
                {
                    if (Value == "true" || Value == "false")
                    {
                    }
                    else
                    {
                        Form1.MessageBoxValue("入力が不正です", Type2);
                    }
                }

                break;

            case "char":
                bool aa = Regex.IsMatch(Value, "[0-1a-zA-Z]?");
                if (aa == false)
                {
                    Form1.MessageBoxValue("入力が不正、又は対応していません", Type2);
                }
                break;

            case "byte":
                byte aiii;
                if (byte.TryParse(Value, out aiii))
                {
                }
                else
                {
                    Form1.MessageBoxValue("入力が不正です", Type2);
                }
                break;
            }
            if (String.IsNullOrWhiteSpace(Value) && Type2)
            {
                Form1.MessageBoxValue("文字が入力されていないかスペースのみになっています。", Type2);
            }
        }
        public override string CodeOutput(int level)
        {
            string Code        = "";
            string levelString = new string('\t', level);
            Dictionary <string, string> CheckDic = Util.GetVariableType(this);

            if (comboBox1.SelectedIndex != -1)
            {
                List <string> vList = Util.GetVariableList(this, 0);
                if (comboBox2.SelectedIndex != -1)
                {
                    if (vList.Contains(comboBox1.Text) && vList.Contains(comboBox2.Text))
                    {
                        if (CheckDic[comboBox1.Text] == CheckDic[comboBox2.Text])
                        {
                            if (Util.VariableConfirmation(this).Contains(comboBox2.Text) == false)
                            {
                                Form1.MessageBoxValue("条件で使われている変数は未割当です", true);
                            }
                            Code = levelString + comboBox1.Text + " = " + comboBox2.Text + ";\r\n";
                        }
                        else
                        {
                            Form1.MessageBoxValue("型が異なります", true);
                        }
                    }
                    else
                    {
                        Form1.MessageBoxValue("未宣言の変数が使われています", true);
                    }
                }
                else
                {
                    if (checkBox1.Checked)
                    {
                        if (vList.Contains(comboBox1.Text))
                        {
                            if (CheckDic[comboBox1.Text] == "string")
                            {
                                Code = levelString + comboBox1.Text + " = \"" + comboBox2.Text + "\";\r\n";
                            }
                            else if (CheckDic[comboBox1.Text] == "char")
                            {
                                Code = levelString + comboBox1.Text + " = \'" + comboBox2.Text + "\';\r\n";
                            }
                            else
                            {
                                Code = levelString + comboBox1.Text + " = " + comboBox2.Text + ";\r\n";
                            }
                        }
                        else
                        {
                            Form1.MessageBoxValue("未宣言の変数が使われています", true);
                        }
                    }
                    else
                    {
                        Form1.MessageBoxValue("型が異なります", true);
                    }
                }
            }
            else
            {
                Form1.MessageBoxValue("代入される変数が入力されていません", true);
            }
            return(Code);
        }
        public override string CodeOutput(int level)
        {
            List <string> vlist = Util.GetVariableList(this, 0);

            if (checkBox1.Checked)
            {
                if (vlist.Contains(comboBox1.Text) && vlist.Contains(comboBox2.Text) && vlist.Contains(comboBox3.Text))
                {
                }
            }
            else
            {
                if (vlist.Contains(comboBox1.Text) && vlist.Contains(comboBox2.Text))
                {
                }
            }
            string        levelString = new string('\t', level);
            string        Code        = "";
            List <string> Vlist       = Util.GetVariableList(this, 0);

            if (comboBox1.SelectedIndex != -1)
            {
                if (comboBox2.SelectedIndex != -1)
                {
                    if (checkBox1.Checked)
                    {
                        if (comboBox3.SelectedIndex != -1)
                        {
                            if (Vlist.Contains(comboBox1.Text) && Vlist.Contains(comboBox2.Text) && Vlist.Contains(comboBox3.Text))
                            {
                                Code = levelString + comboBox3.Text + " = " + Type + ".TryParse(" + comboBox1.Text + ".ToString() " + ",out " + comboBox2 + ";";
                                if (Util.VariableConfirmation(this).Contains(comboBox1.Text) == false)
                                {
                                    Form1.MessageBoxValue("型の変換で未割当の変数が使われています", true);
                                }
                            }
                            else
                            {
                                Form1.MessageBoxValue("未宣言の変数が使われています", true);
                            }
                        }
                        else
                        {
                            Form1.MessageBoxValue("bool型に変換結果を送る変数が選択されていません", true);
                        }
                    }
                    else
                    {
                        Code = levelString + Type + ".TryParse(" + comboBox1.Text + ".ToString()" + ",out " + comboBox2.Text + ");\r\n";
                    }
                }
                else
                {
                    Form1.MessageBoxValue("変数が選択されていません", true);
                }
            }
            else
            {
                Form1.MessageBoxValue("変数が選択されていません", true);
            }
            return(Code);
        }
        public override string CodeOutput(int level)
        {
            string Quotation = "";


            String levelString = new string('\t', level);

            CheckLetters.CheckName(textBox1.Text, true);
            if (NameList.Contains(textBox1.Text))
            {
                Form1.MessageBoxValue("同じ名前の変数が既にあります", true);
            }
            else
            {
                NameList.Add(textBox1.Text);
                if (string.IsNullOrWhiteSpace(textBox1.Text))
                {
                    Form1.MessageBoxValue("変数の名前が入力されていません", true);
                }
            }
            switch (comboBox1.SelectedIndex)
            {
            case -1:
                Form1.MessageBoxValue("変数の型が選択されていません", true);
                break;

            case 0:
                itemType = "int";
                break;

            case 1:
                itemType = "string";
                break;

            case 2:
                itemType = "char";
                break;

            case 3:
                itemType = "double";
                break;

            case 4:
                itemType = "byte";
                break;

            case 5:
                itemType = "bool";
                break;
            }
            if (checkBox1.Checked == true)
            {
                if (String.IsNullOrWhiteSpace(textBox2.Text) == false)
                {
                    if (itemType == "char")
                    {
                        char a;
                        if (char.TryParse(textBox2.Text, out a))
                        {
                            Quotation = "\'";
                        }
                        else
                        {
                            Form1.MessageBoxValue("型にあっていません", true);
                        }
                        if (string.IsNullOrWhiteSpace(textBox1.Text))
                        {
                            Form1.MessageBoxValue("入力されていないところがあります", true);
                        }
                    }
                    else if (itemType == "string")
                    {
                        Quotation = "\"";
                    }
                    CheckLetters.CheckValue(itemType, textBox2.Text, true);
                    return(levelString + itemType + " " + this.textBox1.Text + " = " + Quotation + textBox2.Text + Quotation + ";\r\n");
                }
                else
                {
                    if (itemType != "string")
                    {
                        Form1.MessageBoxValue("変数に代入する値が入力されていません", true);
                    }
                    else
                    {
                        return(levelString + itemType + " " + this.textBox1.Text + " = " + "\"\"" + ";\r\n");
                    }
                }
            }


            return(levelString + itemType + " " + this.textBox1.Text + ";\r\n");
        }
Exemple #20
0
        public override string CodeOutput(int level)
        {
            string Code = "";
            string Output;
            string levelString = new string('\t', level);

            if (checkBox1.Checked)
            {
                Output = "Console.Write";
            }
            else
            {
                Output = "Console.WriteLine";
            }
            for (int i = 0; i < OutputOrder.Count; i++)
            {
                AddOutputObject Me = OutputOrder[i];
                if (Me.radioButton1.Checked)
                {
                    if (i == 0)
                    {
                        Code = Code + "\"" + Me.comboBox1.Text + "\"";
                    }
                    else
                    {
                        Code = Code + "+\"" + Me.comboBox1.Text + "\"";
                    }
                }
                else
                {
                    List <string> vList = Util.GetVariableList(this, 0);

                    if (vList.Contains(Me.comboBox1.Text) == false)
                    {
                        Form1.MessageBoxValue("未宣言の変数が使われています", true);
                    }

                    if (Me.comboBox1.SelectedIndex != -1)
                    {
                        if (i == 0)
                        {
                            Code = Code + Me.comboBox1.Text;
                        }
                        else
                        {
                            Code = Code + "+" + Me.comboBox1.Text;
                        }
                        List <string> name = Util.VariableConfirmation(this);
                        if (name.Contains(Me.comboBox1.Text) == false)
                        {
                            Form1.MessageBoxValue("コンソールに表示する変数に値が入力されていません", true);
                        }
                    }
                    else
                    {
                        Form1.MessageBoxValue("変数が設定されていません", true);
                    }
                }
            }
            return(levelString + Output + "(" + Code + ");\r\n");;
        }
Exemple #21
0
        public override string CodeOutput(int level)
        {
            string        levelString = new string('\t', level);
            string        Code        = levelString;
            List <string> vList       = Util.GetVariableList(this, 1);

            if (comboBox1.SelectedIndex != -1)
            {
                Code = Code + comboBox1.Text;
                if (checkBox1.Checked)
                {
                    if (string.IsNullOrWhiteSpace(comboBox2.Text))
                    {
                        Form1.MessageBoxValue("計算するときの数が選択されていません", true);
                    }
                    else
                    {
                        Code = Code + " = " + comboBox2.Text;
                    }
                }
                else
                {
                    if (vList.Contains(comboBox2.Text))
                    {
                        if (comboBox2.SelectedIndex != -1)
                        {
                            if (Util.VariableConfirmation(this).Contains(comboBox2.Text) == false)
                            {
                                Form1.MessageBoxValue("計算で未割当の変数が使われています", true);
                            }
                            Code = Code + " = " + comboBox2.Text;
                        }
                        else
                        {
                            Form1.MessageBoxValue("計算するときの変数が選択されていません", true);
                        }
                    }
                    else
                    {
                        Form1.MessageBoxValue("未宣言の変数が使われています", true);
                    }
                }

                if (checkBox2.Checked)
                {
                    if (string.IsNullOrWhiteSpace(comboBox4.Text))
                    {
                        Form1.MessageBoxValue("計算するときの数が選択されていません", true);
                    }
                    else
                    {
                        if (comboBox3.SelectedIndex != -1)
                        {
                            Code = Code + " " + CalculationType + " " + comboBox4.Text + ";\r\n";
                        }
                    }
                }
                else
                {
                    if (vList.Contains(comboBox4.Text))
                    {
                        if (comboBox4.SelectedIndex != -1)
                        {
                            if (comboBox3.SelectedIndex != -1)
                            {
                                if (Util.VariableConfirmation(this).Contains(comboBox4.Text) == false)
                                {
                                    Form1.MessageBoxValue("計算で未割当の変数が使われています", true);
                                }

                                Code = Code + " " + CalculationType + " " + comboBox4.Text + ";\r\n";
                            }
                        }
                        else
                        {
                            Form1.MessageBoxValue("計算するときの変数が選択されていません", true);
                        }
                    }
                    else
                    {
                        Form1.MessageBoxValue("未宣言の変数が使われています", true);
                    }
                }
            }
            else
            {
                Form1.MessageBoxValue("計算するときの数が選択されていません", true);
            }

            Dictionary <string, string> typeDic = Util.GetVariableType(this);

            if (checkBox1.Checked == false)
            {
                if (checkBox2.Checked == false)
                {
                    if (typeDic[comboBox1.Text] == typeDic[comboBox2.Text] && typeDic[comboBox1.Text] == typeDic[comboBox4.Text])
                    {
                    }
                    else
                    {
                        Form1.MessageBoxValue("型が異なります", true);
                    }
                }
                else
                {
                    if (typeDic[comboBox1.Text] == typeDic[comboBox2.Text])
                    {
                    }
                    else
                    {
                        Form1.MessageBoxValue("型が異なります", true);
                    }
                }
            }
            else
            {
                if (typeDic[comboBox1.Text] == typeDic[comboBox4.Text])
                {
                }
                else
                {
                    Form1.MessageBoxValue("型が異なります", true);
                }
            }


            return(Code);
        }
Exemple #22
0
        public override string CodeOutput(int level)
        {
            string levelString  = new string('\t', level);
            string childcontrol = this.statementBlock1.CodeOutput(level, true);
            string Code         = "";
            string Quotation    = "";

            if (comboBox1.SelectedIndex != -1)
            {
                List <string> vlist = Util.GetVariableList(this, 0);

                if (UseLoopType == "while" || UseLoopType == "do-while")
                {
                    if (ConditionsType != "")
                    {
                        if (comboBox2.SelectedIndex != -1)
                        {
                            if (checkBox2.Checked)
                            {
                                if (UseLoopType == "while")
                                {
                                    if (vlist.Contains(comboBox4.Text) == false)
                                    {
                                        CheckLetters.CheckVariables(comboBox2.Text, comboBox4.Text, Util.GetVariableType(this), true);
                                        if (Util.GetVariableType(this)[comboBox2.Text] == "char")
                                        {
                                            Quotation = "\'";
                                        }
                                        else if (Util.GetVariableType(this)[comboBox2.Text] == "string")
                                        {
                                            Quotation = "\"";
                                        }
                                    }
                                    else
                                    {
                                        Form1.MessageBoxValue("未宣言の変数が使われています", true);
                                    }

                                    Code = levelString + "while" + "(" + comboBox2.Text + " " + ConditionsType + Quotation + comboBox4.Text + Quotation + ")" + "\r\n" + childcontrol;
                                }
                                else
                                {
                                    if (vlist.Contains(comboBox2.Text) == false)
                                    {
                                        if (Util.GetVariableType(this)[comboBox2.Text] == "char")
                                        {
                                            Quotation = "\'";
                                        }
                                        else if (Util.GetVariableType(this)[comboBox2.Text] == "string")
                                        {
                                            Quotation = "\"";
                                        }
                                        CheckLetters.CheckVariables(comboBox2.Text, comboBox4.Text, Util.GetVariableType(this), true);
                                    }
                                    else
                                    {
                                        Form1.MessageBoxValue("未宣言の変数が使われています", true);
                                    }

                                    Code = levelString + "do\r\n" + childcontrol + levelString + "while(" + comboBox2.Text + " " + ConditionsType + " " + Quotation + comboBox4.Text + Quotation + ")\r\n";
                                }
                            }
                            else
                            {
                                if (Util.VariableConfirmation(this).Contains(comboBox2.Text) == false || Util.VariableConfirmation(this).Contains(comboBox4.Text) == false)
                                {
                                    Form1.MessageBoxValue("ループで未割当の変数が使われています", true);
                                }

                                CheckLetters.CheckVariablesAndVariables(comboBox2.Text, comboBox4.Text, Util.GetVariableType(this), true);
                                Code = levelString + UseLoopType + "(" + comboBox2.Text + " " + ConditionsType + " " + comboBox4.Text + ")" + "\r\n" + childcontrol;
                            }
                        }
                        else
                        {
                            Form1.MessageBoxValue("条件の一部が入力されていません", true);
                        }
                    }
                    else
                    {
                        Form1.MessageBoxValue("条件が選択されていません", true);
                    }
                }
                else if (UseLoopType == "for")
                {
                    if (checkBox1.Checked == false)
                    {
                        int value;
                        if (int.TryParse(textBox1.Text, out value))
                        {
                            int     i         = 1;
                            Control MyGparent = this.Parent.Parent;

                            while (MyGparent.GetType() == (typeof(Loop)))
                            {
                                i++;
                                MyGparent = MyGparent.Parent.Parent;
                            }
                            string forNumber = new string ('i', i);
                            Code = levelString + UseLoopType + "(int " + forNumber + "= 0;" + forNumber + " < " + textBox1.Text + ";" + forNumber + "++)\r\n" + childcontrol;
                        }
                    }
                    else
                    {
                        Code = levelString + "for(;;)\r\n" + childcontrol;
                    }
                }
            }
            else
            {
                Form1.MessageBoxValue("ループの種類が選択されていません", true);
            }


            return(Code);
        }