#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Location
    Cheltenham, UK
    Posts
    4
    Rep Power
    0

    Trying to delete lines from Memo


    Hello,

    Pretty new to Delphi, been self teaching myself for around a week now and already developed a project which is now in use for assistance at my work place.

    However, I am trying to make it a bit better and more focussed at a specific topic as currently it's like a general 'Fin in File' type of thing.

    I have hit a brick wall though, I can't spot the issue here:

    p : integer;

    for p:= 0 to memo2.lines.count-1 do
    begin
    if AnsiContainsText (memo2.lines[p], 'LINK')then
    try
    lineResult2 := memo2.Lines[p];
    Memo2.Lines.Delete[p];
    finally
    AssignFile(F,outputFile);
    if IOResult<>0 then Rewrite(F);
    {$I-} Reset(F); {$I+}
    ReWrite(F);
    WriteLn(F, Memo2.Text);
    CloseFile(F);
    end;

    The highlighted line is the line that's giving me an issue. Looking at XE5, it's saying 'Not enough actual paramaters'.

    Thanks in advance,

    Steve
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Location
    Cheltenham, UK
    Posts
    4
    Rep Power
    0
    This has now been solved.

    I have been informed that the delete function is the only one that uses parentheses instead of the square ones.

    Changed it to normal brackets and it's fine.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    354
    Rep Power
    7
    You know, you can replace all this
    Code:
          AssignFile(F,outputFile);
          if IOResult<>0 then Rewrite(F);
          {$I-} Reset(F); {$I+}
          ReWrite(F);
          WriteLn(F, Memo2.Text);
          CloseFile(F);
    with
    Code:
       Memo2.Lines.SaveToFile('<Full Path To File>.txt');
    obviously, replace <Full Path To File>.txt with the actual path and file name such as:

    C:\MyDocuments\MyFile.txt

    Comments on this post

    • AraCyanea agrees : Great help!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Location
    Cheltenham, UK
    Posts
    4
    Rep Power
    0
    Originally Posted by majlumbo
    You know, you can replace all this
    Code:
          AssignFile(F,outputFile);
          if IOResult<>0 then Rewrite(F);
          {$I-} Reset(F); {$I+}
          ReWrite(F);
          WriteLn(F, Memo2.Text);
          CloseFile(F);
    with
    Code:
       Memo2.Lines.SaveToFile('<Full Path To File>.txt');
    obviously, replace <Full Path To File>.txt with the actual path and file name such as:

    C:\MyDocuments\MyFile.txt
    I was unaware of this.

    I have used it and it's perfect. Before I was having issues with error coming up saying unable to locate the output file.

    Thank you very much.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    15
    Rep Power
    0
    Assign file and all that nonsense is largely redundant now for most cases. savetofile is a ton easier as well.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Location
    Cheltenham, UK
    Posts
    4
    Rep Power
    0
    Originally Posted by DLPB2
    Assign file and all that nonsense is largely redundant now for most cases. savetofile is a ton easier as well.
    Thank goodness is all I can say. I had multiple issues with it and it was the first thing I saw that worked so I used it (stupidly).

IMN logo majestic logo threadwatch logo seochat tools logo