($DEFINE) seems to stay within the one .pas file



is this the case? I use a unit in two projects and want some code not to
appear for the second project, so I did this:

some code
{$IFDEF MYVAR}
code to hide in project 2
{$ENDIF}
other code

Then, in project 1s .DPR file

unit1 in 'units\unit1.pas' {form1}
unit2 in 'units\unit2.pas' {form2}
unit3 in 'units\unit3.pas' {form3}
{$DEFINE MYVAR}
unit4 in 'units\unit4.pas' {form4}
unit5 in 'units\unit5.pas' {form5}
unit6 in 'units\unit6.pas' {form6}

unit 4 is the aforementioned code. As I understand it, if that $DEFINE is
not there, then that $IFDEF code should not be compiled and if I add that
$DEFINE, and it shouldn't matter where, then the code compiles again...

But, it appears that this is not the case and only adding the $DEFINE to the
top of unit4 will it work. This means I have to edit unit4 everytime I
compile project1 or project2? Is there another way to do this without
saving a separate unit4.pas and having concurrent almost identical files to
update?

tia,
cj


.