INI files handling exists BUG
Posted: Sat Mar 24, 2018 1:39 am
<r>经过测试,我发现,在读取INI 文件时,在HMG3.4.4版中仍存在BUG,我以前曾经反映过,经过Pablo César的修改后并下发了补丁http://www.hmgforum.com/viewtopic.php?f=43&t=4 ... ini#p47988 ,好像在HMG3.4.4中并未得到修正。我一直使用Pablo César提供的补丁。近日我又发现,当ENTRY为汉字时,无法读取到SECTION下的键值。 <br/>
<br/>
After testing, I found that bugs still exist in the hmg3.4.4 version when I read the ini file, which I have reflected before, modified by Pablo César and patched. I have been using the patch provided by Pablo César. Recently, I found that when entry is Chinese character, I can not read the key value under section. <br/>
<CODE><s>
<br/>
After testing, I found that bugs still exist in the hmg3.4.4 version when I read the ini file, which I have reflected before, modified by Pablo César and patched. I have been using the patch provided by Pablo César. Recently, I found that when entry is Chinese character, I can not read the key value under section. <br/>
<CODE><s>
Code: Select all
</s><i>
</i>#include <hmg.ch>
FUNCTION main()
LOCAL cIniFile := GetStartupFolder() + '\demo.ini'
LOCAL aRet
If !File(cIniFile)
SetIniValue(cIniFile)
Endif
*msgdebug( HMG_GetPrivateProfileSection ( cIniFile, "HMG" ) )
aRet := GetValue(cIniFile)
AEVAL( aRet, { |x| MsgDebug( x, ValType(x) ) } )
RETURN NIL
PROCEDURE SetIniValue( cIni )
BEGIN INI FILE cIni
SET SECTION 'HMG' ENTRY '版本' TO 3.43
SET SECTION 'HMG' ENTRY 'DESCRIBE_1' TO "我非常喜欢HMG!"
SET SECTION 'HMG' ENTRY 'DESCRIBE_2' TO "I LIKE HMG VERY MUCH!"
SET SECTION 'HMG1' ENTRY 'DESCRIBE_3' TO {"1",2,.T.}
SET SECTION 'HMG1' ENTRY 'DESCRIBE_4' TO Date()
SET SECTION 'HMG1' ENTRY 'DESCRIBE_5' TO Nil
SET SECTION 'HMG1' ENTRY 'DESCRIBE_6' TO .F.
END INI
RETURN
FUNCTION GetValue( cIni )
LOCAL cDescrib_1:="", cDescrib_2:="", cDescrib_3:={}
LOCAL cDescrib_4:=Date(), cDescrib_5:=Nil, cDescrib_6:=.F., nVers:=0
BEGIN INI FILE (cIni)
// _GetIni( cSection, cEntry, cDefault, uVar )
// cDescrib_1 := _GetIni( "HMG", "DESCRIBE_1",, cDescrib_1 )
GET cDescrib_1 SECTION 'HMG' ENTRY 'DESCRIBE_1' DEFAULT '' //display "我非常" in 3.4.4 version ,the read value is incomplete and there is a bug ,However, using the patch provided by Pablo César, the display is normal
GET cDescrib_2 SECTION 'HMG' ENTRY 'DESCRIBE_2' DEFAULT ''
GET nVers SECTION 'HMG' ENTRY '版本' DEFAULT 3.43 //ok in hmg3.4.4 version ,But the patch provided by the Pablo César is unreadable and displays a blank
GET cDescrib_3 SECTION 'HMG1' ENTRY 'DESCRIBE_3' DEFAULT {}
GET cDescrib_4 SECTION 'HMG1' ENTRY 'DESCRIBE_4' DEFAULT Date()
GET cDescrib_5 SECTION 'HMG1' ENTRY 'DESCRIBE_5' DEFAULT Nil
GET cDescrib_6 SECTION 'HMG1' ENTRY 'DESCRIBE_6' DEFAULT .F.
END INI
RETURN {cDescrib_1, cDescrib_2, nVers, cDescrib_3, cDescrib_4, cDescrib_5, cDescrib_6}
<e>