Jump to content

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded


Recommended Posts

 I have a very simple script to read a text file into an array. But when I try to use any of the element in the array I got the error. Here is the script:

#include <Date.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
#include <Array.au3>

$Title = "Testing ..."

$RawFilePath = "C:\Premier\Variant\DATA\2018\0511\002506001.raw"
; read raw file
Global $aRawData
_FileReadToArray($RawFilePath, $aRawData, $FRTA_NOCOUNT, "|")
_ArrayColDelete($aRawData, 1)
MsgBox(0, $Title, "First point: " & $aRawData[0])

The error is at $aRawData[0] on the last line. File 002506001.raw is attached. I was able to use _ArrayDisplay() to show it in list view.

002506001.raw

Link to comment
Share on other sites

Hi @youngjohn, and welcome to the AutoIt forums :)
You forgot an important parameter, especially in your case:

$bConvert   [optional] If True then if only one column remains the array is converted to 1D

So, adding it to your script:

#include <Date.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
#include <Array.au3>

$Title = "Testing ..."

$RawFilePath = "C:\Premier\Variant\DATA\2018\0511\002506001.raw"
; read raw file
Global $aRawData
_FileReadToArray($RawFilePath, $aRawData, $FRTA_NOCOUNT, "|")
_ArrayDisplay($aRawData, "Before deleting Column 1 (Second Column):")
_ArrayColDelete($aRawData, 1, True)
MsgBox(0, $Title, "First point: " & $aRawData[0])

You can have a 1-Dimension array :)
 

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

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