tommytx Posted November 12, 2020 Share Posted November 12, 2020 (edited) #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 November 12, 2020 by tommytx Link to comment Share on other sites More sharing options...
tommytx Posted November 12, 2020 Author Share Posted November 12, 2020 (edited) #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 November 12, 2020 by tommytx Link to comment Share on other sites More sharing options...
pseakins Posted November 12, 2020 Share Posted November 12, 2020 (edited) 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 November 12, 2020 by pseakins clarification Phil Seakins Link to comment Share on other sites More sharing options...
Subz Posted November 12, 2020 Share Posted November 12, 2020 I would place a ConsoleWrite(@error & @CRLF) after the _FileReadToArray(...) to see what the error is. Or using FileExists(...) Link to comment Share on other sites More sharing options...
tommytx Posted November 12, 2020 Author Share Posted November 12, 2020 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 More sharing options...
JockoDundee Posted November 12, 2020 Share Posted November 12, 2020 52 minutes ago, tommytx said: Yet the @error suggests that the array loaded fine by no error. Can you just post the “doggone” file already? Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted November 12, 2020 Share Posted November 12, 2020 @tommytx Try something like this: $mylist = @ScriptDir & "\doggone.txt" It seems that you are not reading the file. markyrocks 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
pseakins Posted November 12, 2020 Share Posted November 12, 2020 (edited) 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 November 12, 2020 by pseakins markyrocks and Danp2 2 Phil Seakins Link to comment Share on other sites More sharing options...
dmob Posted November 12, 2020 Share Posted November 12, 2020 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 More sharing options...
markyrocks Posted November 12, 2020 Share Posted November 12, 2020 (edited) $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 November 12, 2020 by markyrocks Spoiler "I Believe array math to be potentially fatal, I may be dying from array math poisoning" Link to comment Share on other sites More sharing options...
tommytx Posted November 12, 2020 Author Share Posted November 12, 2020 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 More sharing options...
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