Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
What Custom Compiler messages can do for you Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
13-Jul-03
Category
Algorithm
Language
Delphi 6.x
Views
117
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Yoav Abrahami

One of the problems of working in a large project is that you need sometimes to 
mark certain places of you’re source code, remaining you of things you need to do. 
We can mark those places in the code, letting Delphi remind us of them.

Answer:

One of the problems of working in a large project is that you need sometimes to 
mark certain places of you’re source code, remaining you of things you need to do. 
There are a number of experts for Delphi that provide a to-do list, even one (nice 
one) that comes with Delphi. 

One think that always bugs me about having a separated list of To-Do items is that 
you have to go and look for it. You can just as well forget all about it, and it 
loses it’s purpose. Wouldn’t it be nice if we could tell the compiler to generate a 
message each time a code with To-Do items is compiled? 

Another thing is that a To-Do List is good for project level reminders, not a unit 
of even object level. You need a reference from the To-Do Item to the unit or 
object, some way of getting from the item to the code. 

I find that using custom compiler messages, I can get another way to remind me of 
what not to forget. It allows me to overcome the two inconveniencies above, letting 
me insert reminders directly into the code and letting the compiler remind me of 
them. 

The syntax for this command is 
1   
2   {$MESSAGE HINT|WARN|ERROR|FATAL 'text string' }
3   
4   //and some examples of it (taken from the Delphi help files) are: 
5   
6   {$MESSAGE 'Boo!'}emits a hint
7   {$MESSAGE Hint 'Feed the cats'}emits a hint
8   {$MESSAGE Warn 'Looks like rain.'}emits a warning
9   {$MESSAGE Error 'Not implemented'}emits an error, continues compiling
10  {$MESSAGE Fatal 'Bang.  Yer dead.'}emits an error, terminates compiler

One use of this directive that I find very useful is for TBD items – To Be Done. I 
use it to replace a To-Do list in this case. There are two advantages to this 
approach: 

You get a compiler message for each item, reminding you to deal with it. 
You can browse those messages with the Alt-F8, Alt-F7 keys. 

A Code with this directive can look like (just an example from a code I am writing 
right now): 

11  destructor TumbSelectionTempTable.Destroy;
12  begin
13    // Clear the temp tables.
14  {$MESSAGE Warn ' - remember to free all allocated objects'}
15    ClearAllOuterWorldFold;
16    if FSubjectsTempTableCreated then
17      DropTempTable(FTableName);
18  
19    FOuterWorldsFolded.Free;
20    FQuery.Free;
21    inherited;
22  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC