Jump to content

Please help me to write the below script


nkanaga
 Share

Recommended Posts

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.

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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.

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...