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

RE: [Clip] Switch to new doc with same content

Expand Messages
  • Art Kocsis
    John, I think you are having a senior moment here. As written your code just overwrites the original doc. Don t you want to append your -1 to the file name
    Message 1 of 9 , Jan 8, 2012
    • 0 Attachment
      John, I think you are having a senior moment here.
      As written your code just overwrites the original doc.
      Don't you want to append your "-1" to the file name part of %NewFile%?

      Just trying to help<g>!

      Art

      At 1/8/2012 05:58 AM, you wrote:
      >I found a solution that seems to work. Not sure if it's the most
      >straightforward way to do it, but it works.
      >In case anyone else needs something like that:
      >^!Set %NewFile%=^$GetDocName$.txt
      >^!Select ALL
      >^!TextToFile "^%NewFile%" ^$GetSelection$
      >^!Open "^%NewFile%"
      >
      >Regards,
      >John
    • John Shotsky
      Nope, it appends .txt to the doc, so its name is name.txt.txt, and that s fine for what I need. It is a throwaway file anyway, ultimately. Not that I don t
      Message 2 of 9 , Jan 8, 2012
      • 0 Attachment
        Nope, it appends .txt to the doc, so its name is name.txt.txt, and that's fine for what I need. It is a throwaway file
        anyway, ultimately. Not that I don't have senior moments, though :-(

        I did add one line to close the new file in case it was open, then got modified.
        ^!Set %NewFile%=^$GetDocName$.txt
        ^!Close %NewFile% discard

        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 Art Kocsis
        Sent: Sunday, January 08, 2012 13:25
        To: NoteTab-Clips
        Subject: RE: [Clip] Switch to new doc with same content


        John, I think you are having a senior moment here.
        As written your code just overwrites the original doc.
        Don't you want to append your "-1" to the file name part of %NewFile%?

        Just trying to help<g>!

        Art

        At 1/8/2012 05:58 AM, you wrote:
        >I found a solution that seems to work. Not sure if it's the most
        >straightforward way to do it, but it works.
        >In case anyone else needs something like that:
        >^!Set %NewFile%=^$GetDocName$.txt
        >^!Select ALL
        >^!TextToFile "^%NewFile%" ^$GetSelection$
        >^!Open "^%NewFile%"
        >
        >Regards,
        >John



        [Non-text portions of this message have been removed]
      • Eb
        Your solution is brief, but it changes the cursor position, if that is important. Theoretically (I havn t tested this), you could use: ^!CopyFile
        Message 3 of 9 , Jan 9, 2012
        • 0 Attachment
          Your solution is brief, but it changes the cursor position, if that is important.

          Theoretically (I havn't tested this), you could use:

          ^!CopyFile "^$GetDocName$" "^$GetDocName$.txt"
          ^!Open "^$GetDocName$.txt"

          to achieve the same effect, without involving the cursor.
          In either case, NoteTab may have to wait for the operating system to actually write the file copy to disk.

          By the way, appending .txt may not exclusively identify the file as temporary. You _could_ use ".tmp" to make that clear.


          Cheers,


          Eb


          --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:
          >
          > I found a solution that seems to work. Not sure if it's the most straightforward way to do it, but it works.
          > In case anyone else needs something like that:
          > ^!Set %NewFile%=^$GetDocName$.txt
          > ^!Select ALL
          > ^!TextToFile "^%NewFile%" ^$GetSelection$
          > ^!Open "^%NewFile%"
          >
          > 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 John Shotsky
          > Sent: Sunday, January 08, 2012 05:28
          > To: ntb-clips@yahoogroups.com
          > Subject: [Clip] Switch to new doc with same content
          >
          >
          > There must be an easier way to do this, but I haven't found a way yet.
          >
          > I have an open document, and some test tells me it needs to be cloned, and further operations performed on the clone,
          > leaving the original untouched. If the clone exists, it should be overwritten, without any user interaction.
          >
          > So, I start with doc1.txt, and due to some test in a clip, it is decided that the processing should be done on
          > doc1-1.txt, which may or may not already exist. If it does exist, it is to be replaced automatically. The open document
          > is in the focus, so essentially, this is the process:
          > Copy all the text on this document (or select it, or send to clipboard or ??)
          > Paste all the text to doc1-1.txt, open and focus on doc1-1.txt
          > Doc1.txt stays open, but not in focus.
          >
          > Help tells me this is the command to use. I can generate the filename, by adding the -1 to it, but I am not sure how to
          > specify the text. Essentially, I'm looking for a 'FileToFile' command with no prompting.
          > ^!TextToFile "FileName" AnyText
          > Creates a disk file containing the specified text. If a file with such a name already exists on disk, it will be
          > replaced by the new file.
          >
          > How do I identify that the text is the text in the current document? I know I could do this using Save As, but then I
          > have to be careful about files that already exist, and my current document gets closed, both of which I'm trying to
          > avoid. I assume that once created, doc1-1.txt would have to be opened, which would give it the focus, so that's no
          > problem.
        • John Shotsky
          Thanks, Eb, that looks good too. I d add a save first, in case it was modified beforehand. I like the idea of .tmp too. Regards, John RecipeTools Web Site:
          Message 4 of 9 , Jan 9, 2012
          • 0 Attachment
            Thanks, Eb, that looks good too. I'd add a save first, in case it was modified beforehand. I like the idea of .tmp too.

            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 Eb
            Sent: Monday, January 09, 2012 12:59
            To: ntb-clips@yahoogroups.com
            Subject: Re: [Clip] Switch to new doc with same content


            Your solution is brief, but it changes the cursor position, if that is important.

            Theoretically (I havn't tested this), you could use:

            ^!CopyFile "^$GetDocName$" "^$GetDocName$.txt"
            ^!Open "^$GetDocName$.txt"

            to achieve the same effect, without involving the cursor.
            In either case, NoteTab may have to wait for the operating system to actually write the file copy to disk.

            By the way, appending .txt may not exclusively identify the file as temporary. You _could_ use ".tmp" to make that
            clear.

            Cheers,

            Eb

            --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> , "John Shotsky" <jshotsky@...> wrote:
            >
            > I found a solution that seems to work. Not sure if it's the most straightforward way to do it, but it works.
            > In case anyone else needs something like that:
            > ^!Set %NewFile%=^$GetDocName$.txt
            > ^!Select ALL
            > ^!TextToFile "^%NewFile%" ^$GetSelection$
            > ^!Open "^%NewFile%"
            >
            > Regards,
            > John
            > RecipeTools Web Site: <http://recipetools.gotdns.com/> http://recipetools.gotdns.com/
            >
            > From: ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> [mailto:ntb-clips@yahoogroups.com
            <mailto:ntb-clips%40yahoogroups.com> ] On Behalf Of John Shotsky
            > Sent: Sunday, January 08, 2012 05:28
            > To: ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com>
            > Subject: [Clip] Switch to new doc with same content
            >
            >
            > There must be an easier way to do this, but I haven't found a way yet.
            >
            > I have an open document, and some test tells me it needs to be cloned, and further operations performed on the clone,
            > leaving the original untouched. If the clone exists, it should be overwritten, without any user interaction.
            >
            > So, I start with doc1.txt, and due to some test in a clip, it is decided that the processing should be done on
            > doc1-1.txt, which may or may not already exist. If it does exist, it is to be replaced automatically. The open
            document
            > is in the focus, so essentially, this is the process:
            > Copy all the text on this document (or select it, or send to clipboard or ??)
            > Paste all the text to doc1-1.txt, open and focus on doc1-1.txt
            > Doc1.txt stays open, but not in focus.
            >
            > Help tells me this is the command to use. I can generate the filename, by adding the -1 to it, but I am not sure how
            to
            > specify the text. Essentially, I'm looking for a 'FileToFile' command with no prompting.
            > ^!TextToFile "FileName" AnyText
            > Creates a disk file containing the specified text. If a file with such a name already exists on disk, it will be
            > replaced by the new file.
            >
            > How do I identify that the text is the text in the current document? I know I could do this using Save As, but then I
            > have to be careful about files that already exist, and my current document gets closed, both of which I'm trying to
            > avoid. I assume that once created, doc1-1.txt would have to be opened, which would give it the focus, so that's no
            > problem.



            [Non-text portions of this message have been removed]
          • Axel Berger
            ... I like using the standard Temp-folder too: ^$ExpandEnv( %temp% )$ ^$GetName(^$GetDocName$)$.tmp Note the backslash: While NotTab paths always end in a
            Message 5 of 9 , Jan 9, 2012
            • 0 Attachment
              Eb wrote:
              > You _could_ use ".tmp" to make that clear.

              I like using the standard Temp-folder too:

              ^$ExpandEnv("%temp%")$\^$GetName(^$GetDocName$)$.tmp

              Note the backslash: While NotTab paths always end in a backslash, DOS
              paths don't.

              Axel

              --
              Dipl.-Ing. F. Axel Berger Tel: +49/ 2174/ 7439 07
              Johann-Häck-Str. 14 Fax: +49/ 2174/ 7439 68
              D-51519 Odenthal-Heide eMail: Axel-Berger@...
              Deutschland (Germany) http://berger-odenthal.de
            • Axel Berger
              ... You could top that by closing and ^!OpenReadOnly Open the old file first and the new one last, so the new, temporary one is in focus. Axel -- Dipl.-Ing. F.
              Message 6 of 9 , Jan 9, 2012
              • 0 Attachment
                John Shotsky wrote:
                > I'd add a save first, in case it was modified beforehand.

                You could top that by closing and ^!OpenReadOnly

                Open the old file first and the new one last, so the new, temporary one
                is in focus.

                Axel

                --
                Dipl.-Ing. F. Axel Berger Tel: +49/ 2174/ 7439 07
                Johann-Häck-Str. 14 Fax: +49/ 2174/ 7439 68
                D-51519 Odenthal-Heide eMail: Axel-Berger@...
                Deutschland (Germany) http://berger-odenthal.de
              • anachromat
                ... Try replacing the middle two lines with: ^!TextToFile ^%NewFile% ^$GetText$ Here are the docs for GetText: Returns the whole text contained in the
                Message 7 of 9 , Jun 1, 2012
                • 0 Attachment
                  --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:
                  >
                  > I found a solution that seems to work. Not sure if it's
                  > the most straightforward way to do it, but it works.
                  > In case anyone else needs something like that:
                  > ^!Set %NewFile%=^$GetDocName$.txt
                  > ^!Select ALL
                  > ^!TextToFile "^%NewFile%" ^$GetSelection$
                  > ^!Open "^%NewFile%"

                  Try replacing the middle two lines with:

                  ^!TextToFile "^%NewFile%" ^$GetText$

                  Here are the docs for GetText: "Returns the whole text contained in the active document."
                Your message has been successfully submitted and would be delivered to recipients shortly.