Help with read data

11/08/2013 00:02 mlukac89#1
i need help with reading data from ini
when i open file it returns me 1 and not content of file

here is script

Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <File.au3>

#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form1", 516, 419, 193, 124)
$List1 = GUICtrlCreateList("", 8, 8, 289, 396)
$Button1 = GUICtrlCreateButton("Open file", 312, 8, 193, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

			$file = FileOpen("C:\Temp\ItemTemplateAll.ini", 0)

			; Check if file opened for reading OK
			If $file = -1 Then
				MsgBox(0, "Error", "Unable to open file.")
				Exit
			Else
				$List1 = GUICtrlSetData($List1, $file & @CRLF)
			EndIf

	EndSwitch
WEnd
and here is ini file

[Only registered and activated users can see links. Click Here To Register...]
11/08/2013 00:51 BladeTiger12#2
Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <File.au3>

#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form1", 516, 419, 193, 124)
$List1 = GUICtrlCreateList("", 8, 8, 289, 396)
$Button1 = GUICtrlCreateButton("Open file", 312, 8, 193, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

			$file = FileOpen("C:\Temp\ItemTemplateAll.ini", 0)

			; Check if file opened for reading OK
			If $file = -1 Then
				MsgBox(0, "Error", "Unable to open file.")
				Exit
			Else
				$List1 = GUICtrlSetData($List1, FileRead("C:\Temp\ItemTemplateAll.ini") & @CRLF)
			EndIf

	EndSwitch
WEnd
Try FileRead.
11/08/2013 02:35 mlukac89#3
tried that too dont works

i now tested with normal txt file and it opens it and i tried to rename that ini to txt but still wont load data from it and i can opet it in notepad and see data in, maybe is file too big and autoit cant load it ?
11/08/2013 06:40 Sh1Rum#4
try iniread :> that is for ini Files :)
11/08/2013 12:43 mlukac89#5
tried that too but this ini is diferent than normal one its from game, but if i can open it in notepad i dont see reason why i cant read it as a file. If i convert extension to .txt same happening

this is one section for 1 item

Code:
[5018]
0=AgpmItem
1=Karkaen necklace
2=0
3=1
4=1
5=0
6=0
7=0
8=0
9=0
10=0
11=0
12=0
13=0
14=0
15=0
16=0
17=0
18=0
19=0
20=0
21=0
22=0
23=0
24=0
25=0
26=0
27=0
28=0
29=0
30=0
31=0
32=0
33=0
34=0
35=0
36=0
37=0
38=0
39=0
40=0
41=0
42=0
43=0
44=0
45=0
46=0
47=0
32=0
48=0
33=0
34=0
35=0
36=0
37=0
38=0
39=0
40=0
41=0
42=0
43=0
44=0
45=0
46=0
47=0
48=0
49=0
50=0
51=0
33=0
34=0
35=0
36=0
37=0
38=0
39=0
40=0
41=0
42=0
43=0
44=0
45=0
46=0
47=0
51=0
52=0
33=0
34=0
35=0
36=0
37=0
38=0
39=0
40=0
41=0
42=0
43=0
44=0
45=0
46=0
47=0
52=0
53=0
54=0
55=0
56=0
57=0
58=0
59=0
60=0
61=0
62=0
63=0
64=0
65=0
66=0
67=0
68=0
69=0
70=0
71=0
72=1065353216
73=1166024704
74=0
75=0
76=0
5=0
6=0
7=0
8=0
9=0
10=0
11=0
12=0
13=0
14=37
15=0
16=0
17=0
77=0
78=0
79=0
80=0
81=0
75=0
82=13
83=16
84=0
85=ApmEventManager
86=AgcmItem
87=196
89=5018
90=1
93=5283840
94=0
95=-0.003082:20.687401:0.004089:32.310398
96=0:0:0:0:0:0:0:0:0:0:0:0
97=0
98=0
99=0
100=0
101=AgcmEventEffect
102=-842150451
103=0:131072
104=0:0:0:0:0:1:0:0
105=0:IS0015.WAV
106=1:1
107=1:0:0:0:0:1:0:0
108=1:IS0023.WAV
115=0
and every item have diferent code in section [] but i need to get that in list to be able for search items.

I need when i type Karkaen to get < [5018] = Karkaen necklace > not the rest of the numbers like you see here.
11/08/2013 14:18 alpines#6
If you looked it up on the documentation then you would know that FileOpen opens a handle for the file. You can rather use
Code:
$hFile = FileOpen(...)
$sFile = FileRead($hFile)
FileClose($hFile)
or
Code:
$sFile = FileRead("Path")
The first method is much better.
IniRead is easy too
Code:
$sEntry = IniRead("PathToIni", "5018", "0", "")
To write an Ini entry you should use
Code:
IniWrite("PathToIni", "SectionName", "EntryName", "DataToWrite")