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

Clip to execute file at cursor

Expand Messages
  • david335577
    I would like to write a Clip to open the path in the current file at the cursor. I mean open here to be the open Windows verb. In case you don t know what
    Message 1 of 22 , Dec 10, 2012
    View Source
    • 0 Attachment
      I would like to write a Clip to open the path in the current file at the cursor. I mean "open" here to be the "open" Windows verb. In case you don't know what that means, it means to run the associated file of the given data file. An example will make this clear: to "open" the file abc.pdf means to run the program AcroRd32.exe, the Acrobat Reader, passing it the data file abc.pdf.

      I have tried using

      ^!Select FILENAME
      ^!^&

      but this doesn't run anything. I've read the Help and looked in the sample code. Anyone have a solution? Thanks.

      I have Notetab Pro 4.91/np (Full version) and cannot upgrade because things that work at that rev will stop working (I tried to upgrade years ago).

      David Spector
    • Ian NTnerd
      ... ^!Select FILENAME ^!shell ^& Works the second time after an error the first time. That seems like a bug. ^!shell ^$GetLine$ This works if the path and file
      Message 2 of 22 , Dec 10, 2012
      View Source
      • 0 Attachment
        On 11/12/2012 6:32 AM, david335577 wrote:
        > ^!Select FILENAME
        > ^!^&
        ^!Select FILENAME
        ^!shell ^&
        Works the second time after an error the first time. That seems like a bug.

        ^!shell ^$GetLine$
        This works if the path and file name are the only thing on the line.

        ^!Select filename
        ^!shell ^$GetSelection$
        Is what you specified.

        NTP 6.2
        Ian
      • david335577
        This works when there are no embedded spaces, otherwise it fails, ignoring any current selection. I apologize for not giving an example file that contains
        Message 3 of 22 , Dec 11, 2012
        View Source
        • 0 Attachment
          This works when there are no embedded spaces, otherwise it fails, ignoring any current selection. I apologize for not giving an example file that contains spaces.

          Example of text that fails (place the cursor inside the filename):

          ----
          The file "C:\arjuna ardagh.mp3" is an example.
          ----

          Neither a solution that extends the Select to search for quotation marks, or a solution that extends the Select to do nothing if there
          is a current selection will work, because Shell itself fails to work properly when are embedded spaces.

          Is NoteTab Pro just too buggy to make "execute file at cursor" work in general? I think I can't return to Emacs now that I'm so used to NoteTab.

          Thanks so much for your partial solution.
        • Axel Berger
          ... No. There is a general rule that if you want to work in the command line, which is what the Shell function does, you MUST NOT have spaces in file names.
          Message 4 of 22 , Dec 11, 2012
          View Source
          • 0 Attachment
            david335577 wrote:
            > Is NoteTab Pro just too buggy to make "execute file at cursor"
            > work in general?

            No. There is a general rule that if you want to work in the command
            line, which is what the Shell function does, you MUST NOT have spaces in
            file names. There are certain exceptions and certain workarounds, that
            sometimes work and sometimes not.

            More or less every time someone sends me a file with spaces I need to
            rename it because something breaks. This problem is definitely not a
            specific NT one.

            You can try
            ^!shell "^$GetSelection$"
            with quotation marks. It might work.

            Axel
          • John Shotsky
            I use the command line where folders, executables and/or files have spaces all the time. Just use double quotes around the whole path/file names. I store my
            Message 5 of 22 , Dec 11, 2012
            View Source
            • 0 Attachment
              I use the command line where folders, executables and/or files have spaces all the time. Just use double quotes around
              the whole path/file names. I store my executables with their path in a variable, with the double quotes stored in the
              variable too. So, generally, it is %!ShellWait ^%MyExecutable% "path\file" with options either between or following,
              based on what it expects.

              Regards,
              John
              RecipeTools Web Site: <http://recipetools.gotdns.com/> http://recipetools.gotdns.com/

              From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Axel Berger
              Sent: Tuesday, December 11, 2012 11:56
              To: ntb-clips@yahoogroups.com
              Subject: Re: [Clip] Clip to execute file at cursor


              david335577 wrote:
              > Is NoteTab Pro just too buggy to make "execute file at cursor"
              > work in general?

              No. There is a general rule that if you want to work in the command
              line, which is what the Shell function does, you MUST NOT have spaces in
              file names. There are certain exceptions and certain workarounds, that
              sometimes work and sometimes not.

              More or less every time someone sends me a file with spaces I need to
              rename it because something breaks. This problem is definitely not a
              specific NT one.

              You can try
              ^!shell "^$GetSelection$"
              with quotation marks. It might work.

              Axel



              [Non-text portions of this message have been removed]
            • loro
              ... It will work. I ve used exactly that in a clip without problems. Lotta
              Message 6 of 22 , Dec 11, 2012
              View Source
              • 0 Attachment
                Axel wrote:
                >You can try
                >^!shell "^$GetSelection$"
                >with quotation marks. It might work.

                It will work. I've used exactly that in a clip without problems.

                Lotta
              • david335577
                Thank you, all, for your good ideas. The problem has not yet been solved, because it fails to open a file like this one, where the cursor is between the
                Message 7 of 22 , Dec 12, 2012
                View Source
                • 0 Attachment
                  Thank you, all, for your good ideas. The problem has not yet been solved, because it fails to open a file like this one, where the cursor is between the quotes:

                  "C:\arjuna ardagh.mp3"

                  The problem is that it is difficult to write clip code to select a quoted string containing spaces.

                  The best I have so far is this:

                  ^!If ^$GetSelSize$ = 0 ^!Select FILENAME
                  ^!shell "^$GetSelection$"

                  This will run a file that has no embedded spaces, and will also run a file with embedded spaces if one manually selects it first.
                • Axel Berger
                  ... If there always are quotes, try this: ^!If ^$GetSelSize$ 3 auswahl ^!Menu Search/ Match Brackets ... ^!shell ^$GetSelection$ Please include the quotes
                  Message 8 of 22 , Dec 12, 2012
                  View Source
                  • 0 Attachment
                    david335577 wrote:
                    > because it fails to open a file like this one, where the cursor
                    > is between the quotes:
                    > "C:\arjuna ardagh.mp3"

                    If there always are quotes, try this:

                    ^!If ^$GetSelSize$>3 auswahl
                    ^!Menu Search/"Match Brackets"
                    :auswahl
                    ^!shell ^$GetSelection$

                    Please include the quotes when selecting manually, I deleted them in the
                    last line as double double quotes (""C:\arjuna ardagh.mp3"") would not
                    yield the desired result.

                    N.B: John, when you say "Just use double quotes around the whole
                    path/file names" that's just what I meant by saying "exceptions and
                    certain workarounds". It will mostly work but you can't rely on it for
                    every batch file. Mine often do a lot of things and I might put extra
                    effort into catering for spaces, but prefer not to have to.

                    Axel
                  • John Shotsky
                    These are operating system issues, however, not NoteTab issues. I don t consider things to be workarounds when, by definition, you must abide by the published
                    Message 9 of 22 , Dec 12, 2012
                    View Source
                    • 0 Attachment
                      These are operating system issues, however, not NoteTab issues. I don't consider things to be workarounds when, by
                      definition, you must abide by the published rules to get the desired performance.

                      Regards,
                      John
                      RecipeTools Web Site: <http://recipetools.gotdns.com/> http://recipetools.gotdns.com/

                      From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Axel Berger
                      Sent: Wednesday, December 12, 2012 07:39
                      To: ntb-clips@yahoogroups.com
                      Subject: Re: [Clip] Re: Clip to execute file at cursor


                      david335577 wrote:
                      > because it fails to open a file like this one, where the cursor
                      > is between the quotes:
                      > "C:\arjuna ardagh.mp3"

                      If there always are quotes, try this:

                      ^!If ^$GetSelSize$>3 auswahl
                      ^!Menu Search/"Match Brackets"
                      :auswahl
                      ^!shell ^$GetSelection$

                      Please include the quotes when selecting manually, I deleted them in the
                      last line as double double quotes (""C:\arjuna ardagh.mp3"") would not
                      yield the desired result.

                      N.B: John, when you say "Just use double quotes around the whole
                      path/file names" that's just what I meant by saying "exceptions and
                      certain workarounds". It will mostly work but you can't rely on it for
                      every batch file. Mine often do a lot of things and I might put extra
                      effort into catering for spaces, but prefer not to have to.

                      Axel



                      [Non-text portions of this message have been removed]
                    • loro
                      ... You could use ^Find to search backwards to find the first quote (provided the cursor is between the quotes). Store the location of it in a variable with
                      Message 10 of 22 , Dec 12, 2012
                      View Source
                      • 0 Attachment
                        david wrote:
                        >The problem is that it is difficult to write clip code to select a
                        >quoted string containing spaces.
                        >
                        >The best I have so far is this:
                        >
                        >^!If ^$GetSelSize$ = 0 ^!Select FILENAME
                        >^!shell "^$GetSelection$"

                        You could use ^Find to search backwards to find the first quote
                        (provided the cursor is between the quotes). Store the location of it
                        in a variable with ^$GetRow$:^$GetCol$ . Then find the next quote.
                        Place the cursor after it (for example with ^!Jump select_end ). Then
                        use ^!SelectTo to select from that position to the position of the
                        first quote you stored in a variable.

                        Lotta
                      • david335577
                        I got a matching brackets not found error for test case a C: arjuna ardagh.mp3 b with cursor after the first .
                        Message 11 of 22 , Dec 14, 2012
                        View Source
                        • 0 Attachment
                          I got a "matching brackets not found" error for test case

                          a "C:\arjuna ardagh.mp3" b

                          with cursor after the first " .
                        • david335577
                          Lotta, That is the craziness I was trying to avoid, as I don t have time to do extensive work on this. I was hoping Clip was rich enough to get this sort of
                          Message 12 of 22 , Dec 14, 2012
                          View Source
                          • 0 Attachment
                            Lotta, That is the craziness I was trying to avoid, as I don't have time to do extensive work on this. I was hoping Clip was rich enough to get this sort of thing done more elegantly and simply.
                          • Axel Berger
                            ... That surprises me. What is your version? With 7.01 I m not currently running the newest myself and there were recent chnages in this function, I believe.
                            Message 13 of 22 , Dec 14, 2012
                            View Source
                            • 0 Attachment
                              david335577 wrote:
                              > I got a "matching brackets not found" error for test case

                              That surprises me. What is your version? With 7.01 I'm not currently
                              running the newest myself and there were recent chnages in this
                              function, I believe.

                              Axel
                            • Axel Berger
                              ... I agree, I wouldn t even attempt something like athta as a last resort, but only after the last resort too has failed me. I still don t understand why
                              Message 14 of 22 , Dec 14, 2012
                              View Source
                              • 0 Attachment
                                david335577 wrote:
                                > That is the craziness I was trying to avoid,

                                I agree, I wouldn't even attempt something like athta as a last resort,
                                but only after the last resort too has failed me.

                                I still don't understand why SelectTo is so primitive. Both Select and
                                Jump allow dozens of help- and powerful keywords, only this one is
                                restricted to row:col numbering.

                                Axel
                              • Dave
                                Hi this works in 4.6 nts H= mp3 ^!shell G: VA - Sensation Black 13 Evil Activities vs Neophyte - Rocking With The Best(Black Amsterdam 2008).mp3 runs
                                Message 15 of 22 , Dec 15, 2012
                                View Source
                                • 0 Attachment
                                  Hi
                                  this works in 4.6 nts
                                  H="mp3"
                                  ^!shell "G:\VA - Sensation Black\13 Evil Activities vs Neophyte - Rocking
                                  With The Best(Black Amsterdam 2008).mp3"
                                  runs default mp3 player
                                  THANKYOU DAVE M


                                  ----- Original Message -----
                                  From: "david335577" <m021@...>
                                  To: <ntb-clips@yahoogroups.com>
                                  Sent: Tuesday, December 11, 2012 9:32 AM
                                  Subject: [Clip] Clip to execute file at cursor


                                  >I would like to write a Clip to open the path in the current file at the
                                  >cursor. I mean "open" here to be the "open" Windows verb. In case you don't
                                  >know what that means, it means to run the associated file of the given data
                                  >file. An example will make this clear: to "open" the file abc.pdf means to
                                  >run the program AcroRd32.exe, the Acrobat Reader, passing it the data file
                                  >abc.pdf.
                                  >
                                  > I have tried using
                                  >
                                  > ^!Select FILENAME
                                  > ^!^&
                                  >
                                  > but this doesn't run anything. I've read the Help and looked in the sample
                                  > code. Anyone have a solution? Thanks.
                                  >
                                  > I have Notetab Pro 4.91/np (Full version) and cannot upgrade because
                                  > things that work at that rev will stop working (I tried to upgrade years
                                  > ago).
                                  >
                                  > David Spector
                                  >
                                  >
                                  >
                                  >
                                  > ------------------------------------
                                  >
                                  > Fookes Software: http://www.fookes.com/
                                  > NoteTab website: http://www.notetab.com/
                                  > NoteTab Discussion Lists: http://www.notetab.com/groups.php
                                  >
                                  > ***
                                  > Yahoo! Groups Links
                                  >
                                  >
                                  >
                                • david335577
                                  Axel Berger: My version is in my first post.
                                  Message 16 of 22 , Dec 15, 2012
                                  View Source
                                  • 0 Attachment
                                    Axel Berger: My version is in my first post.
                                  • Axel Berger
                                    ... I empathize with you, I tend to being very upgrade averse myself, just kook at my OS. On the other hand the most active NT-users, those who give the bulk
                                    Message 17 of 22 , Dec 15, 2012
                                    View Source
                                    • 0 Attachment
                                      david335577 wrote:
                                      > Axel Berger: My version is in my first post.

                                      And now I remember having seen it:
                                      > I have Notetab Pro 4.91/np (Full version) and cannot upgrade

                                      I empathize with you, I tend to being very upgrade averse myself, just
                                      kook at my OS. On the other hand the most active NT-users, those who
                                      give the bulk of the advice here, tend to keep up and have the current
                                      versions. I only began with version 5 and the older timers will all be
                                      forgetting previous particulars by now. So if you want help and advice
                                      here, your best bet is to grit your teeth and do all the edits necessary
                                      to adapt your old and proven clips to version 7. I accept it's a bore,
                                      but it'll help in the long run.

                                      Axel
                                    • david335577
                                      Axel, May I assume, then, that you are willing to make the latest version work for me? The issue, as I vaguely recall, has to do with the F8 command that opens
                                      Message 18 of 22 , Dec 16, 2012
                                      View Source
                                      • 0 Attachment
                                        Axel, May I assume, then, that you are willing to make the latest version work for me? The issue, as I vaguely recall, has to do with the F8 command that opens the current page in the default browser. When I do Web development work, I need F8 to open the page not as an HTML file, but as a PHP file running on my local server (localhost). Apparently, my version can be coerced to do this, but a later version that I tried out years ago could not. I reported this to the NoteTab developer and he said it could not be fixed. Your task, if I am to upgrade as you think I should, is to help me by email write a Clip that does what I need for easy local Web development.
                                      • Axel Berger
                                        david335577 wrote: I need F8 to open the page not as an HTML file, That is a general weakness of Notetab s. Keyboard shortcuts can run menu items but not
                                        Message 19 of 22 , Dec 16, 2012
                                        View Source
                                        • 0 Attachment
                                          david335577 wrote:
                                          I need F8 to open the page not as an HTML file,

                                          That is a general weakness of Notetab's. Keyboard shortcuts can run menu
                                          items but not clips. If only one single function affects you that way,
                                          you're lucky, for me there are quite a few I need to click in my clipbar
                                          and can't access through a key shortcut - although there always is the
                                          <Esc> clip selection.

                                          So many paople keep complaining about this, I'm sure it will get fixed
                                          some day. In the meantime you might look at Sheri's add-on program,
                                          whatever it was called, can't remember offhand.

                                          Axel
                                        • John Shotsky
                                          A simple clip will open the current NoteTab document in your web browser: ^!Toolbar View In Browser You need to save it first, if you intend to see your
                                          Message 20 of 22 , Dec 16, 2012
                                          View Source
                                          • 0 Attachment
                                            A simple clip will open the current NoteTab document in your web browser:
                                            ^!Toolbar View In Browser
                                            You need to save it first, if you intend to see your changes.

                                            Regards,
                                            John
                                            RecipeTools Web Site: <http://recipetools.gotdns.com/> http://recipetools.gotdns.com/

                                            From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of david335577
                                            Sent: Sunday, December 16, 2012 05:43
                                            To: ntb-clips@yahoogroups.com
                                            Subject: [Clip] Re: Clip to execute file at cursor




                                            Axel, May I assume, then, that you are willing to make the latest version work for me? The issue, as I vaguely recall,
                                            has to do with the F8 command that opens the current page in the default browser. When I do Web development work, I need
                                            F8 to open the page not as an HTML file, but as a PHP file running on my local server (localhost). Apparently, my
                                            version can be coerced to do this, but a later version that I tried out years ago could not. I reported this to the
                                            NoteTab developer and he said it could not be fixed. Your task, if I am to upgrade as you think I should, is to help me
                                            by email write a Clip that does what I need for easy local Web development.



                                            [Non-text portions of this message have been removed]
                                          • david335577
                                            Axel, I have no problem with such limitations, because I have the wonderful macro program Macro Express installed. I can make a hotkey do almost anything
                                            Message 21 of 22 , Dec 16, 2012
                                            View Source
                                            • 0 Attachment
                                              Axel, I have no problem with such limitations, because I have the wonderful macro program Macro Express installed. I can make a hotkey do almost anything simple, like sending menu commands to NoteTab, in moments.

                                              There is always a tradeoff between my programming time and how much time it saves me, which is why I haven't implemented a really complex but correct solution to either the F8 or the execute file/command problem. Ideally, the NoteTab support programmer should enjoy learning about use cases in various platforms and change NoteTab primitives to do things better (with options for back-compatibility). Perhaps NoteTab is old enough that its code is brittle and cannot easily be changed. Just speculating. Who knows?
                                            • Eb
                                              David, By placing quotes around the execution line, it executes the associated app, regardless of embedded spaces or not: ^!Select FILENAME ^!Set
                                              Message 22 of 22 , Dec 17, 2012
                                              View Source
                                              • 0 Attachment
                                                David,

                                                By placing quotes around the execution line, it executes the associated app, regardless of embedded spaces or not:

                                                ^!Select FILENAME
                                                ^!Set %temp%=^$GetSelection$
                                                ^!"^%temp%"

                                                Tested on NTP 7.1, Windows 7.

                                                Cheers,


                                                Eb

                                                --- In ntb-clips@yahoogroups.com, "david335577" <m021@...> wrote:
                                                >
                                                >
                                                >
                                                > Thank you, all, for your good ideas. The problem has not yet been solved, because it fails to open a file like this one, where the cursor is between the quotes:
                                                >
                                                > "C:\arjuna ardagh.mp3"
                                                >
                                                > The problem is that it is difficult to write clip code to select a quoted string containing spaces.
                                                >
                                                > The best I have so far is this:
                                                >
                                                > ^!If ^$GetSelSize$ = 0 ^!Select FILENAME
                                                > ^!shell "^$GetSelection$"
                                                >
                                                > This will run a file that has no embedded spaces, and will also run a file with embedded spaces if one manually selects it first.
                                                >
                                              Your message has been successfully submitted and would be delivered to recipients shortly.