AustinTechnoGeek Posted April 7, 2006 Posted April 7, 2006 Hi, I'm working from the CSV to Array subroutines posted here:Filling Arrays from files, Excel .csv 2 AutoIT ArraysI'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[ ^ ERRORI 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[ ^ ERRORCan 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)
Valuater Posted April 7, 2006 Posted April 7, 2006 try this $in_filename = @MyDocumentsDir&"\Mycustomers.csv" no file open 8)
AustinTechnoGeek Posted April 7, 2006 Author Posted April 7, 2006 try this $in_filename = @MyDocumentsDir&"\Mycustomers.csv" no file open 8) Jeez... I feel like an idiot... solution was right under my nose.... Works great... thanks for the help
Valuater Posted April 7, 2006 Posted April 7, 2006 (edited) Welcome and... Welcome to the forums 8) Edited April 7, 2006 by Valuater
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