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

RunScript on selected text only

Expand Messages
  • B_Barry
    Hello All, I want to run something like ^!RunScript C: python27 python.exe postnote http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html but
    Message 1 of 3 , Mar 15 3:39 PM
    • 0 Attachment
      Hello All, I want to run something like
      ^!RunScript C:\python27\python.exe postnote
      but have it only apply to the selected text, never to the whole document. Is there anyway to make this restriction?
      Thanks,
      Bill
    • Axel Berger
      ... So ^## and ^** are no good to you. The thing to do is ^!Export Tempfile.tmp SELECTION ^!InsertFile Tempfile.tmp Axel
      Message 2 of 3 , Mar 16 5:10 AM
      • 0 Attachment
        b_barry@... wrote:
        > but have it only apply to the selected text, never to the whole document.
        > Is there anyway to make this restriction?

        So ^## and ^** are no good to you. The thing to do is

        ^!Export "Tempfile.tmp" SELECTION
        <Run your script>
        ^!InsertFile Tempfile.tmp

        Axel
      • B_Barry
        ... So ^## and ^** are no good to you. The thing to do is ^!Export Tempfile.tmp SELECTION ^!InsertFile Tempfile.tmp Well that seems like it
        Message 3 of 3 , Mar 16 3:17 PM
        • 0 Attachment
          ---In ntb-scripts@yahoogroups.com, <Axel-Berger@...> wrote :

          b_barry@... wrote:
          > but have it only apply to the selected text, never to the whole document.
          > Is there anyway to make this restriction?

          So ^## and ^** are no good to you. The thing to do is

          ^!Export "Tempfile.tmp" SELECTION
          <Run your script>
          ^!InsertFile Tempfile.tmp

          Well that seems like it should work, but I tested it and if there is no selection  the whole document still gets Exported to Tempfile.tmp.

          But, inspired by that I tried using the function ^$GetSelSize$ to check if the selection size is 0 as shown here

          ^!IfFalse ^$GetSelSize$ End
          ^!RunScript C:\python27\python.exe postnote 
          :End

          So far this seems to do what I want.  If anyone sees a case where this will not work, let me know.
          Thanks for the help.
          Bill


        Your message has been successfully submitted and would be delivered to recipients shortly.