Results 1 to 5 of 5

Thread: Get 20 last items in a textfile??

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    50

    Get 20 last items in a textfile??

    My my isn't working correctly right now... How do I the easiest way get the 20 last items in a text file?

    Big thanks!

  2. #2
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    20 last items of...what? A listbox? An array? A Grid?
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    By "the 20 last items" do you mean the last 20 rows of text?
    If every line is separated with a newline then use the Split function to get an array with each line in it.

  4. #4

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    50
    In the textfile there are hundreds or even thousands of values. It could look like this:

    5,4,3,8,66,44,3,4,5

    I am only interested in the last twenty of these. I guess I can use spilt to make an array.

  5. #5
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    You can try this:

    Dim Values(20) as String
    Dim FromFile As (whatever the values are, perhaps Integer)
    Dim I as Byte

    ' file 1 must already be open
    Do until EOF(1)
    Input #1, FromFile
    For I = 1 to 19
    Values(I) = Values(I + 1)
    Next I
    Values(20) = FromFile
    Loop



    This should end up with the last 20 items. It might be slow on Really big files, but it should do the job.
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width