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

Re: [Clip] Can NoteTab handle input\output for GAWK in only one way?

Expand Messages
  • Robert Bull
    On Sunday, May 6, 2012, 9:15:28 PM, joy8388608 wrote: j I became interested in GAWK code by seeing a recent solution using j it a short time ago. j All I
    Message 1 of 6 , May 6, 2012
      On Sunday, May 6, 2012, 9:15:28 PM, joy8388608 wrote:

      j> I became interested in GAWK code by seeing a recent solution using
      j> it a short time ago.

      j> All I can find so far is that the input is all lines in the current
      j> document and the output replaces all lines in the current document.

      j> Is this correct

      I use AWK scripts, usually with GAWK, but I am not an expert. What
      you've said doesn't sound strictly correct. GAWK looks through all the
      input lines, but it normally only operates on those matching /regular
      expressions/. So an AWK script doesn't necessarily *change* all lines,
      though it may (or may not) *output* them all. However, I suspect the
      bit you're interested in is in this line from Help:

      "NoteTab integrates seamless support for Perl and Gawk interpreters;
      scripts can be stored in NoteTab's Clipbook and applied directly to
      highlighted text or the whole document."

      Note - script need only be applied to a highlit area of text.

      I recommend the AWK book: The AWK Programming Language, by Aho,
      Kernighan and Weinberger, the very people who originated the language.
      My copy is published by Addison-Wesley and dated 1988.

      j> Is this correct and is there any other way of getting input and
      j> writing output when calling a GAWK script from a NT clip? If so, how.

      The only way I know is to put the scripts into a clipbook, in a
      section titled Scripts (what else), and call each script with a clip.
      But, you could also run a script in a normal or TCC-LE console and
      capture the output.

      Not sure that helps, best I can do for now.

      --
      Regards,

      Robert Bull
      mailto:barlennan@...
    • Robert Bull
      On Sunday, May 6, 2012, 9:15:28 PM, joy8388608 wrote: j I became interested in GAWK code by seeing a recent solution using Further to my earlier post, the
      Message 2 of 6 , May 6, 2012
        On Sunday, May 6, 2012, 9:15:28 PM, joy8388608 wrote:

        j> I became interested in GAWK code by seeing a recent solution using

        Further to my earlier post, the page of the Help file I quoted is
        titled "Apply Perl and Gawk Scripts on Text." If you search for
        "scripts" in Help, it's the first one in the postings list. Further
        quote from it:

        "Scripts need not be stored in Clip libraries; each script may be
        stored in its own file. Clips which process scripts stored in the Clip
        library are not Clipbar-safe."

        "You will find several examples in the "Samples.clb" library that
        accompanies the NoteTab package."

        I frequently have trouble finding things in the Help file, or more
        accurately, know I've seen something once before, and have trouble
        finding it again.


        --
        Regards,

        Robert Bull
        mailto:barlennan@...
      • joy8388608
        ... Thanks for pointing out the samples in samples.clb. I already bought sed & awk by Dale Dougherty (O Reilly) so will start from there. I haven t started
        Message 3 of 6 , May 6, 2012
          --- In ntb-clips@yahoogroups.com, Robert Bull <barlennan@...> wrote:
          >
          > On Sunday, May 6, 2012, 9:15:28 PM, joy8388608 wrote:
          >
          > j> I became interested in GAWK code by seeing a recent solution using
          >
          > Further to my earlier post, the page of the Help file I quoted is
          > titled "Apply Perl and Gawk Scripts on Text." If you search for
          > "scripts" in Help, it's the first one in the postings list. Further
          > quote from it:
          >
          > "Scripts need not be stored in Clip libraries; each script may be
          > stored in its own file. Clips which process scripts stored in the Clip
          > library are not Clipbar-safe."
          >
          > "You will find several examples in the "Samples.clb" library that
          > accompanies the NoteTab package."
          >
          > I frequently have trouble finding things in the Help file, or more
          > accurately, know I've seen something once before, and have trouble
          > finding it again.
          >
          >
          > --
          > Regards,
          >
          > Robert Bull
          > mailto:barlennan@...
          >

          Thanks for pointing out the samples in samples.clb. I already bought sed & awk by Dale Dougherty (O'Reilly) so will start from there.

          I haven't started playing with it yet, but the one example I saw copied some lines into a new doc and ran a GAWK script which matched and changed all the lines. The results in the doc were the changed lines so I thought that the way it works is to process all the lines in a doc (or, I suppose) just the selected lines (what about partially selected lines???) and replace everything (or just the selected lines?) in that doc with the output which is the changed lines matching the selection criteria.

          Was that clear? I'll figure out more when I actually start to write some test scripts. Wish it was explained a little better somewhere in the NT documentation.

          Thanks for the help.

          Joy
        • joy8388608
          ... Thanks for pointing out the samples in samples.clb. I already bought sed & awk by Dale Dougherty (O Reilly) so will start from there. I haven t started
          Message 4 of 6 , May 6, 2012
            --- In ntb-clips@yahoogroups.com, Robert Bull <barlennan@...> wrote:
            >
            > On Sunday, May 6, 2012, 9:15:28 PM, joy8388608 wrote:
            >
            > j> I became interested in GAWK code by seeing a recent solution using
            >
            > Further to my earlier post, the page of the Help file I quoted is
            > titled "Apply Perl and Gawk Scripts on Text." If you search for
            > "scripts" in Help, it's the first one in the postings list. Further
            > quote from it:
            >
            > "Scripts need not be stored in Clip libraries; each script may be
            > stored in its own file. Clips which process scripts stored in the Clip
            > library are not Clipbar-safe."
            >
            > "You will find several examples in the "Samples.clb" library that
            > accompanies the NoteTab package."
            >
            > I frequently have trouble finding things in the Help file, or more
            > accurately, know I've seen something once before, and have trouble
            > finding it again.
            >
            >
            > --
            > Regards,
            >
            > Robert Bull
            > mailto:barlennan@...
            >

            Thanks for pointing out the samples in samples.clb. I already bought sed & awk by Dale Dougherty (O'Reilly) so will start from there.

            I haven't started playing with it yet, but the one example I saw copied some lines into a new doc and ran a GAWK script which matched and changed all the lines. The results in the doc were the changed lines so I thought that the way it works is to process all the lines in a doc (or, I suppose) just the selected lines (what about partially selected lines???) and replace everything (or just the selected lines?) in that doc with the output which is the changed lines matching the selection criteria.

            Was that clear? I'll figure out more when I actually start to write some test scripts. Wish it was explained a little better somewhere in the NT documentation.

            Thanks for the help.

            Joy
          • Robert Bull
            On Monday, May 7, 2012, 3:28:55 AM, joy8388608 wrote: j Thanks for pointing out the samples in samples.clb. I already j bought sed & awk by Dale Dougherty
            Message 5 of 6 , May 7, 2012
              On Monday, May 7, 2012, 3:28:55 AM, joy8388608 wrote:

              j> Thanks for pointing out the samples in samples.clb. I already
              j> bought sed & awk by Dale Dougherty (O'Reilly) so will start from

              I hope you bought the second edition, or later. The first edition
              apparently had typos. I prefer The AWK Programming Language for AWK
              itself, but Dougherty's book is still the only one I've seen that
              gives a reasonably comprehensible description of SED.

              j> changed lines so I thought that the way it works is to process all
              j> the lines in a doc (or, I suppose) just the selected lines (what
              j> about partially selected lines???) and replace everything (or just
              j> the selected lines?) in that doc with the output which is the
              j> changed lines matching the selection criteria.

              I think AWK looks at all lines of text given to it, but what if
              anything you get out depends on the script. The traditional way to run
              AWK is from a command line in a console (DOS box). Things are slightly
              different if you run it from inside NT because you can include native
              NT commands in the calling clip, and because you can mark only a
              section of a file in NT and thereby hand that part, only, to AWK.

              I've just done a quick check. If you put an AWK script into a Notetab
              clipbook, select some lines in a file, and tell NT to run the AWK
              script, AWK only processes the *marked* lines. The output from the
              script will replace the original selection only, leaving the rest of
              the (originally unmarked) file as it was. If the marking included only
              part of a line, the excluded part will *not* be processed by AWK.

              j> Wish it was explained a little better somewhere in the NT
              j> documentation.

              So do I :) NT's Help file is good, yet it's often hard to find what
              you want.

              Hope that helps,

              --
              Regards,

              Robert Bull
              mailto:barlennan@...
            Your message has been successfully submitted and would be delivered to recipients shortly.