News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

How to use Conditional Evaluation using $if(){}{}

Started by Napoleon, July 07, 2017, 03:19:51 PM

Previous topic - Next topic

Napoleon

Hi,

Before I go to the full scripting option, I would like to try the Variable Expansion using conditional evaluation, that I see mentioned in the documentation:

$if(condition){true clause}{false clause}

How is the 'condition' statement formed?  Is it possible to use '==' or '!=' or other forms of comparison here?  I've worked out that the 'true' and 'false' words in the syntax example should not be included in my expansion (unless I desire those words in the output).

What I'm actually wanting to do is compare $TARGET_NAME to a specific target name string, and set the build target's parameters accordingly.

bmake $if($TARGET_NAME == 'geode-local'){robot-local GEODE_BUILD=yes}{$TARGET_NAME}


Cheers,
Nap.

Napoleon

I have been able to achieve this using the [[ ... ]] notation, however it is very messy compared to what I was hoping to achieve above.  Is it possible to do this using $if(){}{}?

bmake [[ if (GetProjectManager().GetActiveProject().GetActiveBuildTarget().Matches(_T("geode-local"))) print("robot-local GEODE_BUILD=yes"); else print(GetProjectManager().GetActiveProject().GetActiveBuildTarget()); ]]

BlueHazzard

i checked your problem and found a bug in codeblocks:
https://sourceforge.net/p/codeblocks/tickets/520/

with this bug it is not possible to use macros in the $if(){}{} construct.
After this bug is fixed i will look future in your problem

Napoleon

Nice to hear and look forward to the fix.
In my case though, the bug pushed me into the scripting side of things, which has been an awesome adventure!