本帖最后由 cashiba 于 2016-11-3 18:34 编辑 Local $File=@ScriptDir & "\idx.ini"
local $Farr[3]=["F1","F2","F3"] ;字段名集合
Local $Seca[2][2] = [["K1", "T1"], ["K2", "T2"]] ;字段F1的内容
Local $Secb[3][2] = [["K3", "T3"], ["K4", "T4"],["K5", "T5"]] ;字段F2的内容
Local $Secc[4][2] = [["K6", "T6"], ["K7", "T7"],["K8", "T8"],["K9", "T9"]] ;字段F3的内容
Local $Sarr[3]=[$Seca,$Secb,$Secc] ;以上三字段内容集合
WritIniAll($File,$Farr,$Sarr)
Func WritIniAll($File,$Farr,$Sarr)
for $i=0 to UBound($Farr)-1
If @error Then
ConsoleWrite("写入INI文件失败." & @CRLF)
Else
IniWriteSection($File, $Farr[$i],$Sarr[$i],0)
If @error Then ConsoleWrite("写入INI字段失败." & @CRLF)
EndIf
next
EndFunc
ReadIniAll($File)
Func ReadIniAll($File)
Local $Farr= IniReadSectionNames($File)
for $i=1 to $Farr[0]
local $KTar= IniReadSection($File, $Farr[$i])
If @error Then
ConsoleWrite("读取INI文件失败." & @CRLF)
Else
ConsoleWrite("[" & $Farr[$i] & "]" & @CRLF)
For $j = 1 To $KTar[0][0]
ConsoleWrite($KTar[$j][0] & " = " & $KTar[$j][1] & @CRLF)
Next
EndIf
next
EndFunc
|