#133180 - 2005-01-31 04:16 PM
Maximum length of a text file ?
|
tonyh
Getting the hang of it
Registered: 2002-01-09
Posts: 55
Loc: UK
|
Hi
Im using Kix32 4.2. Im trying to read from one test file and retrieve the last 32 characters from each line until the end of the list and place it the results into another txt file. The list file is well over 50000 lines. The kix script keeps on ending before it gets even a 10th of the way down the list. Is there a maximum length for a file it can read or write to.
Heres the script
Break ON
CLS
:start
$=Open(1,"c:\mike\list.txt")
:read
Do $Line=ReadLine(1)
? "$line"
$x = Rtrim($line)
$y = Len("$x")
$machine = $x
If $x = "end"
Goto end
Else
$q=Right ("$x",32)
Shell 'cmd /c echo $q >> c:\mike\report.txt'
EndIf
:startagain
Until InStr($Line,"end")
:end
Shell 'cmd /c echo end of list'
thanks in advance
Tony
Edited by tonyh (2005-01-31 04:29 PM)
_________________________
Tonyh
|
|
Top
|
|
|
|
#133182 - 2005-01-31 04:52 PM
Re: Maximum length of a text file ?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
There used to be a 32kb limit on strings, but I didn't think it applied to files any more.
The following code is a bit tidier and easier to follow: Code:
Break ON $=SetOption("WrapAtEOL","ON") If Open(1,"c:\mike\list.txt") "Cannot open list.txt for reading"+@CRLF EndIf If Open(2,"c:\mike\report.txt",1+4) "Cannot open report.txt for writing"+@CRLF EndIf $Line=ReadLine(1) While Not @ERROR And Not InStr($Line,"end") $Line ? $=WriteLine(2,Right(RTrim($Line),32)+@CRLF) $Line=ReadLine(1) Loop $=Close(1) $=Close(2) ? "Done." ?
|
|
Top
|
|
|
|
#133183 - 2005-01-31 04:56 PM
Re: Maximum length of a text file ?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
PS both your original code and the code that I've just posted will stop if a line contains the text "end" anywhere in it.
You shouldn't need this check at all if you want to read the entire file.
If this is the case, change Code:
While Not @ERROR And Not InStr($Line,"end")
to just read Code:
While Not @ERROR
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 363 anonymous users online.
|
|
|