airrs Posted August 27, 2012 Share Posted August 27, 2012 (edited) hi guys, i have a little problem with a function here. i have two *.ini files, both filled with different and similar strings. now i want to compare the two lists. if there is a string which isn't in the list, the string should be added to the list. Func _BuIm() local $length $BuImOld = IniReadSection("Directory of the *.ini file","SectionName") $import = FileOpenDialog("Open Bu List", "Directory of the New file", "(*.ini)") $BuImNew = IniReadSection($import, "SectionName") For $k = 1 to $BuImOld[0][0] $length = $length + 1 Next $length = $length - 1 ; it starts with one but my list starts with 0 For $i = 1 to $BuImNew[0][0] For $j = 1 to $BuImOld[0][0] If $BuImNew[$i][1] <> $BuImOld [$j][1] Then $length = $length + 1 $x = $BuImNew[$i][1] _IniWrite("Directory of the *.ini file", "sectionName", $length, $x) ElseIf $BuImNew[$i][1] == $BuImOld [$j][1] Then ExitLoop EndIf Next Next _MainWin() EndFunc the function just do weird things and i dont know where the mistake is. can you please help me? Edited August 29, 2012 by airrs Link to comment Share on other sites More sharing options...
Myicq Posted August 27, 2012 Share Posted August 27, 2012 My 2c: files may differ in several ways, and it's quite complex to write a tool that sees the differences like yours.I would look at a tool like the free WinMerge, which also has a CLI and can be run with RunWait(). This tool has a myriad of options and you should be able to get a merged file, or a diff file out.If WinMerge won't do it, there are other alternativesAt least I personally prefer to jump the fence to get the job done. And try not to re-invent the wheel. I am just a hobby programmer, and nothing great to publish right now. Link to comment Share on other sites More sharing options...
UEZ Posted August 27, 2012 Share Posted August 27, 2012 Do you mean something like that? #include <Array.au3> Global $aList_1[5] = ["Car", "Zebra", "Computer", "AutoIt", "Forum"] Global $aList_2[4] = ["Red", "Computer", "Forum", "Tiger"] $aMerged = MergeDiff($aList_1, $aList_2) _ArrayDisplay($aMerged) Func MergeDiff($a1, $a2) Local $ub1 = UBound($a1) - 1 Local $ub2 = UBound($a2) - 1 Local $aNew[$ub1 + $ub2 + 2] Local $j = 0 For $i = 0 To $ub1 $aNew[$j] = $a1[$i] $j += 1 Next For $i = 0 To $ub2 $aNew[$j] = $a2[$i] $j += 1 Next Return _ArrayUnique($aNew) EndFunc Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Spiff59 Posted August 27, 2012 Share Posted August 27, 2012 Stealing UEZ's example, you could also just use the _ArrayConcatenate() function and end up with: #include <Array.au3> Global $aList_1[5] = ["Car", "Zebra", "Computer", "AutoIt", "Forum"] Global $aList_2[4] = ["Red", "Computer", "Forum", "Tiger"] _ArrayConcatenate($aList_1, $aList_2) $aList_1 = _ArrayUnique($aList_1) _ArrayDisplay($aList_1) Link to comment Share on other sites More sharing options...
UEZ Posted August 27, 2012 Share Posted August 27, 2012 I didn't use _ArrayConcatenate() because I didn't want to overwrite one of the arrays! Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
airrs Posted August 28, 2012 Author Share Posted August 28, 2012 ... because I didn't want to overwrite one of the arrays! ...but i do i have a list with data which must be changed sometimes. if someone from my team ison vacation or ill and a change happened in this time, he just need an exported list (export function already works) to import in the existing list.so on list needs to be overwritten.@Spiff59, thanks thats exactly what i needed.... And try not to re-invent the wheel.yeah, but just using other programs isn't very flexible and kinda lazy Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now