truncate from down to up

how i can create function, which delete from file line which is first

whis delete line from last

  AssignFile(F, DBname);
  Seek(F, FileSize(F)-1);

I need the same but from first record to last
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

it takes longer because you have to move each record up.  One way is:

  AssignFile(F, DBname);
  for i := 0 to FileSize(f)-2 do begin
    Seek(F, i+1);
    Seek(F, i);
  Seek(F, FileSize(F)-1);

If the file is small, you can just read the whole file in, then write it out again (less the first record, of course).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
copy the last record over the first (or any before last) record,
and truncate the file as above

meikl ;-)
>>copy the last record over the first

That would work, but it wouldn't preserve the record order of the file, which I assumed was important.  

I like your thinking, though. :-)
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

usual i do so on sequential files,
because its the fast solution,
but as you stated, it will dissort the recordorder

take also a look to this q

meikl ;-)
To have best performance you should act in this way: put a flag in your rows and virtually delete a row with marking this flag.
when you want to phisically delete the records marked (shrink the file) you make a new file and copy all the records not marked to it.
And so...?..
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: roknjohn

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

Karamja (Alan)
EE Cleanup Volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.