Jesse van Oort heeft geschreven in bericht <75g3u3$4i...@reader1.wxs.nl>...
|
|
|Hello,
|
|I'm trying to make an editor , and I don't know how to do the following:
|Every time you type a word, I'd like the editor to check if the typed word
|is a reserved word, such as 'If...then...else', 'string' or 'end', and
then
|make the specific word bold or blue or whatever, as many editors do.
|The reserved words are kept in a table or array and I think one way of
|accomplishing the routine would be to check the table each time you enter
a
|space (each time you enter space means you just finished a word).
|I've been struggling with this problem for a while now. Can anyone help me
|out?
|The preffered language would be Pascal, since I use Delphi3 Pro to build
the
|editor.
|
|Since I'm not always able to receive newsgroups, please reply (also) by
|email.
|Many thanks in advance.
|
|Jesse
|
Jesse:
Just some ideas.
1. Store all keywords in a regular textfile ( one keyword per line )
2. At startup, load a Tstringlist from this file
...
private
KeyWordList : TStringList;
...
KeyWordList := TStringList.Create;
try
KeywordList.LoadFromFile( 'keywords.txt');
except
< Oops! >
end;
...
< do KeyWordList.Free when your app quits >
...
3. To search whether a word input by the user is in the list,
use the IndexOf() method of TStringList.
var
InputWord : string;
...
if KeyWordList.IndexOf( InputWord ) > -1 then
< It is a keyword, do your thing here >
else
< Is not a keyword >
...
Regards,
Dirk Claessens
______________________________________________
dirk.claess...@village.ZZuunet.be
dirk.claessens...@belgium.ZZagfa.com
Mailheader was forged to fight spam !
Use the above and remove ZZ
______________________________________________