Jump to content

Help with Arrays


 Share

Recommended Posts

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 ]---
Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
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+£}úé÷쥩ì·)^
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...