Sign in to follow this  
Followers 0
sandyd

Help with Arrays

4 posts in this topic

Hi all,

Having a bit of a problem getting my head round array. See the following code:

#include <file.au3>
#include <Array.au3> 

Dim $WordList, $As[1]

_FileReadToArray('a.txt',$WordList)

For $i = 1 To $WordList[0]
 If StringLower(StringLeft($WordList[$i],3)) = 'add' Then _ArrayAdd($As,$WordList[$i])
Next
 
_ArrayDisplay($As,'ADD ...')

MsgBox(0,'',$As[0])

A file with lots of words begining with the letter A is read. I then try to filter them down by searching for the first 3 letters to be add.

When I try to display the results, it cant determine the number of items in the array. I have checked by outputting $As[0] which shows blank.

Any ideas?


----[ SandyD ]---

Share this post


Link to post
Share on other sites



Hi all,

Having a bit of a problem getting my head round array. See the following code:

#include <file.au3>
#include <Array.au3> 

Dim $WordList, $As[1]

_FileReadToArray('a.txt',$WordList)

For $i = 1 To $WordList[0]
 If StringLower(StringLeft($WordList[$i],3)) = 'add' Then _ArrayAdd($As,$WordList[$i])
Next
 
_ArrayDisplay($As,'ADD ...')

MsgBox(0,'',$As[0])

A file with lots of words begining with the letter A is read. I then try to filter them down by searching for the first 3 letters to be add.

When I try to display the results, it cant determine the number of items in the array. I have checked by outputting $As[0] which shows blank.

Any ideas?

If the msgbox is not there, then you probably have too much information to display... Use Ubound($As) - 1 instead of $As[0] and see what you get

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Hi all,

Having a bit of a problem getting my head round array. See the following code:

#include <file.au3>
#include <Array.au3> 

Dim $WordList, $As[1]

_FileReadToArray('a.txt',$WordList)

For $i = 1 To $WordList[0]
 If StringLower(StringLeft($WordList[$i],3)) = 'add' Then _ArrayAdd($As,$WordList[$i])
Next
 
_ArrayDisplay($As,'ADD ...')

MsgBox(0,'',$As[0])

oÝ÷ Øâì"¶h¶ÊÂݱ· x§­Ø^ëmz°"²·taz{kÊÚ[^®Ø^Ú0¼¬yªÜ)à~íçâ®Ëwëmz»-¡·¢Z+£}úé÷쥩ì·)^

Share this post


Link to post
Share on other sites

Cheers for the replies,

I think I'll stick with UBound, more generic and less for me to worry about.


----[ SandyD ]---

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