comptibility with gawk solved...


  • Anonymous


    I'm very impressed with awka and I will probably start to use it more and more where I used to use gawk..

    Anyway I have discovered some differences between the two.. and if anyone is interested some solutions:
    1. Awka doesn't seem to flush stdout after a printf like gawk does.. solution simoly add c call : fflush(stdout); afer printf !!
    2. length of array doesn't work in awka.. solution use awka alength or asort..
    3. strtonum doesn't exist in awka.. workaround: force to number by adding 0.. (doesn't give exactly the same result but suffices in most situation)

    Ideally I would like awka to be 100% compatible with gawk but the differences are to my knowledge very few.. Still it would be nice to be able to run scripts written for awka without change using gawk (If awka is unavailable and installing it is not an option..) so I would really like a method for the script to know at runtime if it run by gawk or awka.. does anyone have an idea how to go about this problem? Is it even possible?

    Lets keep the star awka alive!!


  • Anonymous


    Replying to my own question..

    There might be a way to discern if the script is run by gawk or awka.. (or at least by gawk and someother awk..)

    if (PROCINFO["version"]) { print "GAWK" } else { print "AWKA

    " }

    This seems to work.. It might be extended to include awk and nawk specific code to fine tune the platform detection.. (a bit like old style browser detection..)

    Awka shines brighter and brighter!!

  • Andrew

    I'm glad you found a solution.  Awka, from a development point of view, hasn't been alive for nearly 10 years now.  Every now & then I look at what needs doing, and the list of fixes and improvements quickly scares me, so I put awka back into the bottom drawer for another day :)


  • Anonymous


    Andrew the man. I'm honoured!

    I know awka has been in the bottom drawer for a long time now and although this saddens me I still find awka mature and well worth using.

    I use it mainly for the speed advantage, although gawk is fast awka is so much faster that the time spent on making programs work and complie in awka is well spent time. I also suspect that speed might be a bit addictive, and it sure gives me a thrill to see my old gawk programs run up to ten times faster or more…

    So I endevour to compile all my old gawk programs for awka.. and so far so good.. It takes a little bit of tinkering but I have not yet discovered an insurmountable obstacle..

    The solution above does work for simple stuff but wont compile when using what awka deems illegal code.. for example:

    if (PROCINFO["version"]) { len=length(array) } else { len=alength(array) }

    won't compile… !!

    I now use a small "preprcessor" awka program to work around this..I just delete (or keep) blocks of code depending on what version I want .. very simple and very effective…