Jump to content

Assigning Array


Zepx
 Share

Recommended Posts

Hi,

I'm pretty new to AutoIt scripting.

Ok, my question is, how can I do this?

For $i = 0 To 5 Step +1
    $readline = FileReadLine($file, $i)
    $columns = StringSplit($readline, "|")
    $names[$i] = $columns[1]
    $age[$i] = $columns[2]
Next

my problem with this code gives me

Error: Expected a "=" operator in assignment statement

I have no idea how I can solve this problem. Basically this codes reads from $file every line and then assigns name and age in to a separate variable which indexes from 0 to 5.

Link to comment
Share on other sites

Can you give us a line number, or perhaps include the rest of the error statement?

Infinity is a floorless room without walls or ceiling.Anyone who cannot cope with mathematics is not fully human. At best he is a tolerable subhuman who has learned to wear shoes, bathe, and not make messes in the house.

Link to comment
Share on other sites

Well I don't see a problem in your script, but can you post the whole code?

Infinity is a floorless room without walls or ceiling.Anyone who cannot cope with mathematics is not fully human. At best he is a tolerable subhuman who has learned to wear shoes, bathe, and not make messes in the house.

Link to comment
Share on other sites

Yeah sure. The coding above I used was for testing.

The original code is for this. Hope it helps.

hi, maybe;

local $account[$countlines],$password[$countlines] 
For $i = 0 To $countlines
    $readline = FileReadLine($file, $i)
    $columns = StringSplit($readline, "|")
    $account[$i] = $columns[1]
    $password[$i] = $columns[2]
Next
I can't see that you have declared size of array anywhere? (see helpfile on Arrays)

best, Randall

Link to comment
Share on other sites

yeah, it was my mistake for not declaring the array size.

@randallc,

I used your method, however it seems that I'm getting

Array variable has incorrect number of subscripts or subscript dimension range exceeded. Any ideas? I searched the forum, but I don't understand...

Link to comment
Share on other sites

yeah, it was my mistake for not declaring the array size.

@randallc,

I used your method, however it seems that I'm getting

Array variable has incorrect number of subscripts or subscript dimension range exceeded. Any ideas? I searched the forum, but I don't understand...

Hi, Sorry,

probably;

local $account[$countlines+1],$password[$countlines+1]
Randall
Link to comment
Share on other sites

Hmm.. it still gives the same error. However, I changed it from using the loop For to While... in this case the expression is < $countlines. It works nicely =)...

I don't understand the usage of Ubound and those _FileReadToArray thingy... many of the other topics uses them. This is my first script.

Btw, thanks for your help randallc!

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