Recent

Author Topic: Basic HTML Generation...  (Read 13367 times)

commodianus

  • New Member
  • *
  • Posts: 18
Re: Basic HTML Generation...
« Reply #15 on: March 25, 2010, 11:54:49 pm »
Thanks again everyone. All accomplished.

commodianus

  • New Member
  • *
  • Posts: 18
Re: Basic HTML Generation...
« Reply #16 on: March 26, 2010, 12:19:09 am »
eny, would modifying your last bit of code to do <i>" and "</i> be very complicated? I didn't notice that at first, but I don't want to overstay my welcome either. :P
« Last Edit: March 26, 2010, 12:57:53 am by commodianus »

commodianus

  • New Member
  • *
  • Posts: 18
Re: Basic HTML Generation...
« Reply #17 on: March 26, 2010, 01:06:17 am »
This does the trick. Thanks all, really done this time.

Code: [Select]
procedure TForm1.Quote;
const C_BOOL2HTML_ITALIC: array[boolean] of string = ('<i>', '</i>');
var i      : integer;
    s      : string;
    InQuote: boolean;
    before, after : string;
begin
  Memo2.Lines.Clear;
  for i := 0 to Memo1.Lines.Count-1 do
  begin
    s := Memo1.Lines[i];
    InQuote := false;
   while pos('"',s) > 0 do
    begin
      s := StringReplace(s, '"', C_BOOL2HTML_ITALIC[InQuote], []);
      InQuote := not InQuote;
    end;
    if InQuote then
      s := s + C_BOOL2HTML_ITALIC[InQuote];
    Memo2.Append(s);
  end;
  Memo1.Text := Memo2.Text;

  Application.ProcessMessages;

  Memo1.Text := StringReplace(Memo1.Text, '<i>', '<i>"',
                          [rfReplaceAll, rfIgnoreCase]);

  Memo1.Text := StringReplace(Memo1.Text, '</i>', '"</i>',
                          [rfReplaceAll, rfIgnoreCase]);

end;
« Last Edit: March 26, 2010, 01:16:08 am by commodianus »

 

TinyPortal © 2005-2018