Delete first line in a text file
Moderators: Dorian (MJT support), JRL
Delete first line in a text file
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
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.
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]
[email protected]