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

Re: [NTS] Redirecting GAWK Output

Expand Messages
  • flo.gehrke
    ... Thanks, Robert! I see that last version working and getting to the result that you had in mind. Actually, I never talked of inserting the result into the
    Message 1 of 16 , May 17 12:17 PM
    • 0 Attachment
      --- In ntb-scripts@yahoogroups.com, Robert Bull <barlennan@...> wrote:
      >
      > Kees' script does the job (...) I have a section titled Scripts in
      > my clipbook, beneath the section of ordinary clips. In the Scripts
      > section I have a clip entitled "Kees AWK script". It contains my
      > version of Kees' script:
      >
      > Kees AWK script
      > ----------------
      > BEGIN { max = 0 + 0 }
      > # echo input to original file
      > {
      > print
      > }
      > # the rest of the script
      > {
      > if(length($0) > max){
      > max = length($0)
      > }
      > }
      > END { printf("max line length is %d", max) }
      > ----------------
      > Notice there aren't any references to files or file names at all.

      Thanks, Robert!

      I see that last version working and getting to the result that you had in mind.

      Actually, I never talked of inserting the result into the active document. The goal was...

      - To have that list (source text) open

      - to run a clip which calls GAWK and starts a GAWK script which calculates the length of the longest line

      - to redirect the result from GAWK back into the NT clip

      - to continue clip execution with that data, i.e., in this case, just the value '16'.

      In this context, I mentioned the clipboard only as a target for redirecting the GAWK output. The idea was, to continue clip execution, for example, with displaying the result in an infobox that could call the clipboard with...

      ^!Info The longest line has ^$GetClipboard$ characters

      Meanwhile, we saw approaches how to redirect the GAWK output to the clipboard (with MS Clip.exe). Also, how to direct the input into GAWK from the clipboard (with gclip.exe from UnxUtils). This could be of interest in cases where we send data from NT to the clipboard, process them with GAWK, and redirect the result via the clipboard back into a clip execution.

      So far, we didn't see a solution for this redirection (to clipboard/from clipboard). That's why I remembered my message #557.

      If you still have the patience to spend some time with that subject -- please have a look at the latest messages. It's all in the NT Scripts Group on Yahoo -- or in your incoming emails ;-)

      Regards,
      Flo
    • Robert Bull
      Hello, flo.gehrke; Thursday, May 17, 2012, 8:17:01 PM, you wrote: fg I see that last version working and getting to the result that you fg had in mind. What
      Message 2 of 16 , May 17 1:34 PM
      • 0 Attachment
        Hello, flo.gehrke;

        Thursday, May 17, 2012, 8:17:01 PM, you wrote:

        fg> I see that last version working and getting to the result that you
        fg> had in mind.

        What a pity it wasn't what *you* had in mind. I might have known I'd
        get the wrong end of the stick... still, it was a fun play session.


        --
        Regards,

        Robert Bull
        mailto:barlennan@...
      • Kees Nuyt
        ... PRINT is not the same as print . gawk is case-sensitive. -- Regards, Kees Nuyt
        Message 3 of 16 , May 17 1:51 PM
        • 0 Attachment
          On Mon, 14 May 2012 16:17:09 -0000, you wrote:

          > 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 }

          PRINT is not the same as print .
          gawk is case-sensitive.


          --
          Regards,

          Kees Nuyt
        Your message has been successfully submitted and would be delivered to recipients shortly.