This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Where is igawk and why doesn't @include replicate this feature?


On Wed, 11 Sep 2019 16:54:49, Troy Kenah wrote:
I used to embed @include junk.awk statements to reduce repetitive code but
this no longer works. These were files were not functions, simply code
snippets; this is the type of error I am now seeing:

gawk: get_FY2019Q1OIC.awk:28: @include "../inc/segments.awk"
gawk: get_FY2019Q1OIC.awk:28:  ^ syntax error
gawk: get_FY2019Q1OIC.awk:36:         fromdate=mktime("2019 09 01 00 00 00")
gawk: get_FY2019Q1OIC.awk:36:                         ^ syntax error
gawk: get_FY2019Q1OIC.awk:36:         fromdate=mktime("2019 09 01 00 00 00")
gawk: get_FY2019Q1OIC.awk:36:
 ^ 0 is invalid as number of arguments for mktime

Works fine here:

   $ gawk --version
   GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2)

   $ cat one.awk
   function f1(n1) {
      return n1 + 10
   }

   $ cat two.awk
   @include "one.awk"
   BEGIN {
      print f1(20)
   }

   $ unset POSIXLY_CORRECT
   $ gawk -f two.awk
   30

Finally, I would make a suggestion. "@include" is not POSIX, so if you find
yourself relying on something like this more and more, it might be better to
switch to a proper programming language. Something like Perl, Lua or Tcl.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]