Jump to content

# [Help] Comparing between 2 Arrays

## Recommended Posts

\$TimField = IniReadSectionNames(@DesktopDir & "\Data.ini")
For \$a = 1 To \$TimField[0]
\$TimField1 = IniReadSection(@DesktopDir & "\Data.ini", \$TimField[\$a])

For \$i = 1 To \$TimField1[0][0]
\$Key = \$TimFiled1[\$i][0]
\$Value = \$TimeField1[\$i][1]
MsgBox(0, "Section Name " & \$a & " n" & \$TimField[\$a], "Key: " & \$TimField1[\$i][0] & @CRLF & "Value: " & \$TimField1[\$i][1])
Next
Next
MsgBox(0,"","Xong")
\$1 = FileOpen('save.ini')
\$2 = FileRead(\$1)
\$3 = StringSplit(\$2,@CRLF)
For \$i  = 1 to \$3[0]
If \$3[\$i] <> '' Then
\$4 = _ExcelBookOpen(\$3[\$i])
\$5 = _ExcelReadSheetToArray(\$4, 1, 1) ;Starting on the 2nd Column
;~                  _ArrayDisplay(\$5)
For \$i = 1 to \$5[0][1]
\$Compare = \$5[1][\$i]
Next
If \$Compare = \$Key Then Iniwrite(0,"","", \$Value)
EndIf
Next

I got stuck in this problem... I don't know how to explain clearly my problem but hope you guys read my code first !!!!

I need to solve 2 cases

Case 1 :  If \$Compare = \$Key Then Iniwrite(0,"","", \$Value)

Case 2 : How can i read all data from \$5 ???

Thanks for reading my Topic.

Data.ini

Feel free to contact me for more information !!!

Edited by sdynk02
##### Share on other sites

I instantly notice several problems. The following line is wrong:

`If \$Compare = \$Key Then Iniwrite(0,"","", \$Value)`

0 is not a valid ini file name, section and key parameters have not been given valid names and this line should also be inside the second loop. Secondly you use the same variable \$i as iteration count, so the value becomes corrupted in the first loop. You should use a different variable every time you enter a new loop (nested inside another) eg:

```For \$i = 0 To 1
For \$j = 0 To 1
; Do something
Next
Next```
Edited by czardas
##### Share on other sites

I instantly notice several problems. The following line is wrong:

`If \$Compare = \$Key Then Iniwrite(0,"","", \$Value)`

0 is not a valid ini file name, section and key parameters have not been given valid names and this line should also be inside the second loop. Secondly you use the same variable \$i as iteration count, so the value becomes corrupted in the first loop. You should use a different variable every time you enter a new loop (nested inside another) eg:

```For \$i = 0 To 1
For \$j = 0 To 1
; Do something
Next
Next```

I forgot to fix my code, actually it's Msgbox(0,"","",\$Value), not Iniwrite. And Using Iniwrite is my purpose !!!!

##### Share on other sites

If you have free time, so Can you get into my pc to see what happens to understand more clearly about my code???. I'm using teamviewer for sure. I got somethings to ask you.
Many Thanks.

##### Share on other sites

I forgot to fix my code, actually it's Msgbox(0,"","",\$Value), not Iniwrite. And Using Iniwrite is my purpose !!!!

You have flag, title, text, and timeout for the first four parameters of MsgBox.  You have the value (text) in the timeout parameter.

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

##### Share on other sites

If you have free time, so Can you get into my pc to see what happens to understand more clearly about my code???. I'm using teamviewer for sure. I got somethings to ask you.
Many Thanks.

No, but if I were to do that, I would go to the AutoIt help file and open it on the page with tutorials.

##### Share on other sites

No, but if I were to do that, I would go to the AutoIt help file and open it on the page with tutorials.

I solved my problems. Anyway, tks for your help !!!!

\$1 = FileOpen('save.ini')
\$2 = FileRead(\$1)
\$3 = StringSplit(\$2,@CRLF)
For \$i  = 1 to \$3[0]
If \$3[\$i] <> '' Then
\$4 = _ExcelBookOpen(\$3[\$i])
\$5 = _ExcelReadSheetToArray(\$4, 1, 1)
;~          _ArrayDisplay(\$5)
\$TimField = IniReadSectionNames(@DesktopDir & "\Data.ini")
;_ArrayDisplay(\$TimField)
For \$a = 1 To \$TimField[0]
\$TimField1 = IniReadSection(@DesktopDir & "\Data.ini", \$TimField[\$a])
For \$i = 1 To \$TimField1[0][0]
;~                                                               MsgBox(0, "Section Name " & \$a & " n" & \$TimField[\$a], "Key: " & \$TimField1[\$i][0] & @CRLF & "Value: " & \$TimField1[\$i][1])
\$6  = IniRead(@DesktopDir & "\Data.ini",\$TimField[\$a],'cohaykhong','Khong Co')
Next
Next
For \$i = 1 to \$5[0][1]
MsgBox(0,'',\$6&'|'&\$5[1][\$i])
Next
EndIf
Next
EndFunc

##### Share on other sites

If the code does what you want, then that is a pure fluke. I still see you are reusing \$i in multiple places before previous usage has finished. You are overloading this unfortunate variable which can only store one loop count at a time. You want it to store too much information. I showed you a solution above.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now
• ### Recently Browsing   0 members

No registered users viewing this page.

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...