Jump to content

(solved) Array not being set correctly


Recommended Posts

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

Hello. Share a sample of skills.txt

Input and expected output array.

Saludos

Link to comment
Share on other sites

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

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