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

Re: Smart/intelligent text formatting

Expand Messages
  • rpdooling
    Well, I poked around and looked at the Template-Toolkit, but I can t find a win32 rendition which is where I do all of my work. If they ever port NoteTab or
    Message 1 of 19 , Sep 27, 2005
      Well, I poked around and looked at the Template-Toolkit, but I can't
      find a win32 rendition which is where I do all of my work. If they
      ever port NoteTab or Delphi to Linux, then I could be persuaded to
      switch. So for now I better just use plain old autoformat.

      What's your favorite solution to the problem of reformatting text that
      comes to you with hard returns at the end of each line and NO blank
      space separating the paragraphs?

      I found this one on the clips forum that works most of the time.

      ^!REPLACE "{[.!?]}\b*$" >> "\1\n" ritswa

      Thanks,

      Rick

      --- In ntb-scripts@yahoogroups.com, "acummingsus" <acumming@c...> wrote:
      > --- In ntb-scripts@yahoogroups.com, "rpdooling" <rpdooling@y...> wrote:
      > > Alan,
      > >
      > > >>is there another script that can be run afterwords to remove the
      > > hard paragraph breaks at the end of each line?<<
      > >
      > > Never mind. Sorry. Select All. Join lines. Duh.
      >
      > (new clips are enclosed at bottom)
      >
      > Well, if you'd rather be lazy and have Perl do the work instead, I had
      > also needed to add a modification anyways. So, new mod/update
      > included below, here goes:
      >
      > Hi Rick,
      >
      > I'm not sure wether you want all lines joined or only want consecutive
      > (so to speak) lines joined.
      >
      > At doc for Text-Autoformat:
      >
      >
      http://search.cpan.org/~dconway/Text-Autoformat-1.13/lib/Text/Autoformat.pm
      >
      > I couldn't locate any option to run lines together.
      >
      > But to do so, join lines, is very easy to do with the Perl
      > substitution operator:
      >
      > s///; <- skeleton of such/said operator
      >
      > s/-2Breplaced-/--replace_with_this--/any_option(s)_go_here;
      >
      > Look at bottom where clips R included herein for: # newly added line
      >
      > It uses substitution operator to join *all* lines together (replaces
      > with a space). If do not want that then remove the plus character
      >
      > +
      >
      > remove that + makes it do only one line break at a time rather than
      > multiple consecutive line breaks at each_time/spot (note: the g for
      > global option is used, thus each "spot/time/occurrence").
      >
      > Also in clip below, look for: <new>
      >
      > I meant to re post and do that a while back but forgot to do so.
      >
      > Yet even more: the all option makes it process all text passed to it
      >
      > my $formatted = autoformat($rawtext, {all=>1});
      >
      > my $formatted = autoformat($rawtext);
      >
      > if do like that latter, without the all option, then it processes only
      > the first paragraph of text even if you pass it multiple paragraphs.
      >
      > I just now discovered this next url for the first time:
      >
      >
      http://search.cpan.org/~abw/Template-Toolkit-2.14/lib/Template/Plugin/Autoformat.pm
      >
      > A template interface to text-autoformat. (make my own templates for
      > to have available the output of various and different format
      > patterns). Pick/choose a template to run according to a particular
      > desired output format.
      >
      > Goodness, as to the amount of possibilities that exists here!
      >
      > Probably a caution I should previously had is to work up to (biggest,
      > huge file size). (I'd guess it means above a few megabytes in file
      > size)-- most common texts don't get up to near that big at all.
      >
      > My intent so far for myself equate to use it for formatting email
      > replies and similar where the size of text is not overly huge. It
      > slurps an entire file into memory/ram. And, ram is finite though it
      > typically takes an overly huge file size in order to bring any
      > problem. This slurping is commonly something that's done. But there
      > can be a type of a situation (*really* huge file) where some other
      > solution (such as tie, etc.) would be preferred.
      >
      > Alan.
      >
      > Dear Alan:
      >
      > The text::autoformat works great, but it puts a hard return at the end
      > of each line. Is there an option or something that can be set to avoid
      > that? Alternatively, is there another script that can be run afterwords
      > to remove the hard paragraph breaks at the end of each line?
      >
      > Thanks
      >
      > Rick
      >
      > --- In ntb-scripts@yahoogroups.com, "acummingsus" <acumming@c...> wrote:
      > > Text::Autoformat
      > >
      > > been using that Perl module on Linux. Impressive.
      > >
      > > http://search.cpan.org/~dconway/Text-Autoformat-
      > > 1.13/lib/Text/Autoformat.pm
      > >
      > > There's a bit of doc and what it will do.
      > >
      > > I just installed that module on my Win 2k and works super in Notetab.
      > >
      > > ppm equals perl package manager
      > >
      > > http://www.google.com/search?q=ppm+repositories
      > >
      > > bribes a ppm repository has Text-Autoformat (mine Windows Perl is
      > > Activestate Perl 5.8.X) (Additionally I also saw the module there for
      > > Perl 5.6.X)
      > >
      > > ppm> help
      > >
      > > ppm> help repository
      > >
      > > ppm> rep add bribes http_url_2_the_bribes_repo
      > >
      > > ppm> search text-autoformat
      > >
      > > ppm> install text-autoformat
      > >
      > > ppm> quit
      > >
      > > line length default of 72 char lines for now (well, 2 code lines
      > > R with "all" so U can comment the one and un comment the other
      > > line containing "all" which provides two choices of formatting).
      > > May develop it more with more choices, bells, and whistles. Two
      > > clips next:
      >
      > H="t_a_format"
      > ^!RunPerl taform
      >
      > H="_taform"
      > #!perl -w
      >
      > use strict;
      > use Text::Autoformat;
      > my $rawtext;
      >
      > # ----------------<new>----------------------------
      > # <depracated>
      > # while (<DATA>) {
      > # while (<>) {
      > # $rawtext = "$rawtext$_";
      > # }
      > # </depracated>
      >
      > {
      > # file slurp method. Significantly beats depracated
      > local( $/ ) ; # faster than while loop. This
      > $rawtext = <> # just slurps file into scalar variable
      > }
      > # ------------------</new>-------------------------
      >
      > # my $formatted = autoformat($rawtext, {left=>20, right=>60, all=>1});
      > my $formatted = autoformat($rawtext, {all=>1});
      > # my $formatted = autoformat $rawtext;
      >
      > # newly added line is next (joins lines)
      > $formatted =~ s/\n+/ /g;
      > print "$formatted\n";
      > # print "\n$rawtext\n"
      > # ----end----
      >
      > >
      > > Thanks for the tip on autoformat..
      >
      > You're welcome.
      >
      > I ran across it from somewhere Perl out there. I found it interesting.
      >
      > --
      > Alan.
    • acummingsus
      ... I haven t tried the T-T module yet. But it appears it is avail for Win32 http://template-toolkit.org/download.html Win32 about half way down the page.
      Message 2 of 19 , Sep 27, 2005
        --- In ntb-scripts@yahoogroups.com, "rpdooling" <rpdooling@y...> wrote:
        > Well, I poked around and looked at the Template-Toolkit, but I can't
        > find a win32 rendition which is where I do all of my work. If they
        > ever port NoteTab or Delphi to Linux, then I could be persuaded to
        > switch. So for now I better just use plain old autoformat.

        I haven't tried the T-T module yet. But it appears it is avail for Win32

        http://template-toolkit.org/download.html

        Win32 about half way down the page.

        http://www.google.com/search?q=ppm+template-toolkit&sourceid=mozilla&start=0&start=0&ie=utf-8&oe=utf-8

        Another way could be

        H="_taform"

        H="_taform2"

        etc. etc. IOW have various formatting options in different child
        clips. And call up the desired one.

        I'll be looking more into all of the above. But it's some days/weeks
        up ahead at this time before it happens as I'm too booked up right now
        to put yet another onto the platter at this time. If I discover more
        or make script with more bells and whistles then I'll post here about it.

        > What's your favorite solution to the problem of reformatting text that
        > comes to you with hard returns at the end of each line and NO blank
        > space separating the paragraphs?
        >
        > I found this one on the clips forum that works most of the time.
        >
        > ^!REPLACE "{[.!?]}\b*$" >> "\1\n" ritswa

        It appears that looks for a period, exclamation mark, or question mark
        with yes or no an adjacent word_boundary(s) (space(s)) -- and,
        whenever hits/strikes that criteria, it inserts another line break.

        I haven't ever had text come to me with the problem that you describe.

        As long as the Notetab regex is doing what it set out to do then it
        looks to me like there'd be no point in a Perl regex as to do so would
        only duplicate the Notetab results.

        To dial in even more, wouldn't a parser need at least some
        intelligence (as in ability to discern via language/grammar "rules" as
        to when it is appropriate to have/make a paragraph)?

        The Parse-rec-descent module in Perl is trainable. It is trained via
        grammars (rules) that you feed to it. I know it raises the
        intelligence level above that of what regex can do.

        also is other parser that starts low and ascends (the inverse of P-R-D)

        http://search.cpan.org/~dconway/Parse-RecDescent-1.94/lib/Parse/RecDescent.pod

        http://search.cpan.org/~tbone/Parse-RecDescent-FAQ-3.94/FAQ.pm

        I don't know much about, really. Hope to some day once I further
        advance my Perl skills.

        Perhaps snoop/search around for parser intelligence and similar if
        interested.

        Alan.
      • rpdooling
        Dear Alan: The template toolkit is WAY overkill for my needs. I looked at it last night, then uninstalled it. But I did play more with text::autoformat. Just
        Message 3 of 19 , Sep 28, 2005
          Dear Alan:

          The template toolkit is WAY overkill for my needs. I looked at it last
          night, then uninstalled it. But I did play more with text::autoformat.
          Just the barebones module is slick indeed. I configured it to ignore
          any line beginning with ^! so it can be used on clip code, but I can't
          figure out how to teach it that NoteTab marks comments with a ";" One
          kludgy way to do it is to just have the clip replace the ";" with "#"
          first (which text::autoformat recognizes), then change the "#s" back
          to ";s" after autoformat runs.

          I wrote the author of the module to see if there is a way to teach it
          that for us NoteTabbers our comment lines start with ";"

          Rick


          --- In ntb-scripts@yahoogroups.com, "acummingsus" <acummingsus@g...>
          wrote:
          > --- In ntb-scripts@yahoogroups.com, "rpdooling" <rpdooling@y...> wrote:
          > > Well, I poked around and looked at the Template-Toolkit, but I can't
          > > find a win32 rendition which is where I do all of my work. If they
          > > ever port NoteTab or Delphi to Linux, then I could be persuaded to
          > > switch. So for now I better just use plain old autoformat.
          >
          > I haven't tried the T-T module yet. But it appears it is avail for
          Win32
          >
          > http://template-toolkit.org/download.html
          >
          > Win32 about half way down the page.
          >
          >
          http://www.google.com/search?q=ppm+template-toolkit&sourceid=mozilla&start=0&start=0&ie=utf-8&oe=utf-8
          >
          > Another way could be
          >
          > H="_taform"
          >
          > H="_taform2"
          >
          > etc. etc. IOW have various formatting options in different child
          > clips. And call up the desired one.
          >
          > I'll be looking more into all of the above. But it's some days/weeks
          > up ahead at this time before it happens as I'm too booked up right now
          > to put yet another onto the platter at this time. If I discover more
          > or make script with more bells and whistles then I'll post here
          about it.
          >
          > > What's your favorite solution to the problem of reformatting text that
          > > comes to you with hard returns at the end of each line and NO blank
          > > space separating the paragraphs?
          > >
          > > I found this one on the clips forum that works most of the time.
          > >
          > > ^!REPLACE "{[.!?]}\b*$" >> "\1\n" ritswa
          >
          > It appears that looks for a period, exclamation mark, or question mark
          > with yes or no an adjacent word_boundary(s) (space(s)) -- and,
          > whenever hits/strikes that criteria, it inserts another line break.
          >
          > I haven't ever had text come to me with the problem that you describe.
          >
          > As long as the Notetab regex is doing what it set out to do then it
          > looks to me like there'd be no point in a Perl regex as to do so would
          > only duplicate the Notetab results.
          >
          > To dial in even more, wouldn't a parser need at least some
          > intelligence (as in ability to discern via language/grammar "rules" as
          > to when it is appropriate to have/make a paragraph)?
          >
          > The Parse-rec-descent module in Perl is trainable. It is trained via
          > grammars (rules) that you feed to it. I know it raises the
          > intelligence level above that of what regex can do.
          >
          > also is other parser that starts low and ascends (the inverse of P-R-D)
          >
          >
          http://search.cpan.org/~dconway/Parse-RecDescent-1.94/lib/Parse/RecDescent.pod
          >
          > http://search.cpan.org/~tbone/Parse-RecDescent-FAQ-3.94/FAQ.pm
          >
          > I don't know much about, really. Hope to some day once I further
          > advance my Perl skills.
          >
          > Perhaps snoop/search around for parser intelligence and similar if
          > interested.
          >
          > Alan.
        • Jason Morgan
          Not sure if anyone is interested, but I ve managed to create clips that will run Python code (which is what I mainly use). If anyone is interested, let me
          Message 4 of 19 , Sep 28, 2005
            Not sure if anyone is interested, but I've managed to create clips that
            will run Python code (which is what I mainly use). If anyone is
            interested, let me know.

            --
            Jason Morgan
            Senior Programmer
            Decipher, Inc.
            p 800.923.5523
          • rpdooling
            Jason, Fire away. I m just learning PERL and thinking about switching to Python instead because I forget everything in between immersions. I hear Python is
            Message 5 of 19 , Sep 28, 2005
              Jason,

              Fire away. I'm just learning PERL and thinking about switching to
              Python instead because I forget everything in between immersions. I
              hear Python is easier to read and remember.

              Rick

              --- In ntb-scripts@yahoogroups.com, "Jason Morgan" <jason@d...> wrote:
              > Not sure if anyone is interested, but I've managed to create clips that
              > will run Python code (which is what I mainly use). If anyone is
              > interested, let me know.
              >
              > --
              > Jason Morgan
              > Senior Programmer
              > Decipher, Inc.
              > p 800.923.5523
            • Jason Morgan
              Rick, From my point of view, Python is much easier to understand than Perl. If you have any experience with other Object Oriented languages, such as C/C++,
              Message 6 of 19 , Sep 28, 2005
                Rick,

                From my point of view, Python is much easier to understand than Perl.
                If you have any experience with other Object Oriented languages, such as
                C/C++, Python should be a snap for you.
                As the majority of my clips are very specialized to my needs, I'm
                including a very simple example that should give you an idea of how to
                get started. You will need to install Python, which is free and can be
                downloaded from www.python.org. There you can also find almost
                everything you need to get started programming in Python.

                H="Sort"
                ^!RunScript C:\python24\python.exe sort

                H="sort"
                from sys import stdin
                input = stdin.read().split('\n')
                input.sort()
                print '\n'.join(input)

                --
                Jason Morgan
                Senior Programmer
                Decipher, Inc.
                p 800.923.5523


                > -----Original Message-----
                > From: ntb-scripts@yahoogroups.com
                > [mailto:ntb-scripts@yahoogroups.com] On Behalf Of rpdooling
                > Sent: Wednesday, September 28, 2005 2:46 PM
                > To: ntb-scripts@yahoogroups.com
                > Subject: Re: [NTS] Using Python instead of Perl
                >
                >
                > Jason,
                >
                > Fire away. I'm just learning PERL and thinking about
                > switching to Python instead because I forget everything in
                > between immersions. I hear Python is easier to read and remember.
                >
                > Rick
                >
                > --- In ntb-scripts@yahoogroups.com, "Jason Morgan" <jason@d...> wrote:
                > > Not sure if anyone is interested, but I've managed to create clips
                > > that will run Python code (which is what I mainly use). If
                > anyone is
                > > interested, let me know.
                > >
                > > --
                > > Jason Morgan
                > > Senior Programmer
                > > Decipher, Inc.
                > > p 800.923.5523
                >
                >
                >
                >
                > ------------------------ Yahoo! Groups Sponsor
                > --------------------~-->
                > Get Bzzzy! (real tools to help you find a job). Welcome to
                > the Sweet Life.
                > http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/NhFolB/TM
                > --------------------------------------------------------------
                > ------~->
                >
                > ntb-scripts-unsubscribe@yahoogroups.com
                >
                >
                > Yahoo! Groups Links
                >
                >
                >
                >
                >
                >
              • rpdooling
                Alan, Damian Conway, the guy who wrote the autoformat module wrote me back. Just open the autoformat.pm module and change the line my $quotechar =
                Message 7 of 19 , Sep 28, 2005
                  Alan,

                  Damian Conway, the guy who wrote the autoformat module wrote me back.
                  Just open the autoformat.pm module and change the line

                  my $quotechar = qq{[!#%=|:]};

                  to:

                  my $quotechar = qq{[!#%=|:;]};

                  by adding the ";" and poof, it's a great
                  clipcode autoformatter.

                  Be sure to add in the script itself a line that tells the module to
                  ignore clip code lines starting with "^"

                  My line looks like:

                  my $formatted = autoformat($rawtext, {all=>1, ignore=>qr/(\^)/});

                  If anybody wants to whole script I'll post it later.

                  I hope I didn't double post. Yahoo locked up in the middle of the last.

                  Rick

                  --- In ntb-scripts@yahoogroups.com, "acummingsus" <acummingsus@g...>
                  wrote:
                  > --- In ntb-scripts@yahoogroups.com, "rpdooling" <rpdooling@y...> wrote:
                  > > Well, I poked around and looked at the Template-Toolkit, but I can't
                  > > find a win32 rendition which is where I do all of my work. If they
                  > > ever port NoteTab or Delphi to Linux, then I could be persuaded to
                  > > switch. So for now I better just use plain old autoformat.
                  >
                  > I haven't tried the T-T module yet. But it appears it is avail for
                  Win32
                  >
                  > http://template-toolkit.org/download.html
                  >
                  > Win32 about half way down the page.
                  >
                  >
                  http://www.google.com/search?q=ppm+template-toolkit&sourceid=mozilla&start=0&start=0&ie=utf-8&oe=utf-8
                  >
                  > Another way could be
                  >
                  > H="_taform"
                  >
                  > H="_taform2"
                  >
                  > etc. etc. IOW have various formatting options in different child
                  > clips. And call up the desired one.
                  >
                  > I'll be looking more into all of the above. But it's some days/weeks
                  > up ahead at this time before it happens as I'm too booked up right now
                  > to put yet another onto the platter at this time. If I discover more
                  > or make script with more bells and whistles then I'll post here
                  about it.
                  >
                  > > What's your favorite solution to the problem of reformatting text that
                  > > comes to you with hard returns at the end of each line and NO blank
                  > > space separating the paragraphs?
                  > >
                  > > I found this one on the clips forum that works most of the time.
                  > >
                  > > ^!REPLACE "{[.!?]}\b*$" >> "\1\n" ritswa
                  >
                  > It appears that looks for a period, exclamation mark, or question mark
                  > with yes or no an adjacent word_boundary(s) (space(s)) -- and,
                  > whenever hits/strikes that criteria, it inserts another line break.
                  >
                  > I haven't ever had text come to me with the problem that you describe.
                  >
                  > As long as the Notetab regex is doing what it set out to do then it
                  > looks to me like there'd be no point in a Perl regex as to do so would
                  > only duplicate the Notetab results.
                  >
                  > To dial in even more, wouldn't a parser need at least some
                  > intelligence (as in ability to discern via language/grammar "rules" as
                  > to when it is appropriate to have/make a paragraph)?
                  >
                  > The Parse-rec-descent module in Perl is trainable. It is trained via
                  > grammars (rules) that you feed to it. I know it raises the
                  > intelligence level above that of what regex can do.
                  >
                  > also is other parser that starts low and ascends (the inverse of P-R-D)
                  >
                  >
                  http://search.cpan.org/~dconway/Parse-RecDescent-1.94/lib/Parse/RecDescent.pod
                  >
                  > http://search.cpan.org/~tbone/Parse-RecDescent-FAQ-3.94/FAQ.pm
                  >
                  > I don't know much about, really. Hope to some day once I further
                  > advance my Perl skills.
                  >
                  > Perhaps snoop/search around for parser intelligence and similar if
                  > interested.
                  >
                  > Alan.
                • acummingsus
                  Hi Rick, That s great to know! Thanks. I d be interested your entire script unless there s nothing more that s new in it outside of what you ve already
                  Message 8 of 19 , Sep 28, 2005
                    Hi Rick,

                    That's great to know! Thanks. I'd be interested your entire script
                    unless there's nothing more that's new in it outside of what you've
                    already shared here.

                    I cannot get the ignore option to work in Linux. I've tried over 7
                    different ways, all to no avail.

                    In Linux, I read from a file (I had tried unsuccessfully so far to map
                    relevant command to a key in the Vim editor). Also I don't yet savvy
                    enough on the Kate editor to create a "tool" (macro making use of
                    external program).

                    my junkr.txt file has 5 or 6 paragraphs. 2 paragraphs have word verbatim

                    Each of those 2 para has a really long line.

                    It always formats all para to 72 character line length. I thought it
                    supposed to ignore, not format those 2 para. But it does.

                    (PS I haven't tried the ignore option on Windows yet). I'll boot Win
                    on another day, not today.

                    Do you see anything, problem? Here it is for Linux:

                    #!/usr/bin/perl -w

                    use strict;
                    use Text::Autoformat;
                    my $orig = '/home/al/junkr.txt';
                    my $rawtext;
                    # AC 080205
                    {
                    local( $/ ) ; # change input record separator to file slurp
                    open(OLD, "<", $orig) or die "cant open $orig: $!";
                    $rawtext = <OLD> # slurp entirety of file into $rawtext
                    }
                    # my $formatted = autoformat $rawtext;
                    # my $formatted = autoformat($rawtext, {left=>20, right=>60, all=>1});
                    # my $formatted = autoformat($rawtext, {ignore => qr/original/i, all=>1});

                    my $formatted = autoformat $rawtext, { all=>1, ignore=>qr/verbatim/ };

                    # $formatted =~ s/\n+/ /g; # join lines if desire to

                    print "$formatted\n";
                    # print autoformat { all => 1, ignore => qr/verbatim/i }, $rawtext;
                    print "# ============ re formatted is above and raw orig is below
                    ==========";
                    print "\n$rawtext\n";
                    # end

                    Alan.

                    --- In ntb-scripts@yahoogroups.com, "rpdooling" <rpdooling@y...> wrote:
                    > Alan,
                    >
                    > Damian Conway, the guy who wrote the autoformat module wrote me back.
                    > Just open the autoformat.pm module and change the line
                    >
                    > my $quotechar = qq{[!#%=|:]};
                    >
                    > to:
                    >
                    > my $quotechar = qq{[!#%=|:;]};
                    >
                    > by adding the ";" and poof, it's a great
                    > clipcode autoformatter.
                    >
                    > Be sure to add in the script itself a line that tells the module to
                    > ignore clip code lines starting with "^"
                    >
                    > My line looks like:
                    >
                    > my $formatted = autoformat($rawtext, {all=>1, ignore=>qr/(\^)/});
                    >
                    > If anybody wants to whole script I'll post it later.
                    >
                    > I hope I didn't double post. Yahoo locked up in the middle of the last.
                    >
                    > Rick
                    >
                    > --- In ntb-scripts@yahoogroups.com, "acummingsus" <acummingsus@g...>
                    > wrote:
                    [ snip ]
                  • rpdooling
                    Jason, Thank you. I ll get the Active State Python installed and get a book. Somebody else said just to try both, so I will. Thanks for showing us how to run
                    Message 9 of 19 , Sep 28, 2005
                      Jason,

                      Thank you. I'll get the Active State Python installed and get a book.
                      Somebody else said just to try both, so I will.

                      Thanks for showing us how to run it from NoteTab.

                      Rick

                      --- In ntb-scripts@yahoogroups.com, "Jason Morgan" <jason@d...> wrote:
                      > Rick,
                      >
                      > From my point of view, Python is much easier to understand than Perl.
                      > If you have any experience with other Object Oriented languages, such as
                      > C/C++, Python should be a snap for you.
                      > As the majority of my clips are very specialized to my needs, I'm
                      > including a very simple example that should give you an idea of how to
                      > get started. You will need to install Python, which is free and can be
                      > downloaded from www.python.org. There you can also find almost
                      > everything you need to get started programming in Python.
                      >
                      > H="Sort"
                      > ^!RunScript C:\python24\python.exe sort
                      >
                      > H="sort"
                      > from sys import stdin
                      > input = stdin.read().split('\n')
                      > input.sort()
                      > print '\n'.join(input)
                      >
                      > --
                      > Jason Morgan
                      > Senior Programmer
                      > Decipher, Inc.
                      > p 800.923.5523
                      >
                      >
                      > > -----Original Message-----
                      > > From: ntb-scripts@yahoogroups.com
                      > > [mailto:ntb-scripts@yahoogroups.com] On Behalf Of rpdooling
                      > > Sent: Wednesday, September 28, 2005 2:46 PM
                      > > To: ntb-scripts@yahoogroups.com
                      > > Subject: Re: [NTS] Using Python instead of Perl
                      > >
                      > >
                      > > Jason,
                      > >
                      > > Fire away. I'm just learning PERL and thinking about
                      > > switching to Python instead because I forget everything in
                      > > between immersions. I hear Python is easier to read and remember.
                      > >
                      > > Rick
                      > >
                      > > --- In ntb-scripts@yahoogroups.com, "Jason Morgan" <jason@d...> wrote:
                      > > > Not sure if anyone is interested, but I've managed to create clips
                      > > > that will run Python code (which is what I mainly use). If
                      > > anyone is
                      > > > interested, let me know.
                      > > >
                      > > > --
                      > > > Jason Morgan
                      > > > Senior Programmer
                      > > > Decipher, Inc.
                      > > > p 800.923.5523
                      > >
                      > >
                      > >
                      > >
                      > > ------------------------ Yahoo! Groups Sponsor
                      > > --------------------~-->
                      > > Get Bzzzy! (real tools to help you find a job). Welcome to
                      > > the Sweet Life.
                      > > http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/NhFolB/TM
                      > > --------------------------------------------------------------
                      > > ------~->
                      > >
                      > > ntb-scripts-unsubscribe@yahoogroups.com
                      > >
                      > >
                      > > Yahoo! Groups Links
                      > >
                      > >
                      > >
                      > >
                      > >
                      > >
                    • rpdooling
                      Alan, Only thing I see in yours is that I seemed to get errors if I didn t put all of the options in one line, including the ignore one. ... #!perl -w use
                      Message 10 of 19 , Sep 28, 2005
                        Alan,

                        Only thing I see in yours is that I seemed to get errors if I didn't
                        put all of the options in one line, including the ignore one.

                        -----begin autoformat perl script-----
                        #!perl -w

                        use strict;
                        use Text::Autoformat;
                        my $rawtext;

                        # while (<DATA>) {
                        while (<>) {

                        $rawtext = "$rawtext$_";

                        }

                        # If you ever want to change the margins, etc.
                        # my $formatted = autoformat($rawtext, {left=>20, right=>60, all=>1});
                        # If you don't have the "all=>1" then it does only one
                        # line at a time.

                        my $formatted = autoformat($rawtext, {all=>1, ignore=>qr/(\^)/});

                        # my $formatted = autoformat $rawtext;

                        print "$formatted\n";

                        # print "\n$rawtext\n";
                        # the following will join all of the lines.
                        # should be able to put the RegExp from the add blank
                        # lines clip in here.
                        #$formatted =~ s/\n+/ /g;
                        #print "$formatted\n";

                        #to autoformat notetab clip code, open the autoformat.pm
                        #module, find the "quotechar" line and add a ";" to the
                        #characters recognized as starting a comment or quote line.

                        #for help with autoformat type "perldoc Text::Autoformat at the
                        #command prompt d:\perl>perldoc Text::AutoFormat



                        --- In ntb-scripts@yahoogroups.com, "acummingsus" <acummingsus@g...>
                        wrote:
                        > Hi Rick,
                        >
                        > That's great to know! Thanks. I'd be interested your entire script
                        > unless there's nothing more that's new in it outside of what you've
                        > already shared here.
                        >
                        > I cannot get the ignore option to work in Linux. I've tried over 7
                        > different ways, all to no avail.
                        >
                        > In Linux, I read from a file (I had tried unsuccessfully so far to map
                        > relevant command to a key in the Vim editor). Also I don't yet savvy
                        > enough on the Kate editor to create a "tool" (macro making use of
                        > external program).
                        >
                        > my junkr.txt file has 5 or 6 paragraphs. 2 paragraphs have word
                        verbatim
                        >
                        > Each of those 2 para has a really long line.
                        >
                        > It always formats all para to 72 character line length. I thought it
                        > supposed to ignore, not format those 2 para. But it does.
                        >
                        > (PS I haven't tried the ignore option on Windows yet). I'll boot Win
                        > on another day, not today.
                        >
                        > Do you see anything, problem? Here it is for Linux:
                        >
                        > #!/usr/bin/perl -w
                        >
                        > use strict;
                        > use Text::Autoformat;
                        > my $orig = '/home/al/junkr.txt';
                        > my $rawtext;
                        > # AC 080205
                        > {
                        > local( $/ ) ; # change input record separator to file slurp
                        > open(OLD, "<", $orig) or die "cant open $orig: $!";
                        > $rawtext = <OLD> # slurp entirety of file into $rawtext
                        > }
                        > # my $formatted = autoformat $rawtext;
                        > # my $formatted = autoformat($rawtext, {left=>20, right=>60, all=>1});
                        > # my $formatted = autoformat($rawtext, {ignore => qr/original/i,
                        all=>1});
                        >
                        > my $formatted = autoformat $rawtext, { all=>1, ignore=>qr/verbatim/ };
                        >
                        > # $formatted =~ s/\n+/ /g; # join lines if desire to
                        >
                        > print "$formatted\n";
                        > # print autoformat { all => 1, ignore => qr/verbatim/i }, $rawtext;
                        > print "# ============ re formatted is above and raw orig is below
                        > ==========";
                        > print "\n$rawtext\n";
                        > # end
                        >
                        > Alan.
                        >
                        > --- In ntb-scripts@yahoogroups.com, "rpdooling" <rpdooling@y...> wrote:
                        > > Alan,
                        > >
                        > > Damian Conway, the guy who wrote the autoformat module wrote me back.
                        > > Just open the autoformat.pm module and change the line
                        > >
                        > > my $quotechar = qq{[!#%=|:]};
                        > >
                        > > to:
                        > >
                        > > my $quotechar = qq{[!#%=|:;]};
                        > >
                        > > by adding the ";" and poof, it's a great
                        > > clipcode autoformatter.
                        > >
                        > > Be sure to add in the script itself a line that tells the module to
                        > > ignore clip code lines starting with "^"
                        > >
                        > > My line looks like:
                        > >
                        > > my $formatted = autoformat($rawtext, {all=>1, ignore=>qr/(\^)/});
                        > >
                        > > If anybody wants to whole script I'll post it later.
                        > >
                        > > I hope I didn't double post. Yahoo locked up in the middle of the
                        last.
                        > >
                        > > Rick
                        > >
                        > > --- In ntb-scripts@yahoogroups.com, "acummingsus" <acummingsus@g...>
                        > > wrote:
                        > [ snip ]
                      • Jason Morgan
                        No problem. If you have any questions about anything I ll try and answer them. -- Jason Morgan Senior Programmer Decipher, Inc. p 800.923.5523
                        Message 11 of 19 , Sep 29, 2005
                          No problem. If you have any questions about anything I'll try and
                          answer them.

                          --
                          Jason Morgan
                          Senior Programmer
                          Decipher, Inc.
                          p 800.923.5523


                          > -----Original Message-----
                          > From: ntb-scripts@yahoogroups.com
                          > [mailto:ntb-scripts@yahoogroups.com] On Behalf Of rpdooling
                          > Sent: Wednesday, September 28, 2005 6:05 PM
                          > To: ntb-scripts@yahoogroups.com
                          > Subject: Re: [NTS] Using Python instead of Perl
                          >
                          >
                          > Jason,
                          >
                          > Thank you. I'll get the Active State Python installed and get
                          > a book. Somebody else said just to try both, so I will.
                          >
                          > Thanks for showing us how to run it from NoteTab.
                          >
                          > Rick
                          >
                          > --- In ntb-scripts@yahoogroups.com, "Jason Morgan" <jason@d...> wrote:
                          > > Rick,
                          > >
                          > > From my point of view, Python is much easier to understand
                          > than Perl.
                          > > If you have any experience with other Object Oriented
                          > languages, such
                          > > as C/C++, Python should be a snap for you. As the majority
                          > of my clips
                          > > are very specialized to my needs, I'm including a very
                          > simple example
                          > > that should give you an idea of how to get started. You
                          > will need to
                          > > install Python, which is free and can be downloaded from
                          > > www.python.org. There you can also find almost everything
                          > you need to
                          > > get started programming in Python.
                          > >
                          > > H="Sort"
                          > > ^!RunScript C:\python24\python.exe sort
                          > >
                          > > H="sort"
                          > > from sys import stdin
                          > > input = stdin.read().split('\n')
                          > > input.sort()
                          > > print '\n'.join(input)
                          > >
                          > > --
                          > > Jason Morgan
                          > > Senior Programmer
                          > > Decipher, Inc.
                          > > p 800.923.5523
                          > >
                          > >
                          > > > -----Original Message-----
                          > > > From: ntb-scripts@yahoogroups.com
                          > > > [mailto:ntb-scripts@yahoogroups.com] On Behalf Of rpdooling
                          > > > Sent: Wednesday, September 28, 2005 2:46 PM
                          > > > To: ntb-scripts@yahoogroups.com
                          > > > Subject: Re: [NTS] Using Python instead of Perl
                          > > >
                          > > >
                          > > > Jason,
                          > > >
                          > > > Fire away. I'm just learning PERL and thinking about
                          > > > switching to Python instead because I forget everything in
                          > > > between immersions. I hear Python is easier to read and remember.
                          > > >
                          > > > Rick
                          > > >
                          > > > --- In ntb-scripts@yahoogroups.com, "Jason Morgan" <jason@d...>
                          > > > wrote:
                          > > > > Not sure if anyone is interested, but I've managed to
                          > create clips
                          > > > > that will run Python code (which is what I mainly use). If
                          > > > anyone is
                          > > > > interested, let me know.
                          > > > >
                          > > > > --
                          > > > > Jason Morgan
                          > > > > Senior Programmer
                          > > > > Decipher, Inc.
                          > > > > p 800.923.5523
                          > > >
                          > > >
                          > > >
                          > > >
                          > > > ------------------------ Yahoo! Groups Sponsor
                          > > > --------------------~-->
                          > > > Get Bzzzy! (real tools to help you find a job). Welcome to
                          > > > the Sweet Life.
                          > > > http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/NhFolB/TM
                          > > > --------------------------------------------------------------
                          > > > ------~->
                          > > >
                          > > > ntb-scripts-unsubscribe@yahoogroups.com
                          > > >
                          > > >
                          > > > Yahoo! Groups Links
                          > > >
                          > > >
                          > > >
                          > > >
                          > > >
                          > > >
                          >
                          >
                          >
                          >
                          > ------------------------ Yahoo! Groups Sponsor
                          > --------------------~-->
                          > Most low income households are not online. Help bridge the
                          > digital divide today!
                          > http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/NhFol> B/TM
                          >
                          >
                          > --------------------------------------------------------------
                          > ------~->
                          >
                          > ntb-scripts-unsubscribe@yahoogroups.com
                          >
                          >
                          > Yahoo! Groups Links
                          >
                          >
                          >
                          >
                          >
                          >
                        • rpdooling
                          Jason, Any idea why I can t get something like this to work? It works fine from the command line no matter what directory I m in. ^!Info ^$GetOutput( python
                          Message 12 of 19 , Oct 18 10:09 AM
                            Jason,

                            Any idea why I can't get something like this to work? It works fine
                            from the command line no matter what directory I'm in.

                            ^!Info ^$GetOutput("python -V")$

                            --- In ntb-scripts@yahoogroups.com, "Jason Morgan" <jason@d...> wrote:
                            >
                            > Rick,
                            >
                            > From my point of view, Python is much easier to understand than Perl.
                            > If you have any experience with other Object Oriented languages, such as
                            > C/C++, Python should be a snap for you.
                            > As the majority of my clips are very specialized to my needs, I'm
                            > including a very simple example that should give you an idea of how to
                            > get started. You will need to install Python, which is free and can be
                            > downloaded from www.python.org. There you can also find almost
                            > everything you need to get started programming in Python.
                            >
                            > H="Sort"
                            > ^!RunScript C:\python24\python.exe sort
                            >
                            > H="sort"
                            > from sys import stdin
                            > input = stdin.read().split('\n')
                            > input.sort()
                            > print '\n'.join(input)
                            >
                            > --
                            > Jason Morgan
                            > Senior Programmer
                            > Decipher, Inc.
                            > p 800.923.5523
                            >
                            >
                            > > -----Original Message-----
                            > > From: ntb-scripts@yahoogroups.com
                            > > [mailto:ntb-scripts@yahoogroups.com] On Behalf Of rpdooling
                            > > Sent: Wednesday, September 28, 2005 2:46 PM
                            > > To: ntb-scripts@yahoogroups.com
                            > > Subject: Re: [NTS] Using Python instead of Perl
                            > >
                            > >
                            > > Jason,
                            > >
                            > > Fire away. I'm just learning PERL and thinking about
                            > > switching to Python instead because I forget everything in
                            > > between immersions. I hear Python is easier to read and remember.
                            > >
                            > > Rick
                            > >
                            > > --- In ntb-scripts@yahoogroups.com, "Jason Morgan" <jason@d...> wrote:
                            > > > Not sure if anyone is interested, but I've managed to create clips
                            > > > that will run Python code (which is what I mainly use). If
                            > > anyone is
                            > > > interested, let me know.
                            > > >
                            > > > --
                            > > > Jason Morgan
                            > > > Senior Programmer
                            > > > Decipher, Inc.
                            > > > p 800.923.5523
                            > >
                            > >
                            > >
                            > >
                            > > ------------------------ Yahoo! Groups Sponsor
                            > > --------------------~-->
                            > > Get Bzzzy! (real tools to help you find a job). Welcome to
                            > > the Sweet Life.
                            > > http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/NhFolB/TM
                            > > --------------------------------------------------------------
                            > > ------~->
                            > >
                            > > ntb-scripts-unsubscribe@yahoogroups.com
                            > >
                            > >
                            > > Yahoo! Groups Links
                            > >
                            > >
                            > >
                            > >
                            > >
                            > >
                            >
                          • rpdooling
                            Jason, For purposes of comparison, this DOES work: ^!Info ^$GetOutput(python -c import sys;print sys.version )$ So I m thinking it s some quirk in Python or
                            Message 13 of 19 , Oct 19 5:43 PM
                              Jason,

                              For purposes of comparison, this DOES work:

                              ^!Info ^$GetOutput(python -c "import sys;print sys.version")$

                              So I'm thinking it's some quirk in Python or NoteTab that sends the
                              output of a regular commandline Python command to StdErr.err instead
                              of allowing NoteTab to grab it with the ^$GetOutput()$ function.

                              Oh well.

                              rd

                              --- In ntb-scripts@yahoogroups.com, "rpdooling" <rpdooling@y...> wrote:
                              >
                              > Jason,
                              >
                              > Any idea why I can't get something like this to work? It works fine
                              > from the command line no matter what directory I'm in.
                              >
                              > ^!Info ^$GetOutput("python -V")$
                              >
                              > --- In ntb-scripts@yahoogroups.com, "Jason Morgan" <jason@d...> wrote:
                              > >
                              > > Rick,
                              > >
                              > > From my point of view, Python is much easier to understand than Perl.
                              > > If you have any experience with other Object Oriented languages,
                              such as
                              > > C/C++, Python should be a snap for you.
                              > > As the majority of my clips are very specialized to my needs, I'm
                              > > including a very simple example that should give you an idea of how to
                              > > get started. You will need to install Python, which is free and
                              can be
                              > > downloaded from www.python.org. There you can also find almost
                              > > everything you need to get started programming in Python.
                              > >
                              > > H="Sort"
                              > > ^!RunScript C:\python24\python.exe sort
                              > >
                              > > H="sort"
                              > > from sys import stdin
                              > > input = stdin.read().split('\n')
                              > > input.sort()
                              > > print '\n'.join(input)
                              > >
                              > > --
                              > > Jason Morgan
                              > > Senior Programmer
                              > > Decipher, Inc.
                              > > p 800.923.5523
                              > >
                              > >
                              > > > -----Original Message-----
                              > > > From: ntb-scripts@yahoogroups.com
                              > > > [mailto:ntb-scripts@yahoogroups.com] On Behalf Of rpdooling
                              > > > Sent: Wednesday, September 28, 2005 2:46 PM
                              > > > To: ntb-scripts@yahoogroups.com
                              > > > Subject: Re: [NTS] Using Python instead of Perl
                              > > >
                              > > >
                              > > > Jason,
                              > > >
                              > > > Fire away. I'm just learning PERL and thinking about
                              > > > switching to Python instead because I forget everything in
                              > > > between immersions. I hear Python is easier to read and remember.
                              > > >
                              > > > Rick
                              > > >
                              > > > --- In ntb-scripts@yahoogroups.com, "Jason Morgan" <jason@d...>
                              wrote:
                              > > > > Not sure if anyone is interested, but I've managed to create
                              clips
                              > > > > that will run Python code (which is what I mainly use). If
                              > > > anyone is
                              > > > > interested, let me know.
                              > > > >
                              > > > > --
                              > > > > Jason Morgan
                              > > > > Senior Programmer
                              > > > > Decipher, Inc.
                              > > > > p 800.923.5523
                              > > >
                              > > >
                              > > >
                              > > >
                              > > > ------------------------ Yahoo! Groups Sponsor
                              > > > --------------------~-->
                              > > > Get Bzzzy! (real tools to help you find a job). Welcome to
                              > > > the Sweet Life.
                              > > > http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/NhFolB/TM
                              > > > --------------------------------------------------------------
                              > > > ------~->
                              > > >
                              > > > ntb-scripts-unsubscribe@yahoogroups.com
                              > > >
                              > > >
                              > > > Yahoo! Groups Links
                              > > >
                              > > >
                              > > >
                              > > >
                              > > >
                              > > >
                              > >
                              >
                            • acummingsus
                              Hi Rick, Have you tried ^$GetDosOutput( whatever command )$ sometimes GetDosOutput works other times GetOutput works Of the two, Perl generally seems to like
                              Message 14 of 19 , Oct 19 9:47 PM
                                Hi Rick,

                                Have you tried

                                ^$GetDosOutput("whatever command")$

                                sometimes GetDosOutput works

                                other times GetOutput works

                                Of the two, Perl generally seems to like the GetDosOutput better.

                                I suppose your Python binary and pertinent libraries are in your OS
                                environment search path or otherwise you'd also have a problem in a
                                console too. (and you don't have prob in console)

                                None of those search paths in $PATH (for Python) have a space in the
                                path? I'm thinking: if space then ntb may need use of the GetShort()

                                Perl has no space in path. Likely Python doesn't either.

                                I'd try Python now. But I'm too far along down (or up) into the
                                *depth* of the Perl pool or lake or whatever it is. And, vision sees
                                Perl falling together before too long now.

                                I'll try Python after that happens.

                                Alan.

                                --- In ntb-scripts@yahoogroups.com, "rpdooling" <rpdooling@y...> wrote:
                                >
                                > Jason,
                                >
                                > For purposes of comparison, this DOES work:
                                >
                                > ^!Info ^$GetOutput(python -c "import sys;print sys.version")$
                                >
                                > So I'm thinking it's some quirk in Python or NoteTab that sends the
                                > output of a regular commandline Python command to StdErr.err instead
                                > of allowing NoteTab to grab it with the ^$GetOutput()$ function.
                                >
                                > Oh well.
                                >
                                > rd
                                >
                                > --- In ntb-scripts@yahoogroups.com, "rpdooling" <rpdooling@y...> wrote:
                                > >
                                > > Jason,
                                > >
                                > > Any idea why I can't get something like this to work? It works fine
                                > > from the command line no matter what directory I'm in.
                                > >
                                > > ^!Info ^$GetOutput("python -V")$
                                > >
                                > > --- In ntb-scripts@yahoogroups.com, "Jason Morgan" <jason@d...> wrote:
                                > > >
                                > > > Rick,
                                > > >
                                > > > From my point of view, Python is much easier to understand than
                                Perl.
                                > > > If you have any experience with other Object Oriented languages,
                                > such as
                                > > > C/C++, Python should be a snap for you.
                                [ . . ]
                              • rpdooling
                                Thanks, Alan, Same result with GetDosOutput. I tried that before posting. It sends the version number to StdErr. The python path has no spaces. As for Python
                                Message 15 of 19 , Oct 20 7:16 AM
                                  Thanks, Alan,

                                  Same result with GetDosOutput. I tried that before posting. It sends
                                  the version number to StdErr. The python path has no spaces.

                                  As for Python vs. Perl, it's one of those holy wars, like Emacs vs.
                                  vi. I was told to try both, so I bought a book on Perl and another on
                                  Python. I already have Perl scripts and I'll keep using them. I'll let
                                  you know more after I learn more Python.

                                  Rick

                                  --- In ntb-scripts@yahoogroups.com, "acummingsus" <acummingsus@g...>
                                  wrote:
                                  >
                                  > Hi Rick,
                                  >
                                  > Have you tried
                                  >
                                  > ^$GetDosOutput("whatever command")$
                                  >
                                  > sometimes GetDosOutput works
                                  >
                                  > other times GetOutput works
                                  >
                                  > Of the two, Perl generally seems to like the GetDosOutput better.
                                  >
                                  > I suppose your Python binary and pertinent libraries are in your OS
                                  > environment search path or otherwise you'd also have a problem in a
                                  > console too. (and you don't have prob in console)
                                  >
                                  > None of those search paths in $PATH (for Python) have a space in the
                                  > path? I'm thinking: if space then ntb may need use of the GetShort()
                                  >
                                  > Perl has no space in path. Likely Python doesn't either.
                                  >
                                  > I'd try Python now. But I'm too far along down (or up) into the
                                  > *depth* of the Perl pool or lake or whatever it is. And, vision sees
                                  > Perl falling together before too long now.
                                  >
                                  > I'll try Python after that happens.
                                  >
                                  > Alan.
                                  >
                                  > --- In ntb-scripts@yahoogroups.com, "rpdooling" <rpdooling@y...> wrote:
                                  > >
                                  > > Jason,
                                  > >
                                  > > For purposes of comparison, this DOES work:
                                  > >
                                  > > ^!Info ^$GetOutput(python -c "import sys;print sys.version")$
                                  > >
                                  > > So I'm thinking it's some quirk in Python or NoteTab that sends the
                                  > > output of a regular commandline Python command to StdErr.err instead
                                  > > of allowing NoteTab to grab it with the ^$GetOutput()$ function.
                                  > >
                                  > > Oh well.
                                  > >
                                  > > rd
                                  > >
                                  > > --- In ntb-scripts@yahoogroups.com, "rpdooling" <rpdooling@y...>
                                  wrote:
                                  > > >
                                  > > > Jason,
                                  > > >
                                  > > > Any idea why I can't get something like this to work? It works fine
                                  > > > from the command line no matter what directory I'm in.
                                  > > >
                                  > > > ^!Info ^$GetOutput("python -V")$
                                  > > >
                                  > > > --- In ntb-scripts@yahoogroups.com, "Jason Morgan" <jason@d...>
                                  wrote:
                                  > > > >
                                  > > > > Rick,
                                  > > > >
                                  > > > > From my point of view, Python is much easier to understand than
                                  > Perl.
                                  > > > > If you have any experience with other Object Oriented languages,
                                  > > such as
                                  > > > > C/C++, Python should be a snap for you.
                                  > [ . . ]
                                  >
                                Your message has been successfully submitted and would be delivered to recipients shortly.