Re: {} Questions

Liste des GroupesRevenir à cl awk 
Sujet : Re: {} Questions
De : ben (at) *nospam* bsb.me.uk (Ben Bacarisse)
Groupes : comp.lang.awk
Date : 21. Aug 2024, 09:06:51
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <87o75mpaec.fsf@bsb.me.uk>
References : 1
User-Agent : Gnus/5.13 (Gnus v5.13)
porkchop@invalid.foo (Mike Sanders) writes:

Assuming any awk variant...
>
1. Is this valid? (it works with mawk, gawk, busy box awk)
>
   BEGIN { debug = 1 }
>
   (debug)  { code_here }
>
   (!debug) { code_here }
>
   END { ... }

Yes, that's valid.  You don't need the ()s round the expressions.

2. what is the name or accepted term in AWK for unamed functions,
main()?

I don't know what you mean.  Can you give an example?

It occurs to me that maybe you think

  (debug) { code }

is a function?  It's not.  It's just a normal pattern/action AWK pair.
An AWK pattern can just be an expression.  That expression is evaluated
for every input line and, if true, the corresponding action is executed.
You could have written

  debug != 0 { code }

instead.

--
Ben.

Date Sujet#  Auteur
21 Aug 24 * {} Questions9Mike Sanders
21 Aug 24 `* Re: {} Questions8Ben Bacarisse
21 Aug 24  `* Re: {} Questions7Mike Sanders
21 Aug 24   +* Re: {} Questions4Janis Papanagnou
21 Aug 24   i+- Re: {} Questions1Janis Papanagnou
21 Aug 24   i`* Re: {} Questions2Mike Sanders
22 Aug 24   i `- Re: {} Questions1Janis Papanagnou
21 Aug 24   `* Re: {} Questions2Ben Bacarisse
21 Aug 24    `- Re: {} Questions1Mike Sanders

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal