【问题标题】:Get searching value from INI file从 INI 文件中获取搜索值
【发布时间】:2012-07-02 01:56:23
【问题描述】:

我有一个 INI 文件,我想知道是否可以从这个给定信息中获取价值

我的 INI 看起来像这样

[Images]
image135=Lava.bmp
x135=13
y135=5
image76=Mountian.bmp
x76=7
y76=6
image86=Lava.bmp
x86=8
y86=6
image85=Lava.bmp
x85=8
y85=5
image125=gryph.bmp
x125=12
y125=5

现在我打开这个ini,我想找到图像##[value] 我只知道x##[value] 和y##[value]

假设我知道我的值是 (8,6) 现在我想获取返回的图像 Lava.bmp。注意 8 是 x 坐标,6 是 y 坐标。

不确定我是否正确地解释了这一点,但如果不是,请询问更多信息

当前代码

HexMapIni := TIniFile.Create(FGamePlay.MapName);  //creates ini file
eposition.x := FGameplay.TempCurrentPosition.x;  //x value to search ini for
eposition.y := FGamePlay.TempcurrentPosition.y;  //y value to search ini for
ImageYouWant := //Searchresult.bmp
Hexmap1.ImageAHex(ImageYouWant , bsSolid, eposition);  //place image on map

【问题讨论】:

  • 这是我的想法,但希望有办法。

标签: delphi delphi-xe2 ini


【解决方案1】:
function GetBitmap(Ini: TCustomIniFile; X, Y: Integer): String;
begin
  Result := Ini.ReadString('Images', Format('image%d%d', [X, Y]), '');
end;

【讨论】:

  • 不确定它是如何工作的,但我一回到家就试试这个功能。
  • 它的工作原理是:在'=' 符号前面搜索'imageXY',然后返回后面的内容。这是非常默认的 ini 功能。
  • 哈哈,我没注意到 xy 是 'image' 后面的数字 :D 谢谢
  • @NGLN: 不错 - 我没有注意到 X/Y 也是“图像”之后的值。 +1。
猜你喜欢
  • 1970-01-01
  • 2014-02-20
  • 2017-09-16
  • 2013-06-19
  • 2022-01-21
  • 2016-07-17
  • 1970-01-01
  • 2013-08-02
  • 2012-06-29
相关资源
最近更新 更多