示例#1
0
        private object parse(string[] str)
        {
            switch (str[0])
            {
            case "println":
                return("\r\n");

            case "set":
                _oper.setVar(str[1], parse(ToolArray.sub <string>(str, 2)));
                break;

            case "get":
                return(_oper.getVar(str[1]));

            case "mult":
                return(_oper.mult(ToolArray.sub <string>(str, 1)));

            case "sum":
                return(_oper.sum(ToolArray.sub <string>(str, 1)));

            case "div":
                return(_oper.div(ToolArray.sub <string>(str, 1)));

            case "format":
                return(_oper.format(ToolArray.sub <string>(str, 1)));

            case "formatln":
                return(_oper.format(ToolArray.sub <string>(str, 1)) + "\r\n");

            case "toDouble":
                return(_oper.toDouble(str[1]));

            case "toInt32":
                return(_oper.toInt32(str[1]));

            case "toInt16":
                return(_oper.toInt16(str[1]));

            case "sys":
                return(_env.getSysSettings().getString(_oper.getVar(str[1]).ToString()));

            case "printch":
                return(_oper.printch(ToolArray.sub <string>(str, 1)));

            case "replace":
                return(_oper.replace(ToolArray.sub <string>(str, 1)));

            case "formatlistarr":
                return(_oper.formatlistarr(ToolArray.sub <string>(str, 1)));
            }
            if (str.Length == 1)
            {
                return(_oper.getVar(str[0]));
            }
            return(null);
        }
示例#2
0
        public string formatlistarr(string[] vars)
        {
            if (vars.Length < 3)
            {
                throw new MyException.MyExceptionError(MessageCollection.T_MSG_ERROR_INVALID_ARGS_COUNT);
            }

            StringBuilder sb = new StringBuilder();


            string format_ = getVar(vars[0]).ToString();
            string arr_    = getVar(vars[1]).ToString();

            if (!string.IsNullOrEmpty(arr_))
            {
                string join_ = getVar(vars[2]).ToString();

                string[] typesTmp_ = ToolArray.sub <string>(vars, 3);
                Type[]   types_    = new Type[typesTmp_.Length];

                for (int i = 0; i < types_.Length; ++i)
                {
                    types_[i] = ToolType.parse(typesTmp_[i]);
                }


                string[][] values_ = ToolString.explodeGroupList(arr_);


                for (int x = 0; x < values_.Length; ++x)
                {
                    string[] itms  = values_[x];
                    object[] data_ = new object[itms.Length];

                    for (int i = 0; i < data_.Length; ++i)
                    {
                        Type type_ = i < types_.Length ? types_[i] : ToolTypeSet.helper.tString;

                        data_[i] = PARSE(itms[i], type_);
                    }

                    sb.Append(string.Format(format_, data_));
                    if (x < values_.Length - 1)
                    {
                        sb.Append(join_);
                    }
                }
            }

            return(sb.ToString());
        }