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

Re: [NTS] Re: [Clip] Basic tips on using Perl progs?

Expand Messages
  • Alec Burgess
    Ian: followup This clip: H= direct Perl ^!RunPerl C: TEMP simpletest.pl with this file: #simpletest.pl # Begining of script print ; LOOP: while ( ) {
    Message 1 of 7 , Jul 7, 2005
    View Source
    • 0 Attachment
      Ian: followup

      This clip:
      H="direct Perl"
      ^!RunPerl C:\TEMP\simpletest.pl

      with this file:
      #simpletest.pl
      # Begining of script
      print "<p>";
      LOOP: while (<>) {
      print;
      }
      print "<p>"
      # End of script simple test

      does what you want - but still has the problem with the blockchar before the closing <p>

      let me know if you solve the block char problem.

      Regards ... Alec
      --
      ; ( ) { } [ ] \ | 9 0 + = () {} []

      ----- Original Message -----
      From: Ian Rastall
      To: ntb-scripts@yahoogroups.com
      Sent: Thursday, July 07, 2005 19:16
      Subject: [gla: [NTS] Re: [Clip] Basic tips on using Perl progs?


      Hi all. I'm not sure if you saw the cross-posted email from before,
      but I'm practising my perl skills with clips, and would like a few
      pointers just to get started. (Of course, further confusion will
      probably follow.) :-)

      This is a simple clip I had in my clip library:

      ^!InsertHtml <p>^$GetSelection$</p>

      To try to duplicate it in perl, I've written, as a .pl file:

      $_ = <STDIN>;
      $_ = "<p>".$_."</p>";

      and call it with the following clip:

      ^!RunPerl C:\Perl\test.pl

      Now, I'm sure the perl script represents a fundamental
      misunderstanding both of how perl works, and how NoteTab sends
      information to the interpreter. But if anyone could steer me in the
      right direction, I would sure appreciate it!

      [Non-text portions of this message have been removed]
    • Alan C
      Hi. 4 clips follow (U do not need to make a .pl file unless U want to) - I often do not use .pl file but instead do like the next 4 clips which I think is how
      Message 2 of 7 , Jul 7, 2005
      View Source
      • 0 Attachment
        Hi. 4 clips follow (U do not need to make a .pl file unless U want to)
        - I often do not use .pl file but instead do like the next 4 clips which
        I think is how it's done in samplecode library also.

        pl_ctrl_char2 might needed as the first one (without the 2) (2 is
        Shari's solution) , first 1 I pasted the actual box char which might not
        make it thru email.

        H="pl_ptagger"
        ^!RunPerl pl_ptagr
        ^!RunPerl pl_ctrl_char

        H="_pl_ptagr"
        while (<>) {
        print "<p>";
        print ;
        print "</p>";
        }

        H="_pl_ctrl_char"
        # rids of pesky box char 26 Ntab issue
        while (<>) {
        s/\//;
        print ;
        }

        H="_pl_ctrl_char2"
        while (<>) {
        if (eof && $] > 5.006) {
        $badchar = chr(26);
        s/($badchar)$//;
        }
        print ;
        # end

        Alec Burgess wrote:

        >Ian: followup
        >
        >This clip:
        >H="direct Perl"
        >^!RunPerl C:\TEMP\simpletest.pl
        >
        >with this file:
        >#simpletest.pl
        ># Begining of script
        >print "<p>";
        >LOOP: while (<>) {
        >print;
        >}
        >print "<p>"
        ># End of script simple test
        >
        >does what you want - but still has the problem with the blockchar before the closing <p>
        >
        >let me know if you solve the block char problem.
        >
        >Regards ... Alec
        >
        >
      • Alan C
        ... Oop, that does a line by line basis. if U multiple lines selected then each line gets p tags. The Perl input record separator needs changed to slurp mode
        Message 3 of 7 , Jul 8, 2005
        View Source
        • 0 Attachment
          Alan C wrote:

          >
          >H="pl_ptagger"
          >^!RunPerl pl_ptagr
          >^!RunPerl pl_ctrl_char
          >
          >H="_pl_ptagr"
          >while (<>) {
          >print "<p>";
          >print ;
          >print "</p>";
          >}
          >
          Oop, that does a line by line basis. if U multiple lines selected then
          each line gets p tags.

          The Perl input record separator needs changed to slurp mode if u do not
          want each of multi lines in such a case as that p tagged.

          undef $/; # Enter "file slurp" mode

          H="_pl_ptagr"
          undef $/; # Enter "file slurp" mode
          while (<>) {
          print "<p>";
          print ;
          print "</p>";
          }
          # end


          print "</p>";might need to be

          print "<\/p>";

          or might need to be

          print '</p>';
          --

          LOTS to it all (Perl is a full fledged programming language, a rather powerful one). But Perl is kind in that easy things R easy which means we can Perl at our level of expertise until we learn more and graduate upward.

          I find the need to just play with the stuff ie experiment. a mechanical sort of learning.

          (I'm on Linux I fired up Notetab on wine but I cannot have Ntab call my Linux Perl) so I'm just going from previous experience on writing those clips.

          If you have more issues, post here on the list again. I'll try to do what I can. I'm somewhere near intermediate skill level on Perl now. And I still fire up windows once in a while although not as much as Linux.

          Alan.
        • Ian Rastall
          ... Hi Alec. One solution I ve found is to run HTML Tidy, although that only works in HTML. I have a lot of reading tonight, after the clips you ve posted.
          Message 4 of 7 , Jul 8, 2005
          View Source
          • 0 Attachment
            On Fri, 8 Jul 2005 00:43:12 -0400, Alec wrote:

            >let me know if you solve the block char problem.

            Hi Alec. One solution I've found is to run HTML Tidy, although that
            only works in HTML.

            I have a lot of reading tonight, after the clips you've posted.
            Thanks!

            Ian
            --
            Was it not a comedy, a strange and stupid
            matter, this repetition, this running around
            in a fateful circle? (Hermann Hesse)
            http://www.bookstacks.org/
          • Ian Rastall
            Hi Alan. Thanks for the help. I ll have to pore over it for a while. ... Ian -- Was it not a comedy, a strange and stupid matter, this repetition, this running
            Message 5 of 7 , Jul 8, 2005
            View Source
            • 0 Attachment
              Hi Alan. Thanks for the help. I'll have to pore over it for a while.
              :-)

              Ian
              --
              Was it not a comedy, a strange and stupid
              matter, this repetition, this running around
              in a fateful circle? (Hermann Hesse)
              http://www.bookstacks.org/
            • Alec Burgess
              Hi Alan, Ian Alan: I tried it with both the straight substitution after putting bax the box car which got eaten by yahoo-groups. pl_ctrl_char: AFAICT: it eats
              Message 6 of 7 , Jul 8, 2005
              View Source
              • 0 Attachment
                Hi Alan, Ian

                Alan:
                I tried it with both the straight substitution after putting bax the box car which got eaten by yahoo-groups.

                pl_ctrl_char:
                AFAICT: it eats the box char left before the closing <p> but then deposits its own *after* the closing <p>

                so *selectedtext* --> <p>*selectedtext*<boxchar><p> w/o pl_ctrl_char
                but *selectedtext* --> <p>*selectedtext<p>*<boxchar> with pl_ctrl_char

                Sherri's pl_ctrl_char:
                This works!!

                I'll have to start doing more with Perl scripts again. I think I like using a direct invocation of a script file rather than a two or three level script clip - makes testing easier.

                Ian: Using HTML-Tidy to get rid of the box char is ingenious :-) It doesn't even seem to generate an error-file, just gets rid of the box char.
                -- I'm glad you asked your question.

                Regards ... Alec
                --
                ; ( ) { } [ ] \ | 9 0 + = () {} []

                ----- Original Message -----
                From: Alan C
                To: ntb-scripts@yahoogroups.com
                Sent: Friday, July 08, 2005 02:34
                Subject: [gla: Re: [NTS] Re: [Clip] Basic tips on using Perl progs?


                Hi. 4 clips follow (U do not need to make a .pl file unless U want to)
                - I often do not use .pl file but instead do like the next 4 clips which
                I think is how it's done in samplecode library also.

                pl_ctrl_char2 might needed as the first one (without the 2) (2 is
                Shari's solution) , first 1 I pasted the actual box char which might not
                make it thru email.

                H="pl_ptagger"
                ^!RunPerl pl_ptagr
                ^!RunPerl pl_ctrl_char

                H="_pl_ptagr"
                while (<>) {
                print "<p>";
                print ;
                print "</p>";
                }

                H="_pl_ctrl_char"
                # rids of pesky box char 26 Ntab issue
                while (<>) {
                s/\//;
                print ;
                }

                H="_pl_ctrl_char2"
                while (<>) {
                if (eof && $] > 5.006) {
                $badchar = chr(26);
                s/($badchar)$//;
                }
                print ;
                # end



                [Non-text portions of this message have been removed]
              Your message has been successfully submitted and would be delivered to recipients shortly.