Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting information from a textfile using a template.

Status
Not open for further replies.

Disferente

Programmer
Jun 23, 2008
112
US
I need to get information from a set of textfiles, the info I want to get from the files is what is different between them.
To do this I have made a template; a copy of one of the files, removed the changing text and only kept what is the same, then I added variable names where the deleted text was.

I have a working way to do it now, but it is very slow;
I go byte by byte and check for differences between the template and the sourcefiles. If I find a difference and it is a varname (I use "{1{VarName}1}" without the quotes, the number because there are places where the info is nested, so if there are {2{Varname}2} inside the first it re parses the info inside.) I continue going in the sourcefile until I find the end of the difference and then copy that text to varname.

What I need is some faster method to do this, as 10-20 seconds for a 50kb file is too much.

Could someone please help me?

(I hope I have described it so someone can understand... If not, just ask on what part I not explained enough.)
 
Are you aware of the fc command available under a command prompt or do you especially want to do this under vb6.
For help go to a command prompt and type fc /?
 
I was not aware of that command, but it does not seem to do what I need. It only seems to compare whole lines. Further, I would probably have more problem with using the output from fc than I do now.
Thank you for your suggestion though.
 
I've been looking for other things and came across regexp... Would it be possible to use regexp to match to a text string that can be up to 200kb (perhaps even bigger) in size and would it be faster than the way I am using now?
 
Seems to mostly work with regexp, with one big thing not working.

There is a part of the text that might and might not be there. So far it works.
Inside that part there is a repeating pattern, it repeats from 2 to n times and inside the repeating part there are two places that I need to get as SubMatches. This is where I can't get it working. Is there any way of doing this?

My regexp pattern:
Text here (\d+) (?:some other text <(?:repeating (\d+)> text \d+\. ([^<]+)<)+endtext)? more

My source text:
Text here 2345 some other text <repeating 123> text 123. Something<repeating 321> text 321. Anything<repeating 312> text 312. Whatever<endtext more

The resulting SubMatches becomes as follows:
2345
312
Whatever

It gives only the last. How do I make it return the others as well?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top