MattHiggs Posted May 24, 2017 Share Posted May 24, 2017 (edited) Hello autoit scripters. So I have a question, and while this something I haven't tried before, I would still think it would be pretty straight forward. Below is some code that I have written which will read a file to an array, and I want to create a 2-dimensional array with the number of rows being equal to the number of items in the array divided by 4, and the number of columns equal to 4. However, when I try to create the array in this way, when I actually try to assign values to it, autoit is telling me that the array itself is returning an error. Thanks in advance: #include <File.au3> #include <Word.au3> #include <Array.au3> $array = FileReadToArray ( "C:\Users\whiggs\Documents\skills.txt" ) _ArrayDisplay ( $array ) Local $arr[Ceiling ( UBound ( $array ) / 4 )][4] $hol = 0 For $i = 0 To UBound ( $array ) - 1 Step 4 $arr[$hol][$i] = $array[$i] If @error Then SetError ( 0 ) ExitLoop EndIf $arr[$hol][$i + 1] = $array[$i + 1] If @error Then SetError ( 0 ) ExitLoop EndIf $arr[$hol][$i + 2] = $array[$i + 2] If @error Then SetError ( 0 ) ExitLoop EndIf $arr[$hol][$i + 3] = $array[$i + 3] If @error Then SetError ( 0 ) ExitLoop EndIf $hol += 1 Next Edited May 24, 2017 by MattHiggs Link to comment Share on other sites More sharing options...
Danyfirex Posted May 24, 2017 Share Posted May 24, 2017 Hello. Share a sample of skills.txt Input and expected output array. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Deye Posted May 24, 2017 Share Posted May 24, 2017 (edited) It isn't exactly clear to me, what you are after .. maybe try to work out something with this: Local $i = 0 Local $s = 0 For $x = 1 To Ceiling(UBound($array) / 4) - 1 Do $arr[$x][$i] = $array[$s] $i += 1 $s += 1 Until $i = 4 $i = 0 Next Edited May 24, 2017 by Deye Link to comment Share on other sites More sharing options...
FengHuangWuShen Posted May 24, 2017 Share Posted May 24, 2017 I'm confused too... I think what you're trying to achieve.. could be done simpler. Link to comment Share on other sites More sharing options...
MattHiggs Posted May 24, 2017 Author Share Posted May 24, 2017 Yeah I did just end up doing something simpler. The point of this was to use the content of skills.txt to create a table in a word document comprised of the contents. However, skills.txt has only 27 lines of regular text, so that just creates a table with one column and 27 rows, which would look pretty stupid. So I was trying to create a 2 dimensional array that would have 4 columns and however many number of rows would be necessary to hold the data stored in skills.txt. However, I just modified skills.txt so that the Function which creates tables in word would create the table as I desired. Sorry for the delay. Today has been a very.....stressful.... day. Link to comment Share on other sites More sharing options...
FengHuangWuShen Posted May 24, 2017 Share Posted May 24, 2017 Maybe you could also do like a list view display, so each time you run the script, it will give you the list view representation of Skills.txt. Link to comment Share on other sites More sharing options...
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