Quote:
Originally Posted by lolkop
That should be really easy. Just build a regular expression, that reads in all item data at once, parse it, and build an interface around it...
Should be done in a few lines of code.
Edit:
Example Code:
Code:
$matches = StringRegExp(FileRead('ItemTemplateAll1.ini'), "\[(\d+)\]\r\n(?:\d+=.+\r\n)*?1=(.+)\r\n(?:\d+=.+\r\n)+", 3)
GUICreate('GUI', 300, 150, Default, Default, 0x10C80000)
$list = GUICtrlCreateList('', 10, 10, 280, 90)
$input = GUICtrlCreateInput('', 10, 100, 280, 20)
$btnSearch = GUICtrlCreateButton('Search', 10, 125, 140, 20)
$btnSave = GUICtrlCreateButton('Save', 150, 125, 140, 20)
While True
Switch GUIGetMsg()
Case -3
Exit
Case $list
GUICtrlSetData($input, StringRegExpReplace(GUICtrlRead($list), '\[\d+\] ', ''))
Case $btnSearch
GUICtrlSetData($list, '')
For $i=0 To UBound($matches)-1 Step 2
If StringInStr($matches[$i+1], GUICtrlRead($input)) Then GUICtrlSetData($list, '['&$matches[$i]&'] '&$matches[$i+1])
Next
Case $btnSave
IniWrite('ItemTemplateAll1.ini', StringRegExpReplace(GUICtrlRead($list), '\[(\d+)\].+', '$1'), 1, GUICtrlRead($input))
EndSwitch
WEnd
|
Just 1 more question im working all day on this :( and no luck, when i change item and press Save it dont update items like :
1. find results
2. click on item u want to edit
3. edit item
4. update list and show that edited items + previous from first search
Like
Code:
$matches = StringRegExp(FileRead('ItemTemplateAll1.ini'), "\[(\d+)\]\r\n(?:\d+=.+\r\n)*?1=(.+)\r\n(?:\d+=.+\r\n)+", 3)
GUICreate('GUI', 300, 150, Default, Default, 0x10C80000)
$list = GUICtrlCreateList('', 10, 10, 280, 90)
$input = GUICtrlCreateInput('', 10, 100, 280, 20)
GUICtrlSetLimit ($input, 50, 3)
$btnSearch = GUICtrlCreateButton('Search', 10, 125, 140, 20)
$btnSave = GUICtrlCreateButton('Save', 150, 125, 140, 20)
While True
Switch GUIGetMsg()
Case -3
Exit
Case $list
GUICtrlSetData($input, StringRegExpReplace(GUICtrlRead($list), '\[\d+\] ', ''))
Case $btnSearch
GUICtrlSetData($list, '')
For $i=0 To UBound($matches)-1 Step 2
If StringInStr($matches[$i+1], GUICtrlRead($input)) Then GUICtrlSetData($list, '['&$matches[$i]&'] '&$matches[$i+1])
Next
Case $btnSave
IniWrite('ItemTemplateAll1.ini', StringRegExpReplace(GUICtrlRead($list), '\[(\d+)\].+', '$1'), 1, GUICtrlRead($input))
If Not @error Then
; if file sucessfully written
; update list with new data, read from $input and search again
_GUICtrlListBox_ResetContent($list) ; reset list items ( remove )
Else
MsgBox(48, "Error", "Error = " & @error & ", Extended = " & @extended)
EndIf
EndSwitch
WEnd