Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 380
  • Last Modified:

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?
{$IFDEF ADDIMG_CID}
          if Copy(fnam, 1, 4) <> 'cid:' then
            fnam := 'cid:' + fnam;
{$ENDIF}

Open in new window

0
Stef Merlijn
Asked:
Stef Merlijn
3 Solutions
 
Marco GasiFreelancerCommented:
You have to to add in your implementation section this

{$define ADDIMG_CID}



0
 
Lester_ClaytonCommented:
If you trace from a few lines above this IFDEF - can you see if it's actually even getting to this block - and if it does get to it, does it just jump over it?

The code looks correct, so I'm wondering if it's even getting to the block in which this IFDEF is sitting.
0
 
Marco GasiFreelancerCommented:
Sorry I was too fast (and superficial) in answering... Are you sure the code within $IFDEF clause is correct? Try to place a showmessage, something like

{$IFDEF ADDIMG_CID}
  showmessage('is ADDIMG_CID');
{$ENDIF}

Ifthe message appears, then the problem is in another place...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Stef MerlijnDeveloperAuthor Commented:
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.
0
 
Marco GasiFreelancerCommented:
Place $define in your main form

Cheers
0
 
Stef MerlijnDeveloperAuthor Commented:
No that doesn't work either.
0
 
Marco GasiFreelancerCommented:
I can't imagin what is not working: your code is correct. Can you post the whole unit?
0
 
Stef MerlijnDeveloperAuthor Commented:
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.
0
 
Stef MerlijnDeveloperAuthor Commented:
I can't as it is from a vender.
I need to ask them I guess.
0
 
Marco GasiFreelancerCommented:
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?
0
 
Stef MerlijnDeveloperAuthor Commented:
The IFDEF in in a separate unit.
0
 
Ephraim WangoyaCommented:
try in the project options

defines.JPG
0
 
Stef MerlijnDeveloperAuthor Commented:
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.
0
 
Marco GasiFreelancerCommented:
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...
0
 
Stef MerlijnDeveloperAuthor Commented:
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.
0
 
Marco GasiFreelancerCommented:
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
0
 
Stef MerlijnDeveloperAuthor Commented:
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.
0
 
Stef MerlijnDeveloperAuthor Commented:
Thank you all for help with this question.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now