Jump to content

Recommended Posts

Posted

Hi, I'm working from the CSV to Array subroutines posted here:

Filling Arrays from files, Excel .csv 2 AutoIT Arrays

I'm trying to use the Fileopen command to silently open my data file instead of the fileopendialog command but everyway that I try it I get the following errors from the _FileReadToArray routine.

==> Subscript used with non-Array variable.:

Dim $Name[ $lines[0] ]

Dim $Name[ $lines^ ERROR

==> Array variable subscript badly formatted.:

Dim $Name[ $lines[0] ]

Dim $Name[ ^ ERROR

I tried removing the Array dimension (the [0]) from the Dim line to make it read Dim $Name[$Lines] and the error changed to this"

: ==> Array variable subscript badly formatted.:

Dim $Name[ $lines ]

Dim $Name[ ^ ERROR

Can someone help me understand why this happens when I use FileOpen but works fine when I use FileOpenDialog?

#region -------------- Set up the environment and load the data file ---------------
#include <GuiConstants.au3>
#Include <Array.au3>
#include <File.au3>
      ;$in_filename = FileOpenDialog("hi",@MyDocumentsDir,"Files (*.csv)",5,"Mycustomers.csv")
       $in_filename = FileOpen(@MyDocumentsDir&"\Mycustomers.csv",1)
Dim $lines

_FileReadToArray($in_filename, $lines)

Dim $Name[ $lines[0] ]
DIM $DispName[ $lines[0] ]
DIM $CustNum[ $lines[0] ]
Dim $ConCode[ $lines[0] ]
DIM $KCode[$lines[0] ]

For $i = 1 To $lines[0]
    $temp = StringSplit($lines[$i], ",")
    If $temp[0] = 1 Then Continueloop
$name[$i-1] = $temp[1]
$DispName[$i-1] = $temp[1]
$CustNum[$i-1] = $temp[2]
$ConCode[$i-1] = $temp[3]
$KCode[$i-1] = $temp[4]
_ArraySort($DispName)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...