Jump to content

No output for simple array... worked a million times before.


tommytx
 Share

Recommended Posts

#include <FileConstants.au3>
#include <File.au3>
#include <Array.au3>

$mylist = "doggone.txt"
ConsoleWrite($mylist & @CRLF)
Local $aRec
_FileReadToArray($mylist, $aRec)
_ArrayDisplay($aRec)

Can anyone see anything wrong with this code... I have used it a zillion times before..  Just dead but shows The 0 0 at bottom suggesting it operated with no output.

This is in the text file in same directory as the au3 file

Yes it does print out the doggone.txt based on the ConsoleWrite command but no array box showing the data in the txt file.. NOTHING!.

doggone.txt
dog
cat
pig
hog

Added to show the result..
>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "E:\NEW_IDXSEO\_Recursive_Directory\plugins_real_short_archive_out\recursive-2.au3"    
doggone.txt
>Exit code: 0    Time: 0.2863

 

When I added this just to see:


ConsoleWrite($aRec[0] & @CRLF)
ConsoleWrite($aRec[1] & @CRLF)

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "E:\NEW_IDXSEO\_Recursive_Directory\plugins_real_short_archive_out\recursive-2.au3"    
doggone.txt
"E:\NEW_IDXSEO\_Recursive_Directory\plugins_real_short_archive_out\recursive-2.au3" (11) : ==> Subscript used on non-accessible variable.:
ConsoleWrite($aRec[0] & @CRLF)
ConsoleWrite($aRec^ ERROR

 

Edited by tommytx
Link to comment
Share on other sites

#include <FileConstants.au3>
#include <File.au3>
#include <Array.au3>

; This works fine..
Local $bRec[5] = ["Item 0", "Item 1", "Item 2", "Item 3", "Item 4"]
_ArrayDisplay($bRec)
ConsoleWrite($bRec[0] & @CRLF)
ConsoleWrite($bRec[1] & @CRLF)


$mylist = "doggone.txt"
ConsoleWrite($mylist & @CRLF)
Local $aRec
_FileReadToArray($mylist, $aRec)
_ArrayDisplay($aRec)

ConsoleWrite($aRec[0] & @CRLF)
ConsoleWrite($aRec[1] & @CRLF)

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "E:\NEW_IDXSEO\_Recursive_Directory\plugins_real_short_archive_out\recursive-2.au3"    
Item 0
Item 1
doggone.txt
"E:\NEW_IDXSEO\_Recursive_Directory\plugins_real_short_archive_out\recursive-2.au3" (18) : ==> Subscript used on non-accessible variable.:
ConsoleWrite($aRec[0] & @CRLF)
ConsoleWrite($aRec^ ERROR
>Exit code: 1    Time: 2.765

 

Edited by tommytx
Link to comment
Share on other sites

There's nothing wrong with the code in the first post. It works fine for me if I create and populate doggone.txt

The code in your second post also works for me provided doggone.txt is present. Without doggone.txt it crashed as you would expect.

Edited by pseakins
clarification

Phil Seakins

Link to comment
Share on other sites

Thanks for the help pseakins and subz.

Let's try again.. what I am saying that is not working is the array does not load so the _ArrayDisplay() will not pop up.

When I placed the error printer as requested, no error was shown.... but the _arrayDisplay() still does not function and the reason is the 5 items in file are not being placed in an array as they should be so the display will not show an array as it does not exist.

Further the missing array is confirmed when I try to print an item from the array which simply errors out..

Yet the @error suggests that the array loaded fine by no error.

 

$mylist = "doggone.txt"
Local $aRec
_FileReadToArray($mylist, $aRec)

ConsoleWrite('Error Y or N -> ' & @error & @CRLF)
_ArrayDisplay($aRec)  ; Problem is the display does not work.

; Note this errors out since the array was never loaded.
ConsoleWrite($aRec[0])


Error Y or N -> 1
"E:\NEW_IDXSEO\_Recursive_Directory\plugins_real_short_archive_out\recursive-2.au3" (14) : ==> Subscript used on non-accessible variable.:
ConsoleWrite($aRec[0])
ConsoleWrite($aRec^ ERROR

 

Link to comment
Share on other sites

2 hours ago, tommytx said:

Error Y or N -> 1

 

From the help. 1 - Error opening specified file

The file is NOT being read. Therefore you get the array subscript error because the array does not get populated.

Maybe you still have the file open in your editor or some other app, preventing the au3 script from accessing it.

Edited by pseakins

Phil Seakins

Link to comment
Share on other sites

19 hours ago, tommytx said:

I have used it a zillion times before.

Check for stray characters in both your script & input file. I once pulled all my hair out on a similar issue.

You could also try copy-pasting both into new files.

Link to comment
Share on other sites

$mylist = "doggone.txt"
Local $aRec
_FileReadToArray($mylist, $aRec)

ConsoleWrite('Error Y or N -> ' & @error & @CRLF)
if isArray($aRec) then
    _ArrayDisplay($aRec) 
    ConsoleWrite($aRec[0])
else
    ConsoleWrite("ERRORRRR!!!!!!!!!!!!!")
endif

;always got to protect the mcnuggets.  See my sig for error free array management!!!

 

Edited by markyrocks
Link to comment
Share on other sites

Its working now.. have no idea what did it.. may have been as someone said above a strange character running around. I put it into Notepad++ and lit up all the characters to see but nothing.. Anyway thanks for they help... it should have worked all along as I have used that display command many time.. Thanks a lot.

 

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