Stef Merlijn
asked on
How to use IFDEF?
Hi,
In the source of some component some IFDEF is used.
I need to execute this code.
I've tried to add it:
- in the Directories/Conditionals of my project added: ADDIMG_CID;
- as {$define ADDIMG_CID} in the main unit
Both didn't work for me.
What do I need to do in order to activate this?
In the source of some component some IFDEF is used.
I need to execute this code.
I've tried to add it:
- in the Directories/Conditionals of my project added: ADDIMG_CID;
- as {$define ADDIMG_CID} in the main unit
Both didn't work for me.
What do I need to do in order to activate this?
{$IFDEF ADDIMG_CID}
if Copy(fnam, 1, 4) <> 'cid:' then
fnam := 'cid:' + fnam;
{$ENDIF}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I did do the following:
Added {$define ADDIMG_CID} to the implementation setting of the unit (no form)
Added the showmessage:
{$IFDEF ADDIMG_CID}
showmessage('ADDIMG_CID');
if Copy(fnam, 1, 4) <> 'cid:' then
fnam := 'cid:' + fnam;
{$ENDIF}
The message is not shown.
When I remove the IFDEF, then this code is correclty executed.
Added {$define ADDIMG_CID} to the implementation setting of the unit (no form)
Added the showmessage:
{$IFDEF ADDIMG_CID}
showmessage('ADDIMG_CID');
if Copy(fnam, 1, 4) <> 'cid:' then
fnam := 'cid:' + fnam;
{$ENDIF}
The message is not shown.
When I remove the IFDEF, then this code is correclty executed.
Place $define in your main form
Cheers
Cheers
ASKER
No that doesn't work either.
I can't imagin what is not working: your code is correct. Can you post the whole unit?
ASKER
When I add this code into my onshow-event, it works there.
{$IFDEF ADDIMG_CID}
showmessage('Test');
{$ENDIF}
But still not in the other unit.
{$IFDEF ADDIMG_CID}
showmessage('Test');
{$ENDIF}
But still not in the other unit.
ASKER
I can't as it is from a vender.
I need to ask them I guess.
I need to ask them I guess.
I'm not sure but I suspect you can only use that in the main form/unit. The unit in which you have to use these directives is only used by the main unit of your project or it is part of the project?
ASKER
The IFDEF in in a separate unit.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
As you can see in my initial question I already tried to set it in the project option.
Currently I've asked my question also at the vendor. I got no alternatives for now, except for comment out the IFDEF in the code itself. But that would meen maintenance whenever new releases are distributed.
Currently I've asked my question also at the vendor. I got no alternatives for now, except for comment out the IFDEF in the code itself. But that would meen maintenance whenever new releases are distributed.
What I meant was: the unit $ifdef is in is part of the project (have you added it to the project) or it is simply a unit placed in a registered path used by the main unit? What I'm thinking is that if that unit is not part of the project could not see the $define placed in the main unit...
ASKER
Yes I made a copy of the original unit and added it to the project.
This was basically done because I need to comment out these IFDEF in order to get it to work.
This was basically done because I need to comment out these IFDEF in order to get it to work.
Sorry for this stupid question, I don't want to offend you but... Are you sure yor project now uses the unit added to the project and not the external unit? Really, I don't see any reason for your code is not working, so I'm thinking about something little mistake not directly referred to your code (which is right).
Cheers
Cheers
ASKER
Yes, I'm sure it uses this unit. But even when I doesn't. If I don't comment-out the IFDEF, both units are exactly the same, so it wouldn't make any difference.
ASKER
Thank you all for help with this question.
{$IFDEF ADDIMG_CID}
showmessage('is ADDIMG_CID');
{$ENDIF}
Ifthe message appears, then the problem is in another place...