Recent

Author Topic: Searching character by character of a RichMemo  (Read 314 times)

chiong

  • Newbie
  • Posts: 6
Searching character by character of a RichMemo
« on: November 06, 2025, 02:58:59 pm »
The attached picture is a set of data in richtext file. I am trying to extract the data one character at a time & test for the various fields such as comma or ":-" . However when I extract a single character & test it against the comma I got an error message.

Error message : Error : Operator is not overloaded : "Char" or "Longint"

What am I doing wrong ?  Thanks for any help given.

======
for i := 1 to TextLen  do
    begin
      // Select the current character
      ARichMemo.SelStart := i;
      ARichMemo.SelLength := 1;
      CurrentColor := ARichMemo.SelAttributes.Color;
      CurChar := ARichMemo.Lines.Text ;


      // Check if the color has changed
      if  CurChar =  chr(44) or i = TextLen then
      begin     
......
                 

rvk

  • Hero Member
  • *****
  • Posts: 6922
Re: Searching character by character of a RichMemo
« Reply #1 on: November 06, 2025, 04:05:24 pm »
      if  CurChar =  chr(44) or i = TextLen then
Aren't you forgetting the parentheses ( ( and ) ) here?

(And please use the code tag if you put code in your post. Now it's not visible that you used [ i ] after ARichMemo.Lines.Text )

Zvoni

  • Hero Member
  • *****
  • Posts: 3226
Re: Searching character by character of a RichMemo
« Reply #2 on: November 06, 2025, 05:07:44 pm »
And why are you running through a String comparing each character if it's a comma?
use StrScan or StrPos
Needs Unit "Strings"
https://www.freepascal.org/docs-html/rtl/strings/strscan.html
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018