bobsyuruncle Posted July 26, 2013 Posted July 26, 2013 For some reason what seems like a simple function has gone over my head as to why this doesn't work, so there must be some simple concept here I'm completely missing. I have a 2d array full of values from a csv file and I know that row 1,2 has nothing important, but column 3 has all the classes from the CSV So $twoDarray[3][*one through six] = 1. Name 2. Location 3. host ..etc So I should be able to pass all rows of column 3 by strconvert($twoDarray[3]). I've searched the forums but I could not find the solution to this probably simple problem. Dim $oneDarray $oneDarray=StringSplit($Rawfile, @CRLF, 1) $columnsCounter = stringsplit($oneDarray[2],",") Dim $twoDarray[$oneDarray[0] + 1][$columnsCounter[0] + 1] For $x = 1 to ($oneDarray[0]) $oneRow = stringsplit($oneDarray[$x],",") For $y = 1 to ($oneRow[0]) $twoDarray[$x][$y] = $oneRow[$y] Next Next strconvert($classes,$twoDarray[3]) Log Output Array variable has incorrect number of subscripts or subscript dimension range exceeded.: strconvert($classes,$twoDarray[3]) strconvert($classes,^ ERROR Thanks, Bob
Solution JohnOne Posted July 26, 2013 Solution Posted July 26, 2013 First, what is "strconvert"? Second, you cannot pass a part of an array to a function, unless it's its full location ($twoDarray[y][x]) You can however pass the whole array to a function, where you can loop through the needed parts and process them. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
bobsyuruncle Posted July 26, 2013 Author Posted July 26, 2013 strconvert is just my next function where I begin to step through the strings and parse the values I'm looking for, but is irrelevant to this topic just because the topic is really dealing with 'like you confirmed' passing part of an array into a function. So thank you for clearing that up. This question is resolved for me, thanks.
JohnOne Posted July 26, 2013 Posted July 26, 2013 I see. Additionally, when passing an array to a function the size of which you indicate, it is advisable to pass it by reference (ByRef). That way the array is not copied, saving time and memory. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
bobsyuruncle Posted July 26, 2013 Author Posted July 26, 2013 Would you mind posting a short example? Thanks
kylomas Posted July 26, 2013 Posted July 26, 2013 Why don't you just pass element 3 from $onedarray? Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
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