Hello.
Im trying to use something like
Output := email . “@” . domain . If(email == examplemail) isvalid = true . ”,” . isvalid
The expected result in output should be:
[email protected],true
But i cant make it to work, tried several ways and none worked.
Any helps? Thank you
If inside expression? Topic is solved
Re: If inside expression? Topic is solved
One problem is your curly quotation marks (“ ”) instead of straight quotation marks (" "). Another is that you can't put an if statement in the middle of an expression, but you can use the ternary operator:
Using your example:
Operators in Expressions wrote:Ternary operator [v1.0.46+]. This operator is a shorthand replacement for the if-else statement. It evaluates the condition on its left side to determine which of its two branches should become its final result. For example, var := x>y ? 2 : 3 stores 2 in Var if x is greater than y; otherwise it stores 3. To enhance performance, only the winning branch is evaluated (see short-circuit evaluation).
Using your example:
Code: Select all
email := "examplemail"
domain := "gmail.com"
Output := email . "@" . domain . (email = "examplemail" ? ",true" : "")
MsgBox, % Output
Re: If inside expression?
Probably the curly quotes is because i wrote this post on the iphone
Thank you so much !! This is what I was looking for! Didn’t know about the existence of this ternary operator, it looks like a problem solving for many of my scripts where I have lots of lines.
Thank you so much !! This is what I was looking for! Didn’t know about the existence of this ternary operator, it looks like a problem solving for many of my scripts where I have lots of lines.