boomingranny Posted July 16, 2007 Share Posted July 16, 2007 (edited) Hi, I am Trying to read a line from a file, the line contains over 65534 characters. Can it be done? when i do the filereadline command it only returns the first 65534. is there anyway round this? other than perhaps using fileread??! Thanks for taking the time to help me Example: $test = "" for $i = 1 to 65600 $test &= "c" next $test &= " the end" msgbox (0, "string len before write",stringlen($test) & @CRLF & "last 7 char in string:"& stringright($test,7)) FileDelete("C:\boomingrannytest.txt") $x = fileopen ("c:\boomingrannytest.txt",1) FileWriteLine ($x,$test) FileClose ($x) $x = fileopen ("c:\boomingrannytest.txt",0) $test = FileReadLine ($x) FileClose ($x) msgbox (0, "string len after write/read",stringlen($test) & @CRLF & "last 7 char in string:"& stringright($test,7)) FileDelete("C:\boomingrannytest.txt") the weird thing is the filewriteline allows me to write more than 65534 chars (try opening the c:\boomingrannytest.txt file when the string len after write/read message box is up - see the "the end" text is there!), but the filereadline doesn't read more than 65534 Edited July 16, 2007 by boomingranny Link to comment Share on other sites More sharing options...
ChrisL Posted July 16, 2007 Share Posted July 16, 2007 (edited) ;Create a dummy file with a string length twice what file read line returns $chrs = 65534 * 2 $string= "" For $j = 1 to 20 For $i = 1 to $chrs $String &= "a" Next $String &= @CRLF Next FileWrite("myfile.txt",$string) ;Read the whole file into a variable $fileasaWhole = FileRead("myfile.txt") ;Split the file into an array by the @crlf at the end of line $fileasaarray = StringSplit($fileasaWhole,@CRLF,1) ;loop through each line in the file which is now in an array For $i = 1 to Ubound($fileasaarray) - 1 Msgbox(0,"","Line " & $i & " Is " & StringLen($fileasaarray[$i]) & " Charachters long");you can do whatever you want with the data here Next This is the bit you really interested in ;Read the whole file into a variable $fileasaWhole = FileRead("myfile.txt") ;Split the file into an array by the @crlf at the end of line $fileasaarray = StringSplit($fileasaWhole,@CRLF,1) ;loop through each line in the file which is now in an array For $i = 1 to Ubound($fileasaarray) - 1 Msgbox(0,"","Line " & $i & " Is " & StringLen($fileasaarray[$i]) & " Charachters long");you can do whatever you want with the data here Next Edited July 16, 2007 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
boomingranny Posted July 16, 2007 Author Share Posted July 16, 2007 (edited) so im just going to have to load the whole file into an array?? Problem is the file im working with is quite a whopper, hence the huge lines (some 65535+ in length) Thanks heaps for your speedy reply! i think there is also a _FileReadToArray which does a similar thing? Edited July 16, 2007 by boomingranny Link to comment Share on other sites More sharing options...
ChrisL Posted July 16, 2007 Share Posted July 16, 2007 so im just going to have to load the whole file into an array??Problem is the file im working with is quite a whopper, hence the huge lines (some 65535+ in length)Thanks heaps for your speedy reply!i think there is also a _FileReadToArray which does a similar thing?Yes there is, it pretty much does the same thing.Once you have read the whole file in which you'd only need to do once I think your script will be subsiquently much quicker because you just reffer back to the array from then on [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
boomingranny Posted July 16, 2007 Author Share Posted July 16, 2007 Yes, reading file from memory rather than disk is working out quite well, i just did a quick rewrite of my script (aprox 1300 lines with several functions) and i think its running faster, although its hard to tell... Thanks again for your 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