Sign in to follow this  
Followers 0
StephenG

non-accessible subscript error

3 posts in this topic

I'm interested in breaking up a long text file into smaller ones - and found scripts under Split Text Files Speed Help (Forum - 3 Feb 2010). Both scripts by KeeWay and Melba23 apparently worked at the time.

I changed the script by Melba23 so that my files are referenced (and the search string is relevant to my files) but this generates a 'subscript ...error' message at the line For $i = 1 To $FileArray[0] below, with a ^ below the [0]:

#include <File.au3>

Global $FileArray
$file = @ScriptDir & "C:UsersStephenDesktopNew folderkahntextsel2.txt"
$newfile = @ScriptDir & "C:UsersStephenDesktopNew foldersplit-" ;

_FileReadToArray($file, $FileArray)

$filecount = 0
$sNewFile_Text = ""

ProgressOn("Processing SBT File", "Reading The File...", "0 Lines")

For $i = 1 To $FileArray[0]

SyntaxCheck Prod does not report any errors. I doubt it's significant - but the _FileReadToArray command is in colour in both example scripts, but not in my editor. I'm working with Windows 7 Professional SP1, 64 bit. (I'm a bit mystified by the #include, and have assumed that File.au3 is available with the download).

I'd appreciate any pointers as to what I should do. Thank you.

Stephen

Share this post


Link to post
Share on other sites



StephenG,

Welcome to the AutoIt forums. :)

The error is caused by you trying to access an array variable which is not actually an array - so it would appear that the function did not return one. You are correct that File.au3 is a standard include file - if the script could not find the file you would have other errors shown. ;)

I suggest you add a debugging line after the call to _FileReadToArray and see what error value is returned - that way we might get a better idea of why this is happening:

_FileReadToArray($file, $FileArray)
MsgBox(0, "Error", @error)
Try that and post the value that you see in the MsgBox. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thanks very much. The error message was: 1 - which I discovered means the file cannot be found. So then I looked at the file path and name - - and eventually figured that the @ScriptDir meant that the .au3 file, and the file to be processed, had to be in the same folder/directory. Once I changed the file name from the full path, and put the .au3 file in the same folder - it worked!

So thank you for your help. I needed a program like this a few years ago (to turn long text files with lots of records in into files with one record in - for further text analysis purposes) and gave up at that point. So this is great for me - it will help in my research. Having discovered AutoIt and recalling some Basic programming years ago, I might even try my hand now at writing other text processing routines.

Stephen

1 person likes this

Share this post


Link to post
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
Sign in to follow this  
Followers 0