Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Text Files

bubblybubbly Member Posts: 18
I have managed to save the structure of a table in a text file. How can I read this file in, so I can take the first segment in each line and use it as a header on each column of the String Grid?
Also, what code can I use to search thru a text file to see how many lines are stored in that file?

Thanks

Comments

  • zibadianzibadian Member Posts: 6,349
    : I have managed to save the structure of a table in a text file. How can I read this file in, so I can take the first segment in each line and use it as a header on each column of the String Grid?
    : Also, what code can I use to search thru a text file to see how many lines are stored in that file?
    :
    : Thanks
    :
    The problem with text files is that you can only move to the front of the file or read 1 character or line. To count the lines, you need to use a while-do loop with inside it a readln() and a counter to store the number of lines. Another method is to create a temporary TStringList and store the file in there.
    As for taking parts of the file, I've posted a code in the CodePedia to take the ith part of a character delimited string. It is called StringSplit().
Sign In or Register to comment.