Board index » delphi » OpenTools API BeforeCompile: access violations on code completion

OpenTools API BeforeCompile: access violations on code completion


For some time I've been wanting to preprocess my Delphi files prior to
compilation, to overcome Delphi limitations and/or to make them more

For example, the following is not accepted by Delphi:

Case string of
   'first':          A:=1;
   'second':     A:=2;
   'third':         A:=3;

In the end I want my preprocessor to translate this into a nested IF/End
Else IF/End Else If .... statement.

When implementing BeforeCompile in the OpenTools API, I can run my
preprocessor on every compile. However it turns out BeforeCompile is also
invoked for code completion-- and what's worse, I keep getting access
violations on code completion even though the preprocessor code itself isn't
called. Strange enough all works fine when I am doing a 'build'. Sometimes,
after a new save/rebuild/reinstall package/restart Delphi, things seem to
work right again... and the next time I run Delphi I once again get access
violations. This is driving me wild... :(

What i need to know is:
* What is causing these errors? Are there specific things I should or
shouldn't do while implementing BeforeCompile?
* Is there a way to see the difference between a 'code completion compile'
and a 'real' compile?

Hoping to find a solution,



Re:OpenTools API BeforeCompile: access violations on code completion

Hi all...

I have a strong suspicion that all these problems are caused by the boolean
parameter 'IsCodeInsight' in both Beforecompile and Aftercompile that has
been added in Delphi 5. Any comments on how to make sure?


Other Threads