Zepx Posted November 22, 2007 Posted November 22, 2007 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.
hearurscream Posted November 22, 2007 Posted November 22, 2007 Take the plus sign out of your For 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.
Achilles Posted November 22, 2007 Posted November 22, 2007 You could actually take all of the "Step +1" as the default step amount value is one. So you just need this: For $i = 0 To 5 My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Zepx Posted November 22, 2007 Author Posted November 22, 2007 Thanks for the info, but that doesn't solve my problem for the array assigning, since it gives me that error.
hearurscream Posted November 22, 2007 Posted November 22, 2007 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.
Zepx Posted November 22, 2007 Author Posted November 22, 2007 Ah, sorry bout that. The problem given when runned is at this line: $names[$i] = $columns[1] $age[$i] = $columns[2]
hearurscream Posted November 22, 2007 Posted November 22, 2007 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.
Zepx Posted November 22, 2007 Author Posted November 22, 2007 Yeah sure. The coding above I used was for testing. The original code is for this. Hope it helps.clicker.au3
randallc Posted November 22, 2007 Posted November 22, 2007 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] NextI can't see that you have declared size of array anywhere? (see helpfile on Arrays) best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
Zepx Posted November 22, 2007 Author Posted November 22, 2007 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...
randallc Posted November 22, 2007 Posted November 22, 2007 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 ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
Zepx Posted November 22, 2007 Author Posted November 22, 2007 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!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now