コード例 #1
0
 public ShowFieldItem(
     ZeroRowCol RowCol, byte?AttrByte, ShowUsage Usage, ShowDtyp Dtyp, int Dlen)
     : base(RowCol, ShowItemType.Field, AttrByte)
 {
     this.Usage = Usage;
     this.Dtyp  = Dtyp;
     this.Dlen  = Dlen;
     this.Value = "";
 }
コード例 #2
0
        Tuple <ShowDtyp, int, int, string> ParseDataDefn(string Text)
        {
            ShowDtyp dtyp   = ShowDtyp.Char;
            int      dlen   = 0;
            int      dprc   = 0;
            string   delim  = null;
            string   errmsg = null;

            int ix = 0;

            // text up to the "(" is data type.
            int fx = Text.IndexOf('(', ix);
            int lx = fx - ix;

            if ((ix == -1) || (lx == 0))
            {
                errmsg = "Data defn bad form. " + Text;
            }
            if (errmsg == null)
            {
                var chDtyp = Text.Substring(ix, lx).Trim();
                var rv     = ShowDtypExt.TryParse(chDtyp);
                if (rv == null)
                {
                    errmsg = "Invalid data type. " + chDtyp;
                }
                else
                {
                    dtyp = rv.Value;
                    ix   = fx + 1;
                }
            }

            // data length until "," or close paren.
            if (errmsg == null)
            {
                if (ix >= Text.Length)
                {
                    fx = -1;
                }
                else
                {
                    fx = Text.IndexOfAny(new char[] { ',', ')' }, ix);
                    lx = fx - ix;
                }
                if ((fx == -1) || (lx == 0))
                {
                    errmsg = "length part of data defn missing. " + Text;
                }
                else
                {
                    delim = Text.Substring(fx, 1);
                    var rv = Text.Substring(ix, lx).TryParseInt32();
                    if (rv == null)
                    {
                        errmsg = "length part of data defn not numeric. " + Text;
                    }
                    else
                    {
                        dlen = rv.Value;
                        ix   = fx + 1;
                    }
                }
            }

            // decimal precision
            if ((errmsg == null) && (delim != null) && (delim == ","))
            {
                if (ix >= Text.Length)
                {
                    fx = -1;
                }
                else
                {
                    fx = Text.IndexOf(')', ix);
                }
                lx = fx - ix;
                if ((fx == -1) || (lx == 0))
                {
                    errmsg = "decimal precision part of data defn missing. " + Text;
                }
                else
                {
                    delim = Text.Substring(fx, 1);
                    var rv = Text.Substring(ix, lx).TryParseInt32();
                    if (rv == null)
                    {
                        errmsg = "decimal precision part of data defn not numeric. " + Text;
                    }
                    else
                    {
                        dprc = rv.Value;
                        ix   = fx + 1;
                    }
                }
            }

            return(new Tuple <ShowDtyp, int, int, string>(dtyp, dlen, dprc, errmsg));
        }