Big ini read, found data problem

08/13/2015 12:50 lolkop#16
The code example i've posted is looking for every thing, containing your input...

If you want exact matches, simply remove the wildcards <.<

Code:
#include <array.au3>
_ArrayDisplay(StringRegExp(FileRead('ItemTemplateAll1.ini'), "[1]=("&InputBox("Search for", "Enter your Text:")&")", 3))
08/13/2015 13:16 mlukac89#17
Your first example just works fine give me all results i want, but i dont know how to put that in variable so i can loop through array and put items i founded in listview like it opens in 1 sec in _ArrayDisplay() with your 1st example.

Code:
Case $hFinddAllButton
            $test = GuiCtrlRead($hSearchInput)  ; read the search input
            _ArrayDisplay(StringRegExp(FileRead($file), "[1]=(.*"&$test&"*)", 3))

           ; loop through array and populate list
           ; when click on list item store it in $hNameInput and put ID "[5014]" in $hItemID
08/13/2015 14:08 lolkop#18
StringRegExp returns all matches in an array. So you can loop through it, to add stuff to your GUI:

Code:
$matches = StringRegExp(FileRead('ItemTemplateAll1.ini'), "[1]=("&InputBox("Search for", "Enter your Text:")&")", 3)
GUICreate('GUI', 300, 100, Default, Default, 0x10C80000)
$lv = GUICtrlCreateListView('Name', 0, 0, 300, 100)
For $match In $matches
	GUICtrlCreateListViewItem($match, $lv)
Next
While GUIGetMsg()<>-3
WEnd
08/13/2015 23:23 mlukac89#19
My project was to made something like this [Only registered and activated users can see links. Click Here To Register...] but for now still no success :(
08/14/2015 09:04 lolkop#20
Quote:
Originally Posted by mlukac89 View Post
My project was to made something like this [Only registered and activated users can see links. Click Here To Register...] but for now still no success :(
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
08/14/2015 12:32 mlukac89#21
Thanks alot man u helped me alot to see how all works and how to handle with all data and array contents.

Cheers
08/15/2015 22:29 mlukac89#22
Quote:
Originally Posted by lolkop View Post
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
09/01/2015 19:48 mlukac89#23
Quote:
Originally Posted by lolkop View Post
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
To dont open new topic, how i can get from this class name ?

Because every section have this keys 78, 80 so how i can recognize it if its founded.

For example i have :

Code:
[section number]
1=Armor of Kildemor
78=2
80=1
[other sections]
1=Armpads of Kildemor
78=2
80=1
[other section]
1=Graves of Kildemor
78=2
80=1
[other section]
1=Boots of Kildemor
78=2
80=1
[other section]
1=Armor of Aaron
78=1
80=1
[other section]
1=Gilliwen Culet
78=8
80=15
so when i find item to get what class item is for.
In ini file is like this i founded all class, so now if i search for item lets say

Kildemor its for 2,1 so its Berserker
Gilliwen is for 8,15 so its Scion

Something like if 78=2 and 80=1 then is Berserker

Code:
1=Name
78=Race
80=Class

=============================

78=1 ; human
80=1 ; knight
80=2 ; archer
80=8 ; mage

78=2 ; orc
80=1 ; berskerer
80=2 ; hunter
80=8 ; sorc

78=4 ; elf
80=1 ; swashbuckler
80=2 ; ranger
80=8 ; elementalist

78=8 ; dragonscion
80=15 ; scion