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

Re: [Clip] Re: Newbie question: Running Perl Scripts

Expand Messages
  • Larry Thomas
    Hi Stephanie, ... 1. Right click over the Perl Script clip and select Copy to Clipboard 2. Right click over the combo box at the top of the clipbook
    Message 1 of 6 , Aug 10, 2000
      Hi Stephanie,

      At 04:35 AM 08/10/2000 -0000, you wrote:
      >Hi Larry and others,
      >Thanks for the correction. Found the clip, but can't seem to get
      >anything out of it. All the clip seems to do is number the lines...
      >Like I said, I'm new at this and am not really sure how that helps
      >me. I'm just trying to run the standard, "Hello, world" script that
      >has 1 line of code. I can get the script to work when I add the
      >shebang line and upload it to the web. I just need to be able to run
      >it offline and locally.
      >
      >Can anyone give me some tips?
      >Thanks.


      1. Right click over the Perl Script clip and select "Copy to Clipboard"
      2. Right click over the combo box at the top of the clipbook display.
      3. Enter the name you want for a new clipbook library and press ok.
      4. Right click over the list portion of the new clipbook and select "Add
      from Clipboard" then ok to add the Perl Script clip to it.
      5. Right click over the list portion of the new clipbook and select "Add
      New Clip".
      6. Type in _HelloWorld for the name and click ok.
      7. Enter or copy/paste the script you have for Hellow World into the new
      clip.
      8. Switch to the Perl Script to edit it.
      9. Edit the line: ^!RunPerl Perl NumLines and replace Perl NumLines with
      HelloWorld.
      10. Save the clip book.

      Now you can run the Perl Script clip and it should do what you want. You
      may want to run it on an empty document since it appears to send a line of
      text as its output. Otherwise you can just check your current document to
      see if the output was added to it.

      Regards,

      Larry
      larryt@...
    • schau
      ... lines... ... that ... run ... Clipboard ... display. ... select Add ... select Add ... the new ... NumLines with ... want. You ... line of ... document
      Message 2 of 6 , Aug 12, 2000
        --- In ntb-clips@egroups.com, Larry Thomas <larryt@c...> wrote:
        >
        > Hi Stephanie,
        >
        > At 04:35 AM 08/10/2000 -0000, you wrote:
        > >Hi Larry and others,
        > >Thanks for the correction. Found the clip, but can't seem to get
        > >anything out of it. All the clip seems to do is number the
        lines...
        > >Like I said, I'm new at this and am not really sure how that helps
        > >me. I'm just trying to run the standard, "Hello, world" script
        that
        > >has 1 line of code. I can get the script to work when I add the
        > >shebang line and upload it to the web. I just need to be able to
        run
        > >it offline and locally.
        > >
        > >Can anyone give me some tips?
        > >Thanks.
        >
        >
        > 1. Right click over the Perl Script clip and select "Copy to
        Clipboard"
        > 2. Right click over the combo box at the top of the clipbook
        display.
        > 3. Enter the name you want for a new clipbook library and press ok.
        > 4. Right click over the list portion of the new clipbook and
        select "Add
        > from Clipboard" then ok to add the Perl Script clip to it.
        > 5. Right click over the list portion of the new clipbook and
        select "Add
        > New Clip".
        > 6. Type in _HelloWorld for the name and click ok.
        > 7. Enter or copy/paste the script you have for Hellow World into
        the new
        > clip.
        > 8. Switch to the Perl Script to edit it.
        > 9. Edit the line: ^!RunPerl Perl NumLines and replace Perl
        NumLines with
        > HelloWorld.
        > 10. Save the clip book.
        >
        > Now you can run the Perl Script clip and it should do what you
        want. You
        > may want to run it on an empty document since it appears to send a
        line of
        > text as its output. Otherwise you can just check your current
        document to
        > see if the output was added to it.
        >
        > Regards,
        >
        > Larry
        > larryt@c...


        Hi Larry,
        I did what you said, but...nothing happened.
        Let me see if I got everything right. I have a new clipbook with a
        clip called _HelloWorld and it contains the perl scipt clip + my
        hello world script. Perl NumLines is replaced with HelloWorld. So
        that line reads ^!RunPerl HelloWorld
        Then open a new document and run the script. I tried running it but
        nothing happened. I didn't get an error or any type of output. Maybe
        I have something configured wrong?

        I also tried just viewing the script through a browser but when I did
        that, an MS-DOS window opened, flashed something, and then the window
        closed. I think it flashed Hello World, but it was so quick, it
        wouldn't be a useful method for testing scripts.

        Thanks for trying to help me. I really appreciate it. Maybe I need
        to just play around with it some more...

        Thanks again,
        Stephanie
      • Larry Thomas
        Hi Stephanie, ... The problem it appears to me is that you have placed both clips into one clip instead of having them separate. You need to have one copy of
        Message 3 of 6 , Aug 12, 2000
          Hi Stephanie,

          At 10:43 PM 08/12/2000 -0000, you wrote:
          >Hi Larry,
          >I did what you said, but...nothing happened.
          >Let me see if I got everything right. I have a new clipbook with a
          >clip called _HelloWorld and it contains the perl scipt clip + my
          >hello world script. Perl NumLines is replaced with HelloWorld. So
          >that line reads ^!RunPerl HelloWorld
          >Then open a new document and run the script. I tried running it but
          >nothing happened. I didn't get an error or any type of output. Maybe
          >I have something configured wrong?

          The problem it appears to me is that you have placed both clips into one
          clip instead of having them separate. You need to have one copy of the
          original Perl Script clip with the Perl Numlines replaced by HelloWorld and
          a second clip name _HelloWorld that contains your perl script. You run
          Perl Script and it will use _HelloWorld as the script source and the
          current document as the output target.

          I have not learned Perl but I am basing my advice on the fact that you got
          the original Perl Script to run properly in the SampleCode Library. There
          is no difference here between that one and yours except for the name of the
          clip containing the Perl script and the script in it so it should produce
          output if the other one does - unless there is something in the script
          itself that prevents it or a mispelling in the clips.

          I will tell you that if you only have one clip names _HelloWorld with
          everything in it, you will not be able to run it at all because the
          underscore at the beginning of the name prevents the clip from being run by
          clicking on it. Only another clip can run it as a subroutine. So you
          would not get anything at all when you tried to run this clip. You can see
          that you cannot run it by the fact that it is greyed out in the clip list.
          Go to the SampleCode Library and you will see that Perl Script is in normal
          type and when you look below you will see several clip names including Perl
          NumLines which are greyed out. If they were not you could double click on
          them and the script they contain would be dumped into your current document
          as is. But as they are, you can click on them as much as you want and they
          will not execute at all which is as NoteTab was designed to work. Eric
          provided that option so that we could write clips as subroutines to be
          called by other clips that a user could not accidentally execute directly.

          Regards,

          Larry
          larryt@...
        • Larry Hamilton
          Hi Stephanie, Larry T., ... I have been working on some things with Perl, no I do not know Perl, just trying to use some canned scripts. I built the following
          Message 4 of 6 , Aug 12, 2000
            Hi Stephanie, Larry T.,

            On Sat, 12 Aug 2000 18:59:22 -0500, ntb-clips@egroups.com wrote:
            >The problem it appears to me is that you have placed both clips into
            >one clip instead of having them separate. You need to have one copy

            I have been working on some things with Perl, no I do not know Perl,
            just trying to use some canned scripts.

            I built the following clip from scratch, since I have worked with
            some other languages trying to get them to run.

            One thing I noticed with Perl is that it makes the DOS window pop up
            and close so quickly, that it is working, one just cannot see what it
            is doing. Also, some Perl scripts will change the open document. I
            started trying to do the following with ^!RunPerl, but was not
            getting it to work. It uses an ^!Info box to display the results of
            the Perl script. It just shows that there is more than one way to run
            a Perl script in NoteTab. ;-)

            I was having problems getting ^!RunPerl to work in a way that I could
            show the results in a new document or in an ^!Info window. Is this
            something that needs to be done with Perl, or is there a way I
            overlooked to do this with ^!RunPerl? I have Wayne's NoteAwk, but it
            applies it to the current document if it is just a display clip, like
            hello world. I guess one could add a new document line in the clip,
            before the Perl script is called... Well, I have had a long week at
            work, among other things, so I am starting to ramble. I will stop now
            and leave it to the coherent to correct the incoherent.

            ;08/11/2000
            ;Larry Hamilton, Clips list lm_hamilton@...
            ^!SetListDelimiter=|
            ;Long line follows:
            ^!Set
            %List%=^$StrReplace("^$GetScriptPath$";;"^$GetFiles("^$GetScriptPath$"
            ;"*.pl")$";False;False)$
            ^!Set %Value%=^?{(H=15)Choose Perl program to execute==^%List%}
            ^!Info ^$GetOutput("Perl.exe d:\notetab\scripts\^%Value%")$

            HTH,
            -- Larry Hamilton, lm_hamilton@... on 08/12/2000
          • Larry Thomas
            Hi Stephanie and Larry H., ... I have decided to start trying to learn Perl from this thread. I have ActiveState Perl but I do not yet have it installed.
            Message 5 of 6 , Aug 12, 2000
              Hi Stephanie and Larry H.,

              At 09:50 PM 08/12/2000 -0500, Larry H Wrote:
              >Hi Stephanie, Larry T.,
              >
              >I have been working on some things with Perl, no I do not know Perl,
              >just trying to use some canned scripts.
              >

              I have decided to start trying to learn Perl from this thread. I have
              ActiveState Perl but I do not yet have it installed. Will do it shortly.
              I just wrote the following scripts for myself to get started and for anyone
              else that can use them.

              The first two are for testing scripts to see how they work in Perl and with
              NoteTab. The _Test Script clip contains the Perl NumLines script from the
              SampleCode Library. It should give you the same results and running the
              Perl Script clip in the SampleCode Library. To test new scripts just
              delete the content of _Test Script and type or copy/paste your new script
              in and save it and run Perl Script Tester on an open document to see the
              restults.

              The third clip runs scripts that are saved as .pl files in NoteTab's script
              folder. If you have saved any such scripts just run it and select the
              browse button and select the script you want, click ok and then ok again to
              run it.

              The last clip needs a clipbar button to work the way I intend it to work.
              When you are in the _Test Script clip and have a script you are happy with
              run this clip from the clipbar and it will copy the script and paste it to
              a new document and open a save dialog to save it to the script folder as a
              .pl file. Just type in the name you want to save the file as with out an
              extension and the file will be saved with the .pl extension added.

              Notice that I used a variable in two of the clips to avoid having the clips
              messed up due to long lines - that is I kept the lines short.

              ______[Copy below this line]_______
              H="Perl Script Tester"
              ;Larry Thomas <larryt@...>
              ;08/12/2000, 09:58:37 PM
              ^!IfFileExist ^$GetPerlExe$ Next ELSE NoPerl
              ^!DeleteFile ^$GetAppPath$StdError.err
              ^!RunPerl Test Script
              ^!IfFileExist ^$GetAppPath$StdError.err Next ELSE End
              ^!Open ^$GetAppPath$StdError.err
              ^!Prompt Perl has reported some errors!
              ^!GoTo End
              :NoPerl
              ^!Prompt Cannot execute this Clip without a Perl interpreter!


              H="_Test Script"
              #
              #  \perl\numline.pl
              #
              # begin
              while (<>) {
              $x=sprintf("%05d",$.);
              print "$x $_";
              }
              # end


              H="Run Perl Script"
              ;Larry Thomas <larryt@...>
              ;08/12/2000, 09:58:37 PM
              ^!IfFileExist ^$GetPerlExe$ Next ELSE NoPerl
              ^!DeleteFile ^$GetAppPath$StdError.err
              ^!Set %WizardEnd%=Select a Script to Run=^$GetScriptPath$
              ^!RunPerl ^?{(T=O;F="Script Files (*.pl)|*.pl")^%WizardEnd%}
              ^!IfFileExist ^$GetAppPath$StdError.err Next ELSE End
              ^!Open ^$GetAppPath$StdError.err
              ^!Prompt Perl has reported some errors!
              ^!GoTo End
              :NoPerl
              ^!Prompt Cannot execute this Clip without a Perl interpreter!


              H="Save Script"
              ;Larry Thomas <larryt@...>
              ;08/12/2000, 09:58:37 PM
              ^!Toolbar Copy All
              ^!Toolbar Paste New
              ^!Set %WizardEnd%=Enter File Name=^$GetScriptPath$
              ^!Save As ^?{(T=S;F="Script Files (*.pl)|*.pl")^%WizardEnd%}.pl
              _____[Copy above this line]______
              | right click over the clipbook |
              | and choose "Add from Clipboard" |
              ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

              Regards,

              Larry
              larryt@...
            • Larry Hamilton
              Hi Larry T., Stephanie, ... That s on my list of things to do before I die... ;-) It s a long list. Learning Perl is on the end of the list at the moment.
              Message 6 of 6 , Aug 13, 2000
                Hi Larry T., Stephanie,

                On Sat, 12 Aug 2000 22:18:48 -0500, ntb-clips@egroups.com wrote:
                >I have decided to start trying to learn Perl from this thread.

                That's on my list of things to do before I die... ;-) It's a long
                list. Learning Perl is on the end of the list at the moment. Although
                I keep running into reasons to learn it. Maybe its an indication it
                needs to move up the list?

                >I just wrote the following scripts for myself to get started and for
                >anyone else that can use them.

                Thanks. Useful tools for the learning process.
                -- Larry Hamilton, lm_hamilton@... on 08/14/2000
              Your message has been successfully submitted and would be delivered to recipients shortly.