Recent

Author Topic: [solved] Issues was wrong file Too close to the trees to see the forest  (Read 422 times)

What I can do

  • Full Member
  • ***
  • Posts: 152
OS:Windows 10@64
Compiler: Lazarus 3.8
Project: Searching for words with in a TRichMemo document.
Every search works flawless except two
Document is a any standard Lazarus PAS file
Code: Pascal  [Select][+][-]
  1.  L:=RichMemo2.Search('private',0,Length(RichMemo2.rtf),[]);
  2. //retuns -1
  3.  L:=RichMemo2.Search('public',0,Length(RichMemo2.rtf),[]);
  4. //returns -1
  5.   L:=RichMemo2.Search('procedure',0,Length(RichMemo2.rtf),[]);
  6. //returns 1830 in my test document
  7.   L:=RichMemo2.Search('type',0,Length(RichMemo2.rtf),[]);
  8. //returns 387 in my test document
  9.  
  10.  
Update:
 I'm don't know if it's RichMemo2 or Lazarus because
Code: Pascal  [Select][+][-]
  1.   L:=AnsiPos('private',RichMemo2.Lines.Text);
  2.   L:=PosEX('private',RichMemo2.Lines.Text,1);
  3.   L:=Pos('private',RichMemo2.Lines.Text);
  4.  
  5. //all returns 0
« Last Edit: February 07, 2025, 01:04:47 am by What I can do »

What I can do

  • Full Member
  • ***
  • Posts: 152
Re: I think TrichMemo has a bug in search
« Reply #1 on: February 07, 2025, 12:32:04 am »
tried to work around but it still too buggy
Code: Pascal  [Select][+][-]
  1.   for L:=0 to 300 do
  2.     begin
  3.      str:=RichMemo2.Lines[L];
  4.      i:=AnsiPos('private',Str); //never a successful test
  5.      if I>0 then
  6.       showmsg('good');
  7.     end;

What I can do

  • Full Member
  • ***
  • Posts: 152
Re: Lazarus 3.8 is too buggy.
« Reply #2 on: February 07, 2025, 12:46:26 am »
interesting both of these return correctly
Code: Pascal  [Select][+][-]
  1. L:=Pos('private','this has the word private');
  2.   L:=ansipos('private','this has the word private');
  3. // both return 19

so I'm leaning on the fault being TRichMemo
« Last Edit: February 07, 2025, 12:47:58 am by What I can do »

What I can do

  • Full Member
  • ***
  • Posts: 152
Re: Lazarus 3.8 with TRichMemo is too buggy
« Reply #3 on: February 07, 2025, 01:03:09 am »
Nope it's all my fault!
My boo boo
and after walking through line by line I finally found it

 

TinyPortal © 2005-2018