iniParser.Set C# (CSharp) Method

Set() public method

Set the variable and value if they dont exist. Updates the variables value if does exist.
public Set ( string subSection, string key, string value ) : void
subSection string The Section this key belongs to
key string The variable nameThe value of the variable
value string
return void
    public void Set(string subSection, string key, string value)
    {
        for(int i = 0; i < keys.Count; i++){
            if(keys[i].Equals(key)){
                vals[i] = value;
                subSections[i] = subSection;
                return;
            }
        }

        subSections.Add(subSection);
        keys.Add(key);
        vals.Add(value);
        comments.Add("");
    }

Same methods

iniParser::Set ( string subSection, string key, string value, string comment ) : void

Usage Example

    // Use this for initialization
    void Start()
    {
        if (mode == DisplayMode.Colors)
        {
            background = new Texture2D(1, 1);
            background.SetPixel(1, 1, colors.background);
            background.wrapMode = TextureWrapMode.Repeat;
            background.Apply();

            foreground = new Texture2D(1, 1);
            foreground.SetPixel(1, 1, colors.foreground);
            foreground.wrapMode = TextureWrapMode.Repeat;
            foreground.Apply();

            xpShadow = new Texture2D(1, 1);
            xpShadow.SetPixel(1, 1, colors.xpShadowIncrease);
            xpShadow.wrapMode = TextureWrapMode.Repeat;
            xpShadow.Apply();
        }
        else
        {
            background = textures.background;
            foreground = textures.foreground;
            xpShadow   = textures.xpShadowIncrease;
        }

        barwidth = Screen.width * screenPer;
        boxwidth = barwidth / 10;
        barstrt  = Screen.width * ((1.0f - screenPer) / 2);
        Debug.Log(barstrt + ":" + Screen.width);

        parser.Load(IniFiles.XP);
        if (parser.Get("XP").Equals(""))
        {
            parser.Set("", "XP", "0");

            float curxp = 0;

            for (int i = 0; i < 200; i++)
            {
                if (i != 0)
                {
                    curxp += 800 + (400 * (i - 1));
                }

                int cp = Mathf.CeilToInt(curxp);
                parser.Set("Ranks", "level-" + i, curxp.ToString());
            }
            curxp = 9999999;

            parser.Set("Ranks", "level-200", curxp.ToString());
            parser.Save(IniFiles.XP);
        }
        localxp = int.Parse(parser.Get("XP"));

        calc();
    }
All Usage Examples Of iniParser::Set