Loading ...
Sorry, an error occurred while loading the content.

555Re: Redirecting GAWK Output

Expand Messages
  • mycroftj
    May 14, 2012
    • 0 Attachment
      --- In ntb-scripts@yahoogroups.com, "flo.gehrke" <flo.gehrke@...> wrote:
      >
      > Hi GAWK experts!
      >
      > I can clearly see how to run a GAWK script from a NT clip. But I get into trouble whith redirecting GAWK output to a clip. Example:
      >
      > Given some lines...
      >
      > Adelaide
      > Adria
      > Karkonjafarabadi
      > Karolyne
      > Rob
      >
      > In my naive view, there should be a solution that redirects the GAWK result directly to the clipboard or a variable so the clip could call the result from there.
      >
      > Thanks for advice!
      >
      > Flo
      >


      OK. I've spent all morning trying to come up with a solution.
      I've never done this before and have a few questions to work through on my journey.


      Why does using GetOutput give me the "fstat < 0: fd = 0" line where as GetInputOutput does not?

      Why does running the GAWK code in a NT clip execute the PRINT statement but calling external files with GetOutput, GetInputOutput or running from DOS does not? (They just give me the output 16 and not the data lines in the input file.)

      Why does END { print max | command } work (when setting 'command' to 'clip' in BEGIN but END { print max | clip } does not work??



      C:\Program Files (x86)\GnuWin32\bin\gawk.exe
      C:\Program Files (x86)\NoteTab Light\Scripts\script.awk
      C:\Users\user\Documents\input.txt

      Entering this in DOS returns 16
      gawk.exe -f "C:\Program Files (x86)\NoteTab Light\Scripts\script.awk" "C:\Users\user\Documents\input.txt"

      Running this clip
      ^!Info ^$GetOutput(^$GetGawkExe$ -f "^$GetScriptPath$script.awk" "^$GetDocumentPath$input.txt")$
      gives me
      fstat < 0: fd = 0
      16
      Why don't I see the lines output by PRINT?


      Running this clip
      ^!Info ^$GetInputOutput(^$GetGawkExe$ -f "^$GetScriptPath$script.awk" "^$GetDocumentPath$input.txt")$
      gives me
      16
      Why don't I see the lines output by PRINT?


      GAWK Subroutine called in NT clip:
      This leaves all the original document lines followed by 16 on the last line. All text is selected by clip.
      # Find size of longest line
      {
      print $0
      if (length($0) > max) { max = length($0) }
      }
      END { print max }


      SCRIPT.AWK
      ----------
      # Find size of longest line
      {
      PRINT $0
      if (length($0) > max) { max = length($0) }
      }
      END { print max }


      INPUT.TXT
      ---------
      Adelaide
      Adria
      Karkonjafarabadi
      Karolyne
      Rob

      Thanks,
      Joy
    • Show all 16 messages in this topic