Page 1 of 1

Expression Help

Posted: 22 Mar 2012, 16:35
by ChrisFlye
Hi all,

I'm trying to get a boolean output from a string expression. Simply, if there is no text (null) give me 1, if there is some text give me 0. I'm using the following but to no avail.

A == "" ? 1 : 0

How do I express a null value in a String Expression?

I'm getting 'cannot convert int to string'.

Thanks,
Chris

Re: Expression Help

Posted: 23 Mar 2012, 10:33
by squiggle
Does it have to be an expression? I'd just use the "String Length" node, you feed the string into it and it gives you a number of informative outputs, among them a boolean as to whether the string is empty.

http://www.ventuz.com/support/help/late ... tions.html

Re: Expression Help

Posted: 23 Mar 2012, 10:41
by Daniel Willer
You can use the IsNullOrEmpty() method.
Your Int expression should look like that: String.IsNullOrEmpty(A) ? 1:0
Check MSDN for further information.

By the way you cannot output a 0 or 1 in a string expression because the result has to be a string. But you can add a string arguement via the CustomModel to an Integer Expression.

Cheers!

Re: Expression Help

Posted: 23 Mar 2012, 19:42
by ChrisFlye
Both of those were useful. Sorted!

Thanks a lot!

Re: Expression Help

Posted: 26 Mar 2012, 16:20
by dodgygizmos
goats cheese :-)