douti0467 2018-08-09 13:08
浏览 244

在.ini配置文件中使用“include”

I need your help. I have two .ini-files with similar keys and values. I want them to be synchronized but more like merged.

There will be change on both sides of those .ini-files so we can't create a synchronisation cause we won't overwrite the other side. Everything should be merged/synchronized automatically, while we change content on both ini-files!

The goal is always to change a ini-file in our headquarter and merge/sync it with a file on our cash desk.

Example which cannot work:

ini-file1.ini, is on a cash desk and gets changed several times a day by the cash desk!

ini-file2.ini, is a dublicate of ini-file1.ini in our headquarter. We wanna be able to chnage ini-file2.ini during a change on the cash desk.

The cash desk changed the receiptnumber in ini-file1.ini and we (headquarter) changed key2 in ini-file2.ini:

ini-file1.ini:

key1 = 1;
key2 = 2;
receiptnumber: 122

ini-file2.ini:

key1 = 1;
key2 = 4;
receiptnumber: 118

And now we establish a synchronisation/merge between ini-file1.ini and ini-file2.ini.

A merge-application cannot know which of those keys is the proper key and which one to discard and overwrite.

Actually we thought we could investigate in a "insert/include" in one of those ini-files and outsource everything that comes from our second ini-file. So we got a object orieted ini-file. (My "ini-file oop concept")

Should mean:

ini-file1.ini, is on a cash desk and gets changed several times a day by the cash desk!

ini-file-outsource.ini, is just a part of the cash desk config file. We want it like attached to ini-file1.ini through a line like insert "C:\ini-file-outsource.ini"; which doesn't exist, but we need something similar. It is everything which handles settings in the cashdesk, so this file is not changed by the cash desk. It's on the cash desk.

ini-file2.ini, is a dublicate of ini-file-outsource.ini. It's in our headquarter and used to change settings for the cash desk.

ini-file1.ini:

key1 = 1;
key2 = 2;
receiptnumber: 122
insert "C:\ini-file-outsource.ini";

ini-file-outsource.ini:

key3 = 3;
key4 = 4;
key5 = 8;

ini-file2.ini:

key3 = 3;
key4 = 4;
key5 = 8;

This time we establish a synchronisation between ini-file2.ini and ini-file-outsource.ini.

This should work if it's possible to achieve cause we change only different content on every side. Every key will be unique.

If you have any better approach I'm open for everything.

Thanks for your help

  • 写回答

1条回答 默认 最新

  • dongluoqiu0255 2019-04-20 19:38
    关注

    You can use something like:

    ini=%d/../anotherFile.ini:section
    

    Where %d is current file directory and :section refers to specific section to include

    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决