How to set ini value with INI Config

17 ビュー (過去 30 日間)
Michael Critchfield
Michael Critchfield 2018 年 11 月 22 日
編集済み: Michael Critchfield 2018 年 11 月 23 日
Hi,
I am using INI Config to read from and write to a custom .ini-file. The reading works perfectly, I use the GetValues-Function for that.
However, I cannot get the SetValues-Function to work. I do not get an Error but the value in my .ini-file does not change either.
[~] = ini.SetValues('Category','SettingA','Teststring');
Nothing happens. Does anybody know what I am doing wrong here?
Thanks in advance!
  4 件のコメント
Geoff Hayes
Geoff Hayes 2018 年 11 月 22 日
MIchael - could you paste the code that you have written that creates the ini file (with default settings) and then the code that updates the file (which "corrupts" it).
Michael Critchfield
Michael Critchfield 2018 年 11 月 22 日
編集済み: Michael Critchfield 2018 年 11 月 23 日
Hi Goeff,
Thanks for getting back to me on this.
I did not use code to create my ini file, I typed it manually.
Reading the settings works fine.
Thanks to your advice, writing works fine now too, except the missing linebreaks.
I use the following lines to update a setting in my ini file:
ini = IniConfig();
[~] = ini.ReadFile('mysettings.ini');
SettingA = string(ini.GetValues('Category','SettingA'));
% ...
SettingA = 'Teststring';
[~] = ini.SetValues('Category','SettingA',SettingA);
[~] = ini.WriteFile('mysettings.ini');
clear ini;

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

製品


リリース

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by