autoitFR Posted February 4, 2011 Share Posted February 4, 2011 I've been using FileReadLine() to read in lines of data that takes user input and compares it to the file being read. I recently updated the file and noticed that I get an array error after having made the file go past 64KB. After Googling for an answer it looks like there was a cap put on older versions but was removed. I'm wondering if the cap got put back on the latest release, as that is what I've been working with. The other weird thing is, I've changed my function that reads in the text file to use FileRead() instead, however it stops at the exact same spot. I'm stumped and any help would be appreciated. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 4, 2011 Moderators Share Posted February 4, 2011 autoitFR,Welcome to the AutoIt forum. If you could post your code (please put [autoit] before and [/autoit] after your posted code) and let us know if there is anything special about the file you are trying to read, we might be able to offer some sensible help. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
autoitFR Posted February 5, 2011 Author Share Posted February 5, 2011 (edited) Here's two versions that worked prior to adding more information to the info.txt file I read in. When it stops on the last line, it only displays half of what that line actually contains. There's nothing special about the info.txt file. There's an item name with two item numbers which are separated with |. ITEMNAME|ITEMNUM1|ITEMNUM2 ITEMNAME|ITEMNUM1|ITEMNUM2 ITEMNAME|ITEMNUM1|ITEMNUM2 Func _findmyitem($x1, $y1, $x2, $y2) Local $item_to_check, $file, $line, $result, $CNF $CNF = "ITEM NOT FOUND" $item_to_check = "ITEM NUMBER" $file = FileOpen("info.txt", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open info.txt.") Exit EndIf While 1 $chars = FileRead($file) If @error = -1 Then ExitLoop $line = StringSplit($chars, @CRLF, 1) If $line[1] = "" Then ExitLoop For $x = 1 to $line[0] $result = StringSplit($line[$x], "|", 1) If StringCompare($result[2], $item_to_check, 2) == 0 OR StringCompare($result[3], $item_to_check, 2) == 0 Then FileClose($file) Return $result[1] EndIf Next WEnd FileClose($file) Return $CNF EndFunc Func _findmyitem($x1, $y1, $x2, $y2) Local $item_to_check, $file, $line, $result, $CNF $CNF = "ITEM NOT FOUND" $item_to_check = "ITEM NUMBER" $file = FileOpen("info.txt", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open info.txt.") Exit EndIf While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $result = StringSplit($line, "|", 1) If StringCompare($result[2], $item_to_check, 2) == 0 OR StringCompare($result[3], $item_to_check, 2) == 0 Then FileClose($file) Return $result[1] EndIf WEnd FileClose($file) Return $CNF EndFunc Edited February 5, 2011 by autoitFR Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 5, 2011 Moderators Share Posted February 5, 2011 autoitFR,I created a file in the format you use with this script:$sContent = "" For $i = 1 To 99999 $iNumber = StringFormat("%05i", $i) $sContent &= "ITEMNAME_" & $iNumber & "|ITEMNUM1_" & $iNumber & "|ITEMNUM2_" & $iNumber & @CRLF Next $hFile = FileOpen(@ScriptDir & "\Item.txt", 2) FileWrite($hFile, $sContent) FileClose($hFile)That gave me a file of over 4.5 Mb. (4,599,954 to be exact )I then ran these scripts which I based on those you posted above on that file and both returned the penultimate entry without problem:expandcollapse popupConsoleWrite(_findmyitem("ITEMNUM1_99998") & @CRLF) Func _findmyitem($item_to_check) $CNF = "ITEM NOT FOUND" $file = FileOpen("info.txt", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open info.txt.") Exit EndIf While 1 $chars = FileRead($file) If @error = -1 Then ConsoleWrite("No read" & @CRLF) ExitLoop EndIf $line = StringSplit($chars, @CRLF, 1) If $line[1] = "" Then ConsoleWrite("No Split" & @CRLF) ExitLoop EndIf For $x = 1 to $line[0] $result = StringSplit($line[$x], "|", 1) If StringCompare($result[2], $item_to_check, 2) == 0 OR StringCompare($result[3], $item_to_check, 2) == 0 Then FileClose($file) Return $result[1] EndIf Next ExitLoop WEnd FileClose($file) Return $CNF EndFuncConsoleWrite(_findmyitem("ITEMNUM1_99998") & @CRLF) Func _findmyitem($item_to_check) $CNF = "ITEM NOT FOUND" $file = FileOpen("info.txt", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open info.txt.") Exit EndIf While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $result = StringSplit($line, "|", 1) If StringCompare($result[2], $item_to_check, 2) == 0 OR StringCompare($result[3], $item_to_check, 2) == 0 Then FileClose($file) Return $result[1] EndIf WEnd FileClose($file) Return $CNF EndFuncSo I can confidently say that the problem in reading a file over 64kb is one which is within your system, not AutoIt. Are you sure that in updating the Info.txt file you have not altered the format in some way so that you get an incomplete read? Perhaps give it a glance in a hex editor - or post it here so I can take a look. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
autoitFR Posted February 5, 2011 Author Share Posted February 5, 2011 Thank you for the insight! I found the problem and it was with my system. I set aside only 512mb of RAM for my VM running the script and bumped it up to 1GB and it works fine now. Thanks for the help! 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