2012-07-02 160 views
-1

我有我想知道如果我可以從這個givein信息得到一個值的INI文件搜索值獲取從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 ,我想找到的圖片## [值]凡我所知道的是X ## [值]和y ## [值]

所以說,我知道我的值是(8,6),現在我想獲取Lava.bmp圖像返回。注8是x座標,6是座標。

不知道IAM解釋這一權利,但如果沒有,請索要更多信息

當前代碼

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 
+0

這就是我所想象的,但hopeing有辦法。 –

回答

3
function GetBitmap(Ini: TCustomIniFile; X, Y: Integer): String; 
begin 
    Result := Ini.ReadString('Images', Format('image%d%d', [X, Y]), ''); 
end; 
+0

不知道這是如何工作的,但生病給功能的嘗試,只要我回家。 –

+0

它的工作原理,如:搜索'=''標誌「的'前imageXY''」,並返回什麼之後。這是相當默認的ini運作。 – NGLN

+0

哈哈,我因此未注意到XY是「形象」後的數字:d感謝 –