Войти

Показать полную графическую версию : [решено] Загруза тольк определенных имен секций ini файла


eus_deus
22-09-2013, 14:55
Всем привет! Итак, рабочий пример
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 629, 478, 433, 177)
$Edit1 = GUICtrlCreateEdit("", 8, 8, 321, 361)
GUICtrlSetData(-1, "")
$Edit2 = GUICtrlCreateEdit("", 336, 8, 289, 361)
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("Read INI", 8, 416, 105, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_iniread()
EndSwitch
WEnd

Func _iniread()
$inifile=@ScriptDir& '\test.ini'
$sections=IniReadSectionNames($inifile)
$msg=''
For $i = 1 To $sections[0]
$msg &= $sections[$i] & @CRLF
GUICtrlSetData($Edit1, $msg)
Next
EndFunc

Ini файл в прикрепленных файлах. Задача - загрузка в Edit1 имен секций, но не всех, а в каждом случае своих:
-1. секции, содержащие v_ в имени
-2. секции только на кириллице
-3. другие секции на латинице, кроме тех, что содержат v_

eus_deus
22-09-2013, 15:32
Остался только второй вопрос - секции, содержащие кириллицу. Как их не включать в список?
По другим вопросам - решил так
Func _iniread()
$inifile=@ScriptDir& '\test.ini'
$sections=IniReadSectionNames($inifile)
$msg=''
For $i = 1 To $sections[0]
if $sections[$i]='Setting' Or StringInStr($sections[$i], 'v_' ) Then
ContinueLoop
EndIf
$msg &= $sections[$i] & @CRLF
GUICtrlSetData($Edit1, $msg)
Next
EndFunc
Это для третьего, для первого аналогично. Как всегда, через ж..., но работает))))

Creat0R
22-09-2013, 20:08
Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) _iniread()
$inifile = @ScriptDir (http://autoit-script.ru/autoit3_docs/macros.htm#@scriptdir) & '\test.ini'
$sections = IniReadSectionNames (http://autoit-script.ru/autoit3_docs/functions/IniReadSectionNames.htm)($inifile)
$msg = ''

For (http://www.autoitscript.com/autoit3/docs/keywords.htm#For) $i = 1 To (http://www.autoitscript.com/autoit3/docs/keywords.htm#To) $sections[0]
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $sections[$i] <> 'Setting' And (http://www.autoitscript.com/autoit3/docs/keywords.htm#And) Not (http://www.autoitscript.com/autoit3/docs/keywords.htm#Not) StringInStr (http://autoit-script.ru/autoit3_docs/functions/StringInStr.htm)($sections[$i], 'v_') And (http://www.autoitscript.com/autoit3/docs/keywords.htm#And) Not (http://www.autoitscript.com/autoit3/docs/keywords.htm#Not) StringRegExp (http://autoit-script.ru/autoit3_docs/functions/StringRegExp.htm)($sections[$i], '[а-яёА-ЯЁ]') Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
$msg &= $sections[$i] & @CRLF (http://autoit-script.ru/autoit3_docs/macros.htm#@crlf)
GUICtrlSetData (http://autoit-script.ru/autoit3_docs/functions/GUICtrlSetData.htm)($Edit1, $msg)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
Next (http://www.autoitscript.com/autoit3/docs/keywords.htm#Next)
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc)

Тут нужно определиться, либо...
секции только на кириллице »
либо...
секции, содержащие кириллицу »

если нужно первое, то в цикле последнее условие должно быть таким: StringRegExp($sections[$i], '^[а-яёА-ЯЁ]+$')

eus_deus
22-09-2013, 20:47
Creat0R, да, все было так просто. С текстовым полем работает, спасибо. С комбобоксом - нет, но это не в тему




© OSzone.net 2001-2012