User forums > Using Code::Blocks
How to use Conditional Evaluation using $if(){}{}
(1/1)
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:
--- Code: ---$if(condition){true clause}{false clause}
--- End code ---
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}
--- End code ---
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(){}{}?
--- Code: ---bmake [[ if (GetProjectManager().GetActiveProject().GetActiveBuildTarget().Matches(_T("geode-local"))) print("robot-local GEODE_BUILD=yes"); else print(GetProjectManager().GetActiveProject().GetActiveBuildTarget()); ]]
--- End code ---
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!
Navigation
[0] Message Index
Go to full version