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

Re: [NTS] Redirecting GAWK Output

Expand Messages
  • Robert Bull
    Hello, flo.gehrke; Monday, May 14, 2012, 11:53:02 PM, you wrote: fg Nevertheless, I m looking forward to see a solution where a fg selection from the active
    Message 1 of 16 , May 16 1:35 PM
    • 0 Attachment
      Hello, flo.gehrke;

      Monday, May 14, 2012, 11:53:02 PM, you wrote:

      fg> Nevertheless, I'm looking forward to see a solution where a
      fg> selection from the active document is copied to the clipboard and
      fg> GAWK is taking the contents of the clipboard as input data -- see
      fg> my latest reply to Joy with that link to comp.lang.awk.

      fg> Could you show us how to implement that procedure to our sample
      fg> clip?

      I can't see you last message to Joy. Is it in one of the other NT
      groups?


      Let me go back to the beginning and ask what you're trying to achieve.
      Are you:

      1) Making tests to help in understanding how NTP's clipbook interacts
      with the Windows clipboard? If so, I don't know enough clipbook
      programming to be able to help.

      2) Wanting to open the file of words in NTP, run the AWK script on it
      to find the maximum line length, and, leaving the original text
      unchanged, append the max line length information to it? If so, I
      think I know how to do that, and further think you're making it too
      complicated.

      Kees' script does the job. What I've done is put my version of it
      (pedantically modified to make it clearer to me) in a NTP "script
      clip" (my name for it), and call it from another "real clip." 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.

      The clip that calls this script has to be called by another name -
      very important - here it's "Test - Kees", containing just the calling
      line:

      Test - Kees
      ----------------
      ^!RunGawk "Kees AWK script"
      ----------------

      When I have your test data open in an NTP file and run the "Test -
      Kees" clip *making sure to avoid calling "Kees AWK script" by name, I
      get:

      ----------------
      Adelaide
      Adria
      Karkonjafarabadi
      Karolyne
      Rob
      max line length is 16
      ----------------

      To prove it, I made a Jing Screencast video that you can see at
      http://screencast.com/t/TW7PYAbQL9

      Note that I usually activate clips by pressing Esc and choosing from
      the dropdown menu. I'd already tested the clip, so the lightbar is
      already on the required clip.

      Apologies if I have still misunderstood what you were looking for.

      --
      Regards,

      Robert Bull
      mailto:barlennan@...
    • 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 2 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 3 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 4 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.