MPP-language-blender icon indicating copy to clipboard operation
MPP-language-blender copied to clipboard

check if value of variable equals some constant

Open agarwal opened this issue 11 years ago • 3 comments

I want to do:

mpp -set x=true foo.mpp
mpp -set x=false foo.mpp

and then in foo.mpp, do something like

{{if (( get x )) = true
  Got true.
}}
{{if (( get x )) = false
  Got false.
}}

Is there some way to do the above?

agarwal avatar Mar 07 '14 15:03 agarwal

On Fri, 7 Mar 2014 07:59:38 -0800, Ashish Agarwal wrote:

I want to do:

mpp -set x=true foo.mpp mpp -set x=false foo.mpp

and then in foo.mpp, do something like

{{if (( get x )) = true Got true. }} {{if (( get x )) = false Got false. }}

For a simple true/false you can use

{{ ifdef x X is defined }} {{ ifndef x X is not defined }}

and then set (or not) “x”.

Chris00 avatar Mar 07 '14 16:03 Chris00

I chose a bad example. I meant for non-Boolean types. I'm doing exactly what you suggest for Booleans.

agarwal avatar Mar 07 '14 17:03 agarwal

Since MPP doesn't currently have value comparison (I do hope to implement something for that in the next 7 weeks), you'd have to use ifcmd if you really need to compare strings in a similar way.

Currently, if you need more powerful features, I suggest you use what I showed in http://pw374.github.io/posts/2013-10-03-20-35-12-using-mpp-two-different-ways.html#Example2usingOCamlasapreprocessorlanguage

pw374 avatar Mar 07 '14 17:03 pw374