Jump to content

My for loop isn't looping?


Recommended Posts

Sup autoit forums!

I'm trying to make a loop to search values from an array into another array

#include <file.au3>
#include <array.au3>

Dim $ArrayAllSources
_FileReadToArray("allsources.csv", $ArrayAllSources)
Dim $ArrayList
_FileReadToArray("list.txt", $ArrayList)

_ArrayDisplay($ArrayAllSources) ; array of about 1000 items, [0] contains the total amount of item
_ArrayDisplay($ArrayList) ; array of about 10 items, [0] contains the total items

For $i = 1 to $ArrayList[0] ; from 1 to 10, should loop 10 times

$ItemToSearch= $ArrayList[$i]

ConsoleWrite($ItemToSearch & @CRLF) ; correctly returns the item at line number

For $i = 1 to $ArrayAllSources[0]
$pos = StringInStr($ArrayAllSources[$i], $ItemToSearch )
if $pos > 0 then
ConsoleWrite($pos & @CRLF) ; corretly returns the line number where the first item was found
Else
EndIf
Next
; but then it never loops, just exits there!
Next

Can you guys spot my mistake? I can't see it. It should work.

Thanks!

Link to comment
Share on other sites

You use $i for both loops. Use another variable for the inner loop.

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

:D

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