To automate stuff on windows pc im using an amazing tool called QuickMacros which can be found here (http://www.quickmacros.com).
Its programming language is not too hard and well documented and supported.
A function i use very often is 'Inline if'
It saves alot of lines and typing in complex codes and you dont have to bother enclosing anything.
It would be great to have it in AM script.
Here its documented: http://www.quickmacros.com/help/Functions/IDP_IIF.html
Could you add it?
Thanks alot!
Inline if
Moderator: Martin
Re: Inline if
"To bother enclosing anything" isn't necessary even now, apart from the tested condition itself.
is legal Automagic syntax.
Unix shells commonly allow constructs like
which need even less brackets, parentheses and the like.
Code: Select all
if (x) a;
Unix shells commonly allow constructs like
Code: Select all
x && a
Code: Select all
x || b
Last edited by Bushmills on 24 Jul 2016 06:58, edited 2 times in total.
Re: Inline if
I don't think this would be necessary. The way that is used here is so simple logic that it shouldn't be too hard to understand.
Case: If expression "x" returns true, execute "a", otherwise execute "b".
Quickmacro:
iif(x a b)
Automagic:
if (x) {a} ELSE {b};
I think the difference isn't large enough to make the need for added function. Also, the former can handle only single expressions and script blocks are strictly prohibited from it. That makes it usable only for very basic operations.
Case: If expression "x" returns true, execute "a", otherwise execute "b".
Quickmacro:
iif(x a b)
Automagic:
if (x) {a} ELSE {b};
I think the difference isn't large enough to make the need for added function. Also, the former can handle only single expressions and script blocks are strictly prohibited from it. That makes it usable only for very basic operations.
Re: Inline if
Quick scan of my uses of "if" indicates that about 80 to 90% of its uses is without "else". This is partly due to active avoidance.
Notice also that a construct, commonly written as
can alternatively be written as
Notice also that a construct, commonly written as
Code: Select all
if (x)
{
result = a
}
else
{
result = b
}
Code: Select all
result = if (x) a else b;
Re: Inline if
Thank you guys!
I didnt know u could put it all into a single line like:
result = if (x) {a} else {b}
I thought the curly brackets have to be in seperated lines and inside a for or while loop it uses alot of space and confused me more than once.. however,
this is perfect
result = if(x) a else b;
Thanks
I didnt know u could put it all into a single line like:
result = if (x) {a} else {b}
I thought the curly brackets have to be in seperated lines and inside a for or while loop it uses alot of space and confused me more than once.. however,
this is perfect
result = if(x) a else b;
Thanks
Re: Inline if
When using very long expressions or large script blocks, splitting them in different lines helps to maintain readability. There's no other function in that. In theory, you could write infinitely long script in a single line.