Delete first line in a text file

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
rostar
Newbie
Posts: 11
Joined: Fri Jan 24, 2003 12:46 pm
Location: Wells, ME USA

Delete first line in a text file

Post by rostar » Fri Jan 24, 2003 2:24 pm

I am currently experimenting with macro scheduler to create and read from a text file to work on a list of tasks. This currently works fine but... if the program that the macro is running crashes at some point I have to restart the script and it reads from the top of the list. Is there a way to delete the top line from the text file whenever it sucessfully completes that line so if a have to restart it does not duplicate the task? Currently I have to see what finished last and manually delete any completed tasks from the text file before I restart. Thanks :D

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Fri Jan 24, 2003 4:14 pm

Hi,

You can't delete a line - deleting a line is actually the same as copying all other lines to a new file and deleting old file and renaming new. This is no good in your case.

A better solution would be to write the line number to an INI file using EditIniFile (or use the registry - RegistryWriteKey) each time you read in a line:

[lines]
linenum=1

Then when your macro starts is looks at this (ReadIniFile) to determine which line to start from (add one to it) ...

I hope this gives you some ideas.
MJT Net Support
[email protected]

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts