I thought I should start a new thread cos I suspect Lance is getting ready
to close the other one and I have begun to see the problem in a new light
thanks to all your clever input
John re: using a UDT to input to:
> This would also have the speed advantage that you can define sections of the
> line ready for processing rather than using Mid$
John thats Darn slick!! You mean you can input to a type! no one told me that - WOW!
I love that concept. As you say, that would speed up all that MID$ stuff.
> Why would you bother converting? The file is a classic fixed length fixed BYTE position record
why indeed.
So my question has become about the speed of reading a line at a time with: GET #1, LineLength, NewLineStr
Vs. Reading the whole file into memory and then working on it.
It seems intuitvly that working with it in memory should be faster
but this does not seem to be the case in practice. So I assume
the way I am handling the file in memory is not optimal.
So far, to work on the whole file in memory, I have only tried:
This was slow because i think Parse$ has to start at the beginning of the string a$ each time.
I think reading a line at a time was faster because the file pointer is sitting at the start of the next record
and windows reads large chunks at a time into memory of a file that is open (???)
Michael,
> How about plan C?
> x$ = EXTRACT$([start, ]MainString, [ANY] MatchString
This looks perfect. I assume after the extraction, i just lop off that many chars
from the front of the string and then do it again with:
> Or plan D?
> REGEXPR mask$ IN main$ [AT start&] TO posvar&, lenvar&
> (BTW, there's a REGEXPR replacement for LINE INPUT in the Source Code forum)
Im not using LINE INPUT tho ???
Or even plan E:
position& = INSTR(a$,CHR$(10))
NewLineStr = LEFT$(a$, position&-1)
a$ = RIGHT$(a$, LEN(a$) - position&)
So which is faster guys?
GET #1, ' read a line at a time
EXTRACT$ ' process a string in memory
REGEXPR ' process a string in memory
INSTR( ' process a string in memory
Scott, Fred,
Thank you for the code
(PS. The Lines I posted originally were from another file that is 70 Chars long yes.
There are two files. It turns out I need to work with the second which is 80Chars.
Sorry for the confusion)
------------------
Kind Regards
Mike
[This message has been edited by Mike Trader (edited July 15, 2001).]
to close the other one and I have begun to see the problem in a new light
thanks to all your clever input

John re: using a UDT to input to:
> This would also have the speed advantage that you can define sections of the
> line ready for processing rather than using Mid$
John thats Darn slick!! You mean you can input to a type! no one told me that - WOW!
I love that concept. As you say, that would speed up all that MID$ stuff.
> Why would you bother converting? The file is a classic fixed length fixed BYTE position record
why indeed.
So my question has become about the speed of reading a line at a time with: GET #1, LineLength, NewLineStr
Vs. Reading the whole file into memory and then working on it.
It seems intuitvly that working with it in memory should be faster
but this does not seem to be the case in practice. So I assume
the way I am handling the file in memory is not optimal.
So far, to work on the whole file in memory, I have only tried:
Code:
OPEN "file" FOR BINARY AS #1 GET$ #1, LOF(1), a$ CLOSE #1 FOR i = 1 TO PARSECOUNT(a$, CHR$(10)) NewLineStr = PARSE$(a$, i) CALL process LINE NEXT
I think reading a line at a time was faster because the file pointer is sitting at the start of the next record
and windows reads large chunks at a time into memory of a file that is open (???)
Michael,
> How about plan C?
> x$ = EXTRACT$([start, ]MainString, [ANY] MatchString
This looks perfect. I assume after the extraction, i just lop off that many chars
from the front of the string and then do it again with:
Code:
DO NewLineStr = EXTRACT$(a$, CHR$(10)) a$ = RIGHT$(a$, LEN(a$) - LEN(NewLineStr)) LOOP
> REGEXPR mask$ IN main$ [AT start&] TO posvar&, lenvar&
Code:
b$ = "\n" 'interpreted as a line-feed or new-line character: CHR$(10) start& = INSTR(a$, CHR$(10)) DO REGEXPR b$ IN a$ AT start& TO position&, length& NewLineStr = mid$(a$, start&, start&-position&) start& = position& LOOP
Im not using LINE INPUT tho ???
Or even plan E:
position& = INSTR(a$,CHR$(10))
NewLineStr = LEFT$(a$, position&-1)
a$ = RIGHT$(a$, LEN(a$) - position&)
So which is faster guys?
GET #1, ' read a line at a time
EXTRACT$ ' process a string in memory
REGEXPR ' process a string in memory
INSTR( ' process a string in memory
Scott, Fred,
Thank you for the code

(PS. The Lines I posted originally were from another file that is 70 Chars long yes.
There are two files. It turns out I need to work with the second which is 80Chars.
Sorry for the confusion)
------------------
Kind Regards
Mike
[This message has been edited by Mike Trader (edited July 15, 2001).]
Comment