nkanaga Posted September 18, 2011 Share Posted September 18, 2011 Please someone help me to write the below code in Autoit script. Int Array_1 [ ]=student.txtInt Array_2[ ]=CodeList.txtStudent.txt contains 400 of them like below, 10 characters letters and numbers like below1. 98AB1101012. 98AB1101023. 98AB110103So on up to 400 CodeList.txt contains 400 of them like below, 10 characters letters and numbers like below1. ACD00101012. ACD00101023. ACD00101034. So on up to 400I would like to have the auto it to . Compare the last five digits of 400 of student.txt and Codelist.txt and if the last digits of thestudent.txt and codelist.txt numbers are same then display the number. Link to comment Share on other sites More sharing options...
water Posted September 18, 2011 Share Posted September 18, 2011 When comparing the arrays do I have to compare e.g. element 2 of array 1 ("98AB110102") to element 2 of array 2 ("ACD0010102") or can the element of array 1 correspond to any of the 400 elements in array 2? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
nkanaga Posted September 18, 2011 Author Share Posted September 18, 2011 Yes, compare e.g. element 2 of array 1 ("98AB110102") to element 2 of array 2 ("ACD0010102``). if the last five digits of the element 2 of array 1 ("98AB110102") to element 2 of array 2 ("ACD0010102``) same the display number else display ``not same. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted September 18, 2011 Share Posted September 18, 2011 This function, _FileReadToArray, can replace this line - Int Array_1 [ ]=student.txt. Perhaps this function, StringCompare, can be used too. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
water Posted September 18, 2011 Share Posted September 18, 2011 (edited) Something like this: #include <file.au3> Global $Array_1, $Array_2 _FileReadToArray("C:\Temp\student.txt", $Array_1) _FileReadToArray("C:\Temp\CodeList.txt", $Array_2) For $i = 1 To $Array_1[0] If StringMid($Array_1[$i], 6) = StringMid($Array_2[$i], 6) Then MsgBox(0, "Compare", "# " & StringMid($Array_1[$i], 6) & " found in both files!") Next No error checking is done. When using in production you should check if _FileReadToArray return any errors and that both arrays have the same size. If you have 400 equal records you will get 400 msgboxes and have to click 400 times "OK". Might be better to write the result to a file and then display this file. Edited September 18, 2011 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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