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

Re: Joining corresponding lines of two files

Expand Messages
  • diodeom
    ... Have a look at the straightforward solutions offered in response to this recent similar inquiry: http://tech.groups.yahoo.com/group/ntb-clips/message/22017
    Message 1 of 9 , Sep 5, 2011
    • 0 Attachment
      bruce.somers@... wrote:
      >
      > I have the need to join corresponding lines from two files, one after the other. I have
      >

      Have a look at the straightforward solutions offered in response to this recent similar inquiry:
      http://tech.groups.yahoo.com/group/ntb-clips/message/22017
    • bruce.somers@web.de
      ... Thanks for the pointer. I have retrieved Flo s version of a clip by Art: ^!SetDebug on ^!SetListDelimiter ^%NL% ^!SetArray
      Message 2 of 9 , Sep 5, 2011
      • 0 Attachment
        bruce.somers@... wrote:
        > I have the need to join corresponding lines from two files, one after the other. I have

        dideom wrote:
        > Have a look at the straightforward solutions offered in response to this recent similar inquiry:
        > http://tech.groups.yahoo.com/group/ntb-clips/message/22017

        Thanks for the pointer. I have retrieved Flo's version of a clip by Art:

        ^!SetDebug on
        ^!SetListDelimiter ^%NL%
        ^!SetArray %Left%=^$GetFileText(^$GetDocumentPath$File1.TXT)$
        ^!SetArray %Right%=^$GetFileText(^$GetDocumentPath$File2.TXT)$
        ; Strip empty records from end of array (by courtesy of Eb)
        ^!If "^%Left^%Left0%%" <> "^%Empty%" Skip Else ^!Dec %Left0%
        ^!Goto Skip_-1
        ^!Set %i%=0

        :Loop
        ^!Inc %i%
        ^!If ^%i% > ^%Left0% End
        ^!InsertText ^%Left^%i%% ^%Right^%i%%^%NL%
        ^!Goto Loop


        I think I have deciphered all but ^$GetFileText(^$GetDocumentPath$File1.TXT)$ .

        ^$GetDocumentPath$  --  Returns the path for NoteTab document files (always ends with backslash).

        Mustn't I have the corresponding files open in NoteTab? Surely NoteTab doesn't search all of my disks
        for File1.TXT . Suppose I had several such files.

        I haven't been able to find out how to save the file (with a new name) upon completion of the clip.

        Bruce
      • diodeom
        ... In ^$GetFileText()$ you should specify between the parentheses YOUR full path/filename, wherever it actually resides; something like C: Documents and
        Message 3 of 9 , Sep 5, 2011
        • 0 Attachment
          bruce.somers@... wrote:
          >
          > Thanks for the pointer. I have retrieved Flo's version of a clip by Art:
          >
          > ^!SetDebug on
          > ^!SetListDelimiter ^%NL%
          > ^!SetArray %Left%=^$GetFileText(^$GetDocumentPath$File1.TXT)$
          > ^!SetArray %Right%=^$GetFileText(^$GetDocumentPath$File2.TXT)$
          > ; Strip empty records from end of array (by courtesy of Eb)
          > ^!If "^%Left^%Left0%%" <> "^%Empty%" Skip Else ^!Dec %Left0%
          > ^!Goto Skip_-1
          > ^!Set %i%=0
          >
          > :Loop
          > ^!Inc %i%
          > ^!If ^%i% > ^%Left0% End
          > ^!InsertText ^%Left^%i%% ^%Right^%i%%^%NL%
          > ^!Goto Loop
          >
          >
          > I think I have deciphered all but ^$GetFileText(^$GetDocumentPath$File1.TXT)$ .
          >
          > ^$GetDocumentPath$  --  Returns the path for NoteTab document files (always ends with backslash).
          >
          > Mustn't I have the corresponding files open in NoteTab? Surely NoteTab doesn't search all of my disks
          > for File1.TXT . Suppose I had several such files.
          >
          > I haven't been able to find out how to save the file (with a new name) upon completion of the clip.
          >
          > Bruce
          >

          In ^$GetFileText()$ you should specify between the parentheses YOUR full path/filename, wherever it actually resides; something like "C:\Documents and Settings\Bruce\Desktop\Test\File1.txt"

          To save the current document with results in a new file you could utilize "^!Save As," again, spelling out where you want it saved and how you wish it named, e.g.:

          ;(the preceding code as you quoted it)

          :Loop
          ^!Inc %i%
          ^!If ^%i% > ^%Left0% Done
          ;(replace "?" below with the text you want to start each line)
          ;(long line start)
          ^!InsertText ?^%space%^%space%^%Left^%i%%^%space%^%space%^%Right^%i%%^p
          ;(long line end)
          ^!Goto Loop
          :Done
          ;(change the path/name to reflect your desired destination)
          ^!Save As C:\Documents and Settings\Bruce\Desktop\Test\Result.txt
          ;(clear variables)
          ^!Set %Left%=; %Right%=; %i%=
        • diodeom
          ... When done testing, ^!SetDebug Off
          Message 4 of 9 , Sep 5, 2011
          • 0 Attachment
            I wrote:
            >
            > ;(the preceding code as you quoted it)
            >

            When done testing, ^!SetDebug Off
          • Art Kocsis
            Hello Bruce, Welcome to the club of confusion, frustration and (sometimes) elation of clips. Notetab s Help file can be incomplete and confusing but hang in
            Message 5 of 9 , Sep 5, 2011
            • 0 Attachment
              Hello Bruce,

              Welcome to the club of confusion, frustration and (sometimes) elation of clips.

              Notetab's Help file can be incomplete and confusing but hang in there. It is
              sometimes useful or necessary to write short test clips just to understand how
              a command or function actually works. A good use for your clipbar.

              The confusion in this specific case comes from the ^$GetDocumentPath$ and
              ^$GetFileText$ functions. Notice that $GDP$ has no argument but $GFT$ does.
              ^$GetDocumentPath$ returns the fully qualified path of an OPEN DOCUMENT
              (named File1.TXT & File2.TXT in the example), while ^$GetFileText$(...)
              returns
              the text from the DISK FILE specified by the fully qualified file name in
              the argument.
              So ^$GetFileText(^$GetDocumentPath$File1.TXT)$ first gets the fully
              qualified path
              for the open doc File1.TXT, prepends it to File1.TXT, then passes the result to
              ^$GetFileText()$ to return the document text AS IT EXISTS ON THE DISK.
              Note that this may be different than the text in Notetab if it has been
              changed and
              not saved.

              If you are dealing with open docs, a better and less convoluted approach
              would be
              to use the ^$GetDocIndex$ & ^$GetDocIndex(Name)$ functions with ^!SetDocIndex
              to navigate to and from open doc tabs, and then use ^!Select All and
              ^$GetSelection$
              to retrieve the subject text.

              ^!Set ^!SetListDelimiter ^%NL%
              ^!Set %home%=^$GetDocIndex$
              ^!SetDocIndex ^$GetDocIndex(File1.txt)$
              ^!Select All
              ^!SetArray %Left%=^$GetSelection$
              ^!SetDocIndex ^$GetDocIndex(File2.txt)$
              ^!Select All
              ^!SetArray %Right%=^$GetSelection$
              ^!SetDocIndex ^%home%

              To place your text onto a disk there are a number of methods:

              If you want to save the entire open doc in the current tab, use
              ^!Save or ^!Save AS as suggested by dideom.

              Alternately, you can write text directly to a file as you generate it:

              Instead of
              ^!InsertText ^%Left^%i%% ^%Right^%i%%^%NL%

              use
              ^!AppendToFile "FileName" ^%Left^%i%% ^%Right^%i%%^%NL%

              where "FileName" is the fully qualified name of your target file.

              HTH

              Namaste', Art

              Any job worth doing right the first time is worth doing over
              - unknown

              At 09/05/2011 10:00, you wrote:
              >bruce.somers@... wrote:
              > > I have the need to join corresponding lines from two files, one after
              > the other. I have
              >
              >dideom wrote:
              > > Have a look at the straightforward solutions offered in response to
              > this recent similar inquiry:
              > >
              > <http://tech.groups.yahoo.com/group/ntb-clips/message/22017>http://tech.groups.yahoo.com/group/ntb-clips/message/22017
              >
              >Thanks for the pointer. I have retrieved Flo's version of a clip by Art:
              >
              >^!SetDebug on
              >^!SetListDelimiter ^%NL%
              >^!SetArray %Left%=^$GetFileText(^$GetDocumentPath$File1.TXT)$
              >^!SetArray %Right%=^$GetFileText(^$GetDocumentPath$File2.TXT)$
              >; Strip empty records from end of array (by courtesy of Eb)
              >^!If "^%Left^%Left0%%" <> "^%Empty%" Skip Else ^!Dec %Left0%
              >^!Goto Skip_-1
              >^!Set %i%=0
              >
              >:Loop
              >^!Inc %i%
              >^!If ^%i% > ^%Left0% End
              >^!InsertText ^%Left^%i%% ^%Right^%i%%^%NL%
              >^!Goto Loop
              >
              >I think I have deciphered all but
              >^$GetFileText(^$GetDocumentPath$File1.TXT)$ .
              >
              >^$GetDocumentPath$Â --Â Returns the path for NoteTab document files
              >(always ends with backslash).
              >
              >Mustn't I have the corresponding files open in NoteTab? Surely NoteTab
              >doesn't search all of my disks
              >for File1.TXT . Suppose I had several such files.
              >
              >I haven't been able to find out how to save the file (with a new name)
              >upon completion of the clip.
              >
              >Bruce
            • bruce.somers@web.de
              Thanks both to Art Kocsis and to diodeom for the tips. I ve had success now with ^!SetListDelimiter ^%NL% ^!SetArray
              Message 6 of 9 , Sep 6, 2011
              • 0 Attachment
                Thanks both to Art Kocsis and to diodeom for the tips. I've had success now with

                ^!SetListDelimiter ^%NL%
                ^!SetArray %Left%=^$GetFileText(D:\ownDevelopment\NTClips\before.txt)$
                ^!SetArray %Right%=^$GetFileText(D:\ownDevelopment\NTClips\after.txt)$
                ^!If "^%Left^%Left0%%" <> "^%Empty%" Skip Else ^!Dec %Left0%
                ^!Goto Skip_-1
                ^!Set %i%=0
                :Loop
                ^!Inc %i%
                ^!If ^%i% > ^%Left0% Done
                ^!InsertText rename^%space%^%space%"^%Left^%i%%"^%space%^%space%"^%Right^%i%%"^%NL%
                ^!Goto Loop
                :Done
                ^!Save As D:\ownDevelopment\NTClips\rename.bat
                ;(clear variables)
                ^!Set %Left%=; %Right%=; %i%=

                which I can follow (Yippee!). This does not require that before.txt and after.txt be open.
                It saves the results in rename.bat but also inserts the lines into the currently open file.

                Can the labels Loop and Done freely 'choosable'?  

                I will have to study the rest of your hints. As you can see, I generate a batch file to
                be run under cmd.exe . All is well unless my files contain German Umlaute (ä ö ü). There
                is a discrepancy between Windows and cmd.exe .

                Bruce
              • diodeom
                ... Check out the modest restrictions listed in Help = Help on Clip Programming = Labels.
                Message 7 of 9 , Sep 6, 2011
                • 0 Attachment
                  bruce.somers@... wrote:
                  >
                  > Can the labels Loop and Done freely 'choosable'?
                  >

                  Check out the modest restrictions listed in Help => Help on Clip Programming => Labels.
                • bruce.somers@web.de
                  ... Check out the modest restrictions listed in Help = Help on Clip Programming = Labels.   Thanks, got that. Bruce
                  Message 8 of 9 , Sep 6, 2011
                  • 0 Attachment
                    bruce.somers@... wrote:
                    >
                    > Can the labels Loop and Done freely 'choosable'?
                    >

                    Check out the modest restrictions listed in Help => Help on Clip Programming => Labels.
                     

                    Thanks, got that.

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