Beispiel #1
0
        //
        // Formats the abbreviation of the ion to include subscripts.
        //
        public static string formatabbr(string abbr)
        {
            string      subNum;
            SmallNumber uni = new SmallNumber();

            for (int x = 0; x < abbr.Length; x++)
            {
                for (int i = 0; i <= 9; i++)
                {
                    if (abbr[x].ToString() == i.ToString())
                    {
                        subNum = uni.convertToSubscript(i);
                        abbr   = abbr.Replace(abbr[x].ToString(), subNum);

                        // Adding parentheses avoids confusion between polyatomic ions and the number of polyatomic ions needed to create the compound.
                        if (x == abbr.Length - 1)
                        {
                            abbr = "(" + abbr + ")";
                        }
                    }
                }
            }

            return(abbr);
        }
Beispiel #2
0
        //
        // Converts the number of ions to a unicode subscript value.
        //
        public static string displayIonNumber(int n)
        {
            string      number;
            SmallNumber uni = new SmallNumber();

            if (n == 1)
            {
                number = "";
            }
            else
            {
                number = uni.convertToSubscript(n).ToString();
            }

            return(number);
        }