本帖最后由 dunphy 于 2014-11-5 03:02 编辑
回复 4# abcd1234
举个批例子也不说清楚。
给你段代码,你看是不是这个意思。若字段里的BB值为1连续出现2个。则BB的值+1, ,再接着判断字段里BB值为2的情况,若有2个,BB值再加1 .是不是这个意思。。
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Array.au3>
Global Const $gc_formName = "配置文件"
Global $ini = @ScriptDir & "\*.ini"
Global $a_PznameA = "aa", $a_PznameB = "bb"
#Region
Global $gu_PzForm = GUICreate($gc_formName, 402, 288, 340, 128)
Global $gu_PzGroup1 = GUICtrlCreateGroup("[1]配置文件", 13, 6, 374, 60)
Global $gu_PzInput1 = GUICtrlCreateInput("", 25, 32, 260, 21)
GUICtrlSetData($gu_PzInput1, $ini)
Global $gu_PzButton1 = GUICtrlCreateButton("随机写入(O)", 288, 30, 86, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $gu_PzButton2 = GUICtrlCreateButton("关于(A)", 13, 250, 59, 25)
Global $gu_PzButton3 = GUICtrlCreateButton("输出", 264, 250, 59, 25)
Global $gu_PzButton4 = GUICtrlCreateButton("退出(X)", 328, 250, 59, 25)
GUISetState(@SW_SHOW)
#EndRegion
_Main() ;主函数开始
Exit
Func _Main()
Local $nMsg
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $gu_PzButton1
Local $path = FileSaveDialog("配置文件存储位置", _
@ScriptDir, "配置文件.ini (*.ini)|所有文件(*.*)", 1 + 8, _
"*.ini", $gu_PzForm)
If @error Then
MsgBox(16, "提示", "你未选择INI文件.")
Else
If FileExists( $path) = 1 Then FileDelete( $path)
Local $a_SectionName[5001]
Local $i, $b = UBound($a_SectionName)
For $i = 1 To $b - 1 Step 1
;;$a_SectionName[0] = UBound($a_SectionName) - 1
$a_SectionName[$i] = "a" & $i
IniWrite( $path, $a_SectionName[$i], $a_PznameA, 123)
IniWrite( $path, $a_SectionName[$i], $a_PznameB, 1)
Next
GUICtrlSetData($gu_PzInput1, $path)
MsgBox(0, "提示:", "成功写入配置文件" & @CRLF & "请在当前程序目录查看")
EndIf
Case $gu_PzButton3
Local $path = GUICtrlRead($gu_PzInput1)
Global $sSection = IniReadSectionNames( $path)
;; _ArrayDisplay($sSection, "$sSection")
If @error Then
MsgBox(0, "提示", "请先创建后再输出查看")
ExitLoop
EndIf
Global $ArraySecName[5001][5]
For $i = 1 To UBound($ArraySecName) - 1
Local $pz_array = IniReadSection( $path, $sSection[$i])
$ArraySecName[0][0] = "字段名"
$ArraySecName[0][1] = "第一关键字"
$ArraySecName[0][2] = "第一关键字的值"
$ArraySecName[0][3] = "第二关键字"
$ArraySecName[0][4] = "第二关键字的值"
$ArraySecName[$i][0] = $sSection[$i]
$ArraySecName[$i][1] = $pz_array[1][0]
$ArraySecName[$i][2] = $pz_array[1][1]
$ArraySecName[$i][3] = $pz_array[2][0]
$ArraySecName[$i][4] = $pz_array[2][1]
;If $ArraySecName[$I][4] = 1 Then
;MsgBox (0,"提示","字段"& $sSection[$I]&"中关健字bb值为1")
;EndIf
Next
_ArrayDisplay($ArraySecName, "$Array")
;;_Exists() ;如果连续二个的BB值为1,则数组中追加一字段
Case $gu_PzButton2
MsgBox(0 + 64, $gc_formName, "作者:#####")
Case $gu_PzButton4
Exit
EndSwitch
WEnd
EndFunc ;==>_main
|