Author Topic: How to use Conditional Evaluation using $if(){}{}  (Read 3084 times)

Offline Napoleon

  • Multiple posting newcomer
  • *
  • Posts: 59
How to use Conditional Evaluation using $if(){}{}
« on: July 07, 2017, 03:19:51 pm »
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:

Code
$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.

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


Cheers,
Nap.
« Last Edit: July 07, 2017, 04:00:28 pm by Napoleon »

Offline Napoleon

  • Multiple posting newcomer
  • *
  • Posts: 59
Re: How to use Conditional Evaluation using $if(){}{}
« Reply #1 on: July 07, 2017, 04:48:45 pm »
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(){}{}?

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

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: How to use Conditional Evaluation using $if(){}{}
« Reply #2 on: July 09, 2017, 10:41:02 pm »
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

Offline Napoleon

  • Multiple posting newcomer
  • *
  • Posts: 59
Re: How to use Conditional Evaluation using $if(){}{}
« Reply #3 on: July 12, 2017, 06:33:41 pm »
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!