Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Delphi Components Usage > D6: how to get ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 89 of 175
Post > Topic >>

D6: how to get one ctr from Richedit

by A man <uce@[EMAIL PROTECTED] > Nov 26, 2003 at 11:35 AM

I want to spell check words from a Richedit.Text but am having trouble 
in my GetWord routine. Here is the code. 

function GetWord(var p:integer):string;
{Get a word from Richedit1 starting at pos p.
Return changed p.
}
var s:string;
    c:char;
    i:integer;
begin
c:=midstr(Form1.Richedit1.text,p,1);
s:=''; //Beginning string
while (c in ['A'..'Z','a'..'z','-','1'..'0']) do //allowable ctrs.
    begin
    s:=s+c;
    inc(p);
    c:=midstr(Richedit1.text,p,1);
    end; //while
dec(p);
GetWord:=s;
end; //GetWord
{*******************************************************}
procedure TForm1.mnuSpell2Click(Sender: TObject);
var s:string;
    l,i,pos:integer;

begin
//Get a word, then check it.
pos:=0;
l:=length(Richedit1.text);
while (pos<l) do
    begin
    s:=GetWord(pos);
    if s=uppercase(s) then break; //Ignore all caps
    if ExecRegExpr('[0-9\.]+',s) then break; //Ignore all digits.
    if ExecRegExpr('[A-Z][a-z]+',s) then break; //Ignore initial capped 
words.
    if ExecRegExpr('[a-zA-Z]*[0-9]+[A-Za-z]*',s) then break; //Ignore 
words containing a digit. 
    janSpeller1.Spell(s);
    Richedit1.Seltext:=s;
    end;

end;

You will notice I want to skip certain types of words, so I have to 
check for those manually since my speller doesn't. But in GetWord, c is 
a char but midstr returns a string, thus I get a compile error (char 
and string incompatible or something). How do I get one char at a time 
from a Richedit1, while passing the current position pointer back from 
GetWord to mnuSpell2Click? 

Thanks.
-- 
Say no to fixed width tables. They look terrible!
 




 2 Posts in Topic:
D6: how to get one ctr from Richedit
A man <uce@[EMAIL PROT  2003-11-26 11:35:40 
Re: how to get one ctr from Richedit
"Bruce Roberts"  2003-11-26 12:19:31 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 18:33:44 CDT 2008.