[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: missing in manpage
From: |
Dave B |
Subject: |
Re: missing in manpage |
Date: |
Fri, 15 May 2009 17:59:42 +0200 |
User-agent: |
Thunderbird 2.0.0.21 (X11/20090420) |
Meller, Thomas wrote:
> Hello altogether,
>
> today I was searching a way to branch through 3 variants.
>
> The 'if'-statement does not describe this option.
> A colleague told me about 'else if (statement) {}', and it worked.
>
> I'd include it, it's missing in the man page.
It's not a new statement, nor an option. It's just a combination of "else"
and "if", which are both in the man page.
The syntax is
if(foo) statement1; else statement2
but of course statement2 can be an "if" as well:
if(foo) statement1; else if(bar)dosomething
and you can then add an "else" to THAT if (not the first one):
if(foo) statement1; else if(bar) dosomething; else defaultaction
The bottom line is that it's not "elseif", "elif", or something like that,
which then would actually be a separate, different, statement; it's just
"else" + "if".
Btw, that construct can be used to go through an arbitrary number of tests,
not just three.
Depending on how it was built, your version of GNU awk might even support
the switch/case construct.
--
D.