Sign in to follow this  
Followers 0
nkanaga

Please help me to write the below script

5 posts in this topic

Please someone help me to write the below code in Autoit script.

Int Array_1 [ ]=student.txt

Int Array_2[ ]=CodeList.txt

Student.txt contains 400 of them like below, 10 characters letters and numbers like below

1. 98AB110101

2. 98AB110102

3. 98AB110103

So on up to 400

CodeList.txt contains 400 of them like below, 10 characters letters and numbers like below

1. ACD0010101

2. ACD0010102

3. ACD0010103

4. So on up to 400

I 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.

Share this post


Link to post
Share on other sites



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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0