Author Topic: Conditional Evaluation using $if(){}{}  (Read 497 times)

Offline BackInTheSandbox

  • Multiple posting newcomer
  • *
  • Posts: 16
Conditional Evaluation using $if(){}{}
« on: March 04, 2020, 09:52:16 am »
Hello,
this is a follow-up on How to use Conditional Evaluation using $if(){}{}. I'm trying the same as the original poster. For testing purposes I currently use an abbreviation at "Settings" => "Editor..." => "Abbreviations".

With
Code: [Select]
$TARGET_NAME I get Debug or Release, depending on my Target.

But with
Code: [Select]
$if($TARGET_NAME == "Debug"){MYDEBUG}{MYRELEASE} I always get MYRELEASE.

I also tried:
Code: [Select]
$TARGET_NAME == Debug
Code: [Select]
$TARGET_NAME == 'Debug'The result is always the same.

The original thread mentions a bug, but I'm not sure about the discussion in the referred ticket. Is the bug fixed in Release 17.12?

TIA, BackInTheSandbox

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12739
    • Travis build status
Re: Conditional Evaluation using $if(){}{}
« Reply #1 on: March 04, 2020, 06:26:20 pm »
The bug has status "open", so it is not fixed anywhere.
Bluehazzard can tell if this is the same issue or this is something else.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BackInTheSandbox

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Conditional Evaluation using $if(){}{}
« Reply #2 on: March 04, 2020, 07:58:27 pm »
Too bad  ;)
Is there any other trick to implement a #define based on build target?I know that I can do that in the project's build options. But I'd prefer a project independent approach, i.e. in the code::blocks settings rather than the project settings.
CU,BackInTheSandbox

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2773
Re: Conditional Evaluation using $if(){}{}
« Reply #3 on: March 05, 2020, 03:53:29 pm »
Yes the bug is the same and it is still open, no comments, so i will commit it. This patch is not perfect but it is an improvement of infinite, because at the moment the if does not work at all ;)

You probably can use squirrel scripting to do what you want...
Code: [Select]
[[if(ReplaceMacros(_T("$TARGET_NAME")).Matches(_T("Debug"))){print("MYDEBUG");} else {print("MYRELEASE");}]]

Offline BackInTheSandbox

  • Multiple posting newcomer
  • *
  • Posts: 16
Re: Conditional Evaluation using $if(){}{}
« Reply #4 on: March 05, 2020, 04:04:32 pm »
Thanks, BlueHazzard!
That squirrel script works like a charm. I put it in the compiler settings under #defines and I get what I need.
CU,BackInTheSandbox