Author Topic: RemoveLnFile  (Read 1387 times)

0 Members and 1 Guest are viewing this topic.

Offline Railor

  • Major(1)
  • Posts: 16
RemoveLnFile
« on: March 15, 2008, 10:01:23 am »
Script Name: RemoveLnFile
Script Description: The script removes the specified line (first line is 0!) from the specified file.
Original Author(s): Railor
Core Version: 2.6.3
Code:
Code: [Select]
procedure RemoveLnFile(File: string; Line: integer);
var
splitted_file: TStringArray;
i: integer;
begin
if FileExists(File) then
begin
splitted_file := xsplit(ReadFile(File),chr(13)+chr(10));
if Line <= ArrayHigh(splitted_file) then
begin
WriteFile(File,'');
for i := 0 to Line-1 do
if splitted_file[i] <> '' then
WriteLnFile(File,splitted_file[i]);

for i := Line+1 to ArrayHigh(splitted_file) do
if splitted_file[i] <> '' then
WriteLnFile(File,splitted_file[i]);
end
end
end;
 

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: RemoveLnFile
« Reply #1 on: March 17, 2008, 01:14:56 am »
Can't be bothered trying to understand that code, but you need to give Keydon credit for using Xsplit :P
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs