I am working on a material report. Currently it checks the material name, and if it matches returns a string, if not it's blank. Here is some sample code:
{ IIF ((Materials.Material_Name = ".79(B) WHT MEL w/ 1S PL-1"), "[ NO ]" , "")}
{ IIF ((Materials.Material_Name = ".25(B) WHT MEL (*ST*)"), "[ MAYBE ]", "")}
{ IIF ((Materials.Material_Name = ".03125(B) PL-2"), "[ YES ]", "")}
I know returning each line adds a return in the report. My question is: Is there any way to add a return in the expression code for readability's sake, without adding a return in the report?
Trouble with expressions adding new lines.
-
- Posts: 2
- Joined: Wed Aug 30, 2017 2:12 pm
Re: Trouble with expressions adding new lines.
Hi Jcathorall,
As a workaround in this case you could use a GetValue event of the Text component as follows:
Thank you,
Edward
As a workaround in this case you could use a GetValue event of the Text component as follows:
Code: Select all
e.Value =
ToString(IIF (Materials.Material_Name = ".79(B) WHT MEL w/ 1S PL-1"), "[ NO ]" , "")) +
ToString(IIF(Materials.Material_Name = ".25(B) WHT MEL (*ST*)"), "[ MAYBE ]", "")) +
ToString(IIF(Materials.Material_Name = ".03125(B) PL-2"), "[ YES ]", ""));
Edward
-
- Posts: 2
- Joined: Wed Aug 30, 2017 2:12 pm
Re: Trouble with expressions adding new lines.
Ok, for me your code evaluates as a string. I can't get it to evaluate the expressions.
At one point by adding curly braces and fixing the brackets in the IIF statement I got it to evaluate as:
1 0.76 BLACK MELAMINE 47 97
[NO]+
+
;
;
1 0.76 WHITE MELAMINE 47 97
+
+
;
;
I can't replicate that though, I changed something and I'm not sure what exactly it was.
It was some thing like:
At one point by adding curly braces and fixing the brackets in the IIF statement I got it to evaluate as:
1 0.76 BLACK MELAMINE 47 97
[NO]+
+
;
;
1 0.76 WHITE MELAMINE 47 97
+
+
;
;
I can't replicate that though, I changed something and I'm not sure what exactly it was.
It was some thing like:
Code: Select all
{e.Value =
ToString( { IIF((Materials.Material_Name = "0.76 BLACK MELAMINE"), "[ NO ]" , "")}) +
ToString( { IIF((Materials.Material_Name = ".25(B) WHT MEL (*ST*)"), "[ MAYBE ]", "")}) +
ToString( { IIF((Materials.Material_Name = ".03125(B) PL-2"), "[ YES ]", "")});}
Re: Trouble with expressions adding new lines.
Hi Jcathorall,
The following approach will definitely work in all the cases. Let's say our expression is something simple, like this:
And in the GetValue event the code will look like follows:
Or, if using e.Value as per your suggestion, it would look like this:
Please check the video on how this can be easily achieved in 3 different approaches.
https://youtu.be/QmZS9p81qYM
Thank you,
Edward
The following approach will definitely work in all the cases. Let's say our expression is something simple, like this:
Code: Select all
{IIF(1<2, "1", "2")}{IIF(1<2, "A", "B")}
Code: Select all
e.Value =
ToString(IIF(1<2, "1", "2")) +
ToString(IIF(1<2, "A", "B"));
Code: Select all
{e.Value =
ToString(IIF(1<2, "1", "2")) +
ToString(IIF(1<2, "A", "B"))}
https://youtu.be/QmZS9p81qYM
Thank you,
Edward