Sign in to follow this  
Followers 0
PowerCat

My for loop isn't looping?

4 posts in this topic

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!

Share this post


Link to post
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 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

Hahaha nice. Such a noobish mistake :P

Thanks!

Share this post


Link to post
Share on other sites
:D

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