read text file

roshanthaparoshanthapa Member Posts: 90
I want to read a previous lines of the text file.


How do I read the previous lines from a text file line by line? ( the situation is same as when textmode is on and we read line by line. But I need to read line by line in reverse like line no. 10 read first, then line no. 9 then 8 then 7 then 6, like that) ....

Comments

  • flfl Member Posts: 184
    create a table with fileds line no and text. Read file directly into table. Then start logic from table instead of from file.
    Francois
    Consultant-Developper

    http://www.CreaChain.com
  • roshanthaparoshanthapa Member Posts: 90
    Thanks fl. Very good reply, I appreciate that.

    But the field in the table with datatype:text can hold only 250 characters at most but I have 1024 characters in some lines so I won't be able to store that much characters in the field in a table.

    So I don't think it is wise to store each line of text file into a table. Yeah we can break down each line of text file and store it in a table.

    Is there any other solution or better than what I thought?
  • ara3nara3n Member Posts: 9,256
    Hello you can also use an array.

    write all of the text to 1024 text array. and then loop backwards.


    I := ArrayLen(MyArray);
    while I < 1 Do begin
    dostuff(Myarray);
    I -= 1;
    end;
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.