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

[NTB] How do I give arguments from NoteTab Pro v4.52 to Perl

Expand Messages
  • Rafael Badziag
    Assume I write a Perl program as a Clip: Grep getting as argument a string to search for in the input stream and giving out all lines with this string to the
    Message 1 of 4 , Jan 12, 1999
      Assume I write a Perl program as a Clip: Grep getting as argument a string to
      search for in the input stream and giving out all lines with this string to the
      output stream.

      Question: How is it possible to give this string as an argument from Note Pad
      Pro v4.52 to Perl?

      A dos command to execute this programm (assuming i saved it as grep.pl) would
      be:
      perl grep.pl "string to search for" < "file to search in"

      In NoteTab Pro:
      If I write a Clip like:
      ^? (here some Note Tab script command to input the string %str% to search for)
      ^! RunPerl Grep
      this will NOT give the given string as an argument to the perl program.

      If I write:
      ^? (here some Note Tab script command to input the string %str% to search for)
      ^! RunPerl Grep %str%
      nothing happens, since there is no such clip like "Grep home" assuming I entered
      "home" as %str%

      Does anybody know a solution to this problem?

      Regards,
      Rafael Badziag


      ------------------------------------------------------------------------
      eGroup home: http://www.eGroups.com/list/notetab
      Free Web-based e-mail groups by eGroups.com
    • Wayne M. VanWeerthuizen
      ... You should take a look at NoteAwk. It is a clipbook I wrote that does grep along with several other things. It also has a clip to aid in running Perl
      Message 2 of 4 , Jan 12, 1999
        Rafael Badziag <badziag@...> wrote:
        >Assume I write a Perl program as a Clip: Grep getting as argument a string to
        >search for in the input stream and giving out all lines with this string to the
        >output stream.
        >
        >Question: How is it possible to give this string as an argument from Note Pad
        >Pro v4.52 to Perl?

        You should take a look at NoteAwk. It is a clipbook I wrote that
        does grep along with several other things. It also has a clip
        to aid in running Perl scripts.

        http://www2.localaccess.com/waynemv/notetab.htm



        --
        Wayne M. VanWeerthuizen
        ICQ: 15117288
        Homepage: http://www2.localaccess.com/waynemv

        ------------------------------------------------------------------------
        eGroup home: http://www.eGroups.com/list/notetab
        Free Web-based e-mail groups by eGroups.com
      • David Seidman
        ... to ... to the ... Pad ... would ... Wayne has suggested, I think, that you use his NoteAwk instead of this approach, and that is a fine suggestion. On the
        Message 3 of 4 , Jan 12, 1999
          At 10:54 AM 1/12/1999 +0100, Rafael Badziag wrote:
          >Assume I write a Perl program as a Clip: Grep getting as argument a string
          to
          >search for in the input stream and giving out all lines with this string
          to the
          >output stream.
          >
          >Question: How is it possible to give this string as an argument from Note
          Pad
          >Pro v4.52 to Perl?
          >
          >A dos command to execute this programm (assuming i saved it as grep.pl)
          would
          >be:
          >perl grep.pl "string to search for" < "file to search in"
          >
          Wayne has suggested, I think, that you use his NoteAwk instead of this
          approach, and that is a fine suggestion. On the other hand, in some
          circumstances you may want to look at
          ^$GetOutput(command)$
          where "command" is perl followed by the rest of your command string
          instead of
          ^$RunPerl
          because it is more flexible. But the handling of quotation can be a problem.





          David Seidman | voice: 202-462-7381 |WPTOOLS, WPMD, |
          Software by Seidman | fax : 202-462-8601 |MORETOOLS, 7to6 |
          2737 Devonshire Pl. NW | seidmand@... |MACROAID, 6TOOLS|
          Washington, DC 20008 |http://world.ase.com/seidman |and DOCTOR 6 |

          ------------------------------------------------------------------------
          eGroup home: http://www.eGroups.com/list/notetab
          Free Web-based e-mail groups by eGroups.com
        • Wayne M. VanWeerthuizen
          ... When I was originally trying to call gawk with parameters, I had some trouble. But, this was several NoteTab revisions ago, and Eric may have fixed the
          Message 4 of 4 , Jan 12, 1999
            David Seidman <seidmand@...> wrote:
            >At 10:54 AM 1/12/1999 +0100, Rafael Badziag wrote:
            >>Assume I write a Perl program as a Clip: Grep getting as argument a string
            >to
            >>search for in the input stream and giving out all lines with this string
            >to the
            >>output stream.
            >>
            >>Question: How is it possible to give this string as an argument from Note
            >Pad
            >>Pro v4.52 to Perl?
            >>
            >>A dos command to execute this programm (assuming i saved it as grep.pl)
            >would
            >>be:
            >>perl grep.pl "string to search for" < "file to search in"
            >>
            > Wayne has suggested, I think, that you use his NoteAwk instead of this
            >approach, and that is a fine suggestion. On the other hand, in some
            >circumstances you may want to look at
            >^$GetOutput(command)$
            >where "command" is perl followed by the rest of your command string
            >instead of
            >^$RunPerl
            >because it is more flexible. But the handling of quotation can be a problem.

            When I was originally trying to call gawk with parameters, I had some
            trouble. But, this was several NoteTab revisions ago, and Eric may
            have fixed the issue. I solved the problem by having NoteAwk
            generate the scripts on the fly. No parameters are ever needed, as
            any values would instead be inserted into the script itself.


            What I have successfully done is call GNU Sort with parameters. Here
            is part of NoteAwk's "Power Sorting with GNU Sort" clip.

            ; Realize there was a lot more to the clip before this point.

            ; Combine parameters into one variable.
            ^!SET %PARMS%="^%FS% ^%IGNORE% ^%CASE% ^%REVERSE% ^%DUPS% ^%GNUSEQ%"


            ; Get names of some temporary files.
            ^!SET %INFILE%="^$GetShort("^$GetTempFile$")$"
            ^!SET %OUTFILE%="^$GetShort("^$GetTempFile$")$"

            ; Apply sorting to entire document, of just to selection.
            ^!IF "^$GetSelSize$" > "0" :SelectionMade
            ^!SELECT ALL
            :SelectionMade

            ; Put the text to be sorted into a temporary disk file.
            ^!EXPORT "^%INFILE%" ASCII SELECTION

            ; Next line is for debugging. It was accidentally left in the
            ; released version of NoteAwk. (Causing an extra message box
            ; to appear. Sorry.)
            ;^!Info [^$GetShort("^%SortExe%")$ ^%PARMS% <^%INFILE% >^%OUTFILE%]

            ; Call sort, and with parameters. Path to sort is in the ^%SortExe%
            ; variable.

            ^!DOS ^$GetShort("^%SortExe%")$ ^%PARMS% <^%INFILE% >^%OUTFILE%
            ^!WAIT

            ; Put results into NoteTab window, replaces selected text.
            ^!InsertFile "^%OUTFILE%"

            ; NoteAwk subroutine clip to check for errors.
            ^!CLIP "Check for Error File"




            Maybe you could use a similar approach with Perl. Note that
            for GNU Sort, I am using temporary files, which are written
            to disk. The RunGawk and RunPerl commands are more efficient,
            as Eric set them up to use memory streams (computer RAM) instead
            of disk files.




            If you objective is just to get a grep function working with
            NoteTab, I've done all the work in NoteAwk's clip: "Find Lines
            Matching a Pattern." You do not need to reinvent the wheel.
            If your idea is to get this set up in Perl, so that you can
            later modify it for a more specific task - I hope you succeed.





            --
            Wayne M. VanWeerthuizen
            ICQ: 15117288
            Homepage: http://www2.localaccess.com/waynemv

            ------------------------------------------------------------------------
            eGroup home: http://www.eGroups.com/list/notetab
            Free Web-based e-mail groups by eGroups.com
          Your message has been successfully submitted and would be delivered to recipients shortly.