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

Not sure to use ^!SelectLine or ^$GetLine$

Expand Messages
  • swimmer70002
    I m trying to create a simple clip that will take the first two lines of text, from a random .txt file, and turn it into an HTML hyperlinked name. My problem
    Message 1 of 14 , Feb 4, 2010
    • 0 Attachment
      I'm trying to create a simple clip that will take the first two lines of text, from a random .txt file, and turn it into an HTML hyperlinked name.

      My problem is that I don't know if it's better to use a ^!SelectLine or ^$GetLine$ command. Unfortunately, NoteTab Help doesn't give enough usage examples for me to really figure out how these two commands work.

      Say I have a text file, and it has lines to follow

      Random.txt
      Line 1: Name of link
      Line 2: http://www.something.com

      How do I use ^!SelectLine or ^$GetLine$ store the text in a variable preferably, so I can do an ^InsertHtml cmd to change the text into:

      <a href="http:///www.something.com">Name of Link</a>

      ?
    • Don Daugherty
      ... Either will work, a illustrated by running the following test clip;: ^!Open ^?{(T=O)Select File to work from} ^!SetCursor 1:1 ^!Select 1 ^!Set
      Message 2 of 14 , Feb 5, 2010
      • 0 Attachment
        swimmer70002 wrote:
        > I'm trying to create a simple clip that will take the first two lines of text, from a random .txt file, and turn it into an HTML hyperlinked name.
        >
        > My problem is that I don't know if it's better to use a ^!SelectLine or ^$GetLine$ command. Unfortunately, NoteTab Help doesn't give enough usage examples for me to really figure out how these two commands work.
        >
        > Say I have a text file, and it has lines to follow
        >
        > Random.txt
        > Line 1: Name of link
        > Line 2: http://www.something.com
        >
        > How do I use ^!SelectLine or ^$GetLine$ store the text in a variable preferably, so I can do an ^InsertHtml cmd to change the text into:
        >
        > <a href="http:///www.something.com">Name of Link</a>
        Either will work, a illustrated by running the following test clip;:

        ^!Open ^?{(T=O)Select File to work from}
        ^!SetCursor 1:1
        ^!Select 1
        ^!Set %Name1%=^$GetSelection$
        ^!SetCursor 2:1
        ^!Select 1
        ^!Set %Link1%=^$GetSelection$
        ^!Select 0
        ; The following should produce the same results, but with fewer lines of
        code.
        ^!Set %Name2%=^$GetLine(1)$
        ^!Set %Link2%=^$GetLine(2)$
        ^!Continue Name1=^%Name1% and Link1=^%Link1%^%NL%Name2=^%Name2% and
        Link2=^%Link2%

        So to do your task I'd use something like this:

        ^!Open ^?{(T=O)Select File to work from}
        ^!Set %Name%=^$GetLine(1)$; %Link%=^$GetLine(2)$
        ^!Set %Result%="<a href'="^%Link%">^%Name%</a>"
        ^!Continue Result=^%Result%
      • Sheri
        ... Probably the best way to accomplish the task is a regex replacement: ^!Jump Doc_Start ^!Replace ^(.+) R(.+)$ $1 RS Jump to the
        Message 3 of 14 , Feb 5, 2010
        • 0 Attachment
          --- In ntb-clips@yahoogroups.com, "swimmer70002" <swimmer70002@...> wrote:
          >
          > I'm trying to create a simple clip that will take the first two
          > lines of text, from a random .txt file, and turn it into an HTML
          > hyperlinked name.
          >
          > My problem is that I don't know if it's better to use a
          > ^!SelectLine or ^$GetLine$ command. Unfortunately, NoteTab Help
          > doesn't give enough usage examples for me to really figure out
          > how these two commands work.
          >
          > Say I have a text file, and it has lines to follow
          >
          > Random.txt
          > Line 1: Name of link
          > Line 2: http://www.something.com
          >
          > How do I use ^!SelectLine or ^$GetLine$ store the text in a
          > variable preferably, so I can do an ^InsertHtml cmd to change the
          > text into:
          >
          > <a href="http:///www.something.com">Name of Link</a>
          >
          > ?
          >

          Probably the best way to accomplish the task is a regex replacement:

          ^!Jump Doc_Start
          ^!Replace "^(.+)\R(.+)$" >> "<a href="$2">$1</a>" RS

          Jump to the start to make sure it finds the first two lines. In the search text, the parenthesized portions can be referenced on the replacement side with $<num> where <num> is the consecutive number of the parentheses counting from the left. So the link's name is in $1 and the link itself is in $2. The "\R" in the pattern is a metacharacter that stands in for the control characters between the lines.

          But you also asked how to store text into a variable. The ^!Set command does that.

          e.g.,
          ^!Set %LinkName%="^$StrTrim(^$GetLine(1)$)$"
          ^!Set %Link%="^$StrTrim(^$GetLine(2)$)$"
          ^!Jump Doc_Start
          ^!Select 2
          ^!InsertHtml <a href="^%Link%">^%LinkName%</a>

          There is no such command as ^!SelectLine

          You can select the current line with

          ^!Select Line

          but keep in mind that the selection then includes the carriage return and line feed control characters as well as the other characters on the line. To exclude them, use ^!Select EOL instead.

          ^!Jump Line_Start
          ^!Select EOL
          ^!Set %LineContent%=^$GetSelection$
          ^!Prompt Line Content is ***^%LineContent%***

          In Standard and Light, ^$GetLine$ includes the two line-breaking control characters -- that is why I used ^$StrTrim$ in the sample usage above.

          Regards,
          Sheri
        • loro
          ... Something like this. I take it it doesn t really say Line 1: and Line 2: in the real text? ^!Jump text_start ^!Set %linktext%=^$GetLine$ ^!Jump +1 ^!Set
          Message 4 of 14 , Feb 5, 2010
          • 0 Attachment
            At 04:22 2010-02-05, you wrote:
            >I'm trying to create a simple clip that will take the first two
            >lines of text, from a random .txt file, and turn it into an HTML
            >hyperlinked name.
            >
            >My problem is that I don't know if it's better to use a ^!SelectLine
            >or ^$GetLine$ command. Unfortunately, NoteTab Help doesn't give
            >enough usage examples for me to really figure out how these two commands work.
            >
            >Say I have a text file, and it has lines to follow
            >
            >Random.txt
            >Line 1: Name of link
            >Line 2: http://www.something.com
            >
            >How do I use ^!SelectLine or ^$GetLine$ store the text in a variable
            >preferably, so I can do an ^InsertHtml cmd to change the text into:
            >
            ><a href="http:///www.something.com">Name of Link</a>

            Something like this. I take it it doesn't really say "Line 1:" and
            Line 2:" in the real text?

            ^!Jump text_start
            ^!Set %linktext%=^$GetLine$
            ^!Jump +1
            ^!Set %link%=^$GetLine$
            ^!Info <a href="^%link%">^%linktext%</a>

            If you want the link inserted in the same document, you could go on
            like the below.

            ^!Jump text_start
            ^!Select 2
            ^!InsertText <a href="^%link%">^%linktext%</a>


            Lotta
          • Don Daugherty
            Oops! Set %Result%= line should read as follows (WITHOUT a single-quote after href): ^!Set %Result%= ^%Name%
            Message 5 of 14 , Feb 5, 2010
            • 0 Attachment
              Oops! Set %Result%= line should read as follows (WITHOUT a single-quote
              after href):

              ^!Set %Result%="<a href="^%Link%">^%Name%</a>"

              Don Daugherty wrote:
              > swimmer70002 wrote:
              >
              >> I'm trying to create a simple clip that will take the first two lines of text, from a random .txt file, and turn it into an HTML hyperlinked name.
              >>
              >> My problem is that I don't know if it's better to use a ^!SelectLine or ^$GetLine$ command. Unfortunately, NoteTab Help doesn't give enough usage examples for me to really figure out how these two commands work.
              >>
              >> Say I have a text file, and it has lines to follow
              >>
              >> Random.txt
              >> Line 1: Name of link
              >> Line 2: http://www.something.com
              >>
              >> How do I use ^!SelectLine or ^$GetLine$ store the text in a variable preferably, so I can do an ^InsertHtml cmd to change the text into:
              >>
              >> <a href="http:///www.something.com">Name of Link</a>
              >>
              > Either will work, a illustrated by running the following test clip;:
              >
              > ^!Open ^?{(T=O)Select File to work from}
              > ^!SetCursor 1:1
              > ^!Select 1
              > ^!Set %Name1%=^$GetSelection$
              > ^!SetCursor 2:1
              > ^!Select 1
              > ^!Set %Link1%=^$GetSelection$
              > ^!Select 0
              > ; The following should produce the same results, but with fewer lines of
              > code.
              > ^!Set %Name2%=^$GetLine(1)$
              > ^!Set %Link2%=^$GetLine(2)$
              > ^!Continue Name1=^%Name1% and Link1=^%Link1%^%NL%Name2=^%Name2% and
              > Link2=^%Link2%
              >
              > So to do your task I'd use something like this:
              >
              > ^!Open ^?{(T=O)Select File to work from}
              > ^!Set %Name%=^$GetLine(1)$; %Link%=^$GetLine(2)$
              > ^!Set %Result%="<a href'="^%Link%">^%Name%</a>"
              > ^!Continue Result=^%Result%
              >
              >
              >
              > ------------------------------------
              >
              > Fookes Software: http://www.fookes.com/
              > NoteTab website: http://www.notetab.com/
              > NoteTab Discussion Lists: http://www.notetab.com/groups.php
              >
              > ***
              > Yahoo! Groups Links
              >
              >
              >
              >
              >
            • swimmer70002
              Hey Lotta, Thanks for responding. I have an ^InsertHTML going into another txt file. Yea, the Line 1: and Line 2: were just expression from where the text is
              Message 6 of 14 , Feb 5, 2010
              • 0 Attachment
                Hey Lotta,

                Thanks for responding. I have an ^InsertHTML going into another txt file. Yea, the Line 1: and Line 2: were just expression from where the text is positioned in the file. I think another issue I'm facing is that the hyperlink text is so huge, it messes this up when I do a loop. I tried swapping Line with Paragraph in ^!Select, but it keeps on becoming broken.

                --- In ntb-clips@yahoogroups.com, loro <tabbie@...> wrote:
                >
                > At 04:22 2010-02-05, you wrote:
                > >I'm trying to create a simple clip that will take the first two
                > >lines of text, from a random .txt file, and turn it into an HTML
                > >hyperlinked name.
                > >
                > >My problem is that I don't know if it's better to use a ^!SelectLine
                > >or ^$GetLine$ command. Unfortunately, NoteTab Help doesn't give
                > >enough usage examples for me to really figure out how these two commands work.
                > >
                > >Say I have a text file, and it has lines to follow
                > >
                > >Random.txt
                > >Line 1: Name of link
                > >Line 2: http://www.something.com
                > >
                > >How do I use ^!SelectLine or ^$GetLine$ store the text in a variable
                > >preferably, so I can do an ^InsertHtml cmd to change the text into:
                > >
                > ><a href="http:///www.something.com">Name of Link</a>
                >
                > Something like this. I take it it doesn't really say "Line 1:" and
                > Line 2:" in the real text?
                >
                > ^!Jump text_start
                > ^!Set %linktext%=^$GetLine$
                > ^!Jump +1
                > ^!Set %link%=^$GetLine$
                > ^!Info <a href="^%link%">^%linktext%</a>
                >
                > If you want the link inserted in the same document, you could go on
                > like the below.
                >
                > ^!Jump text_start
                > ^!Select 2
                > ^!InsertText <a href="^%link%">^%linktext%</a>
                >
                >
                > Lotta
                >
              • swimmer70002
                Hey Sheri, Thanks for your response. I realized in my post, that I could find better syntax use for both commands in older posts here. I did forget a space as
                Message 7 of 14 , Feb 5, 2010
                • 0 Attachment
                  Hey Sheri,

                  Thanks for your response. I realized in my post, that I could find better syntax use for both commands in older posts here. I did forget a space as well. I'm using NoteTab Pro, btw.

                  I another problem, I had discovered, was that the hyperlink was so big, it would seem to break my program. For some reason that regex replacement code works like a charm. I looked at the problem a little more and discovered that text editors don't constitute a new line, until the 'Enter' key is pressed. When notetab opens the file internally, it sees a massive line of text, and then chops it up into more lines. In other words, my single hyperlink line becomes two or three new lines, when opened, and the prgm goes nuts.

                  --- In ntb-clips@yahoogroups.com, "Sheri" <silvermoonwoman@...> wrote:
                  >
                  > --- In ntb-clips@yahoogroups.com, "swimmer70002" <swimmer70002@> wrote:
                  > >
                  > > I'm trying to create a simple clip that will take the first two
                  > > lines of text, from a random .txt file, and turn it into an HTML
                  > > hyperlinked name.
                  > >
                  > > My problem is that I don't know if it's better to use a
                  > > ^!SelectLine or ^$GetLine$ command. Unfortunately, NoteTab Help
                  > > doesn't give enough usage examples for me to really figure out
                  > > how these two commands work.
                  > >
                  > > Say I have a text file, and it has lines to follow
                  > >
                  > > Random.txt
                  > > Line 1: Name of link
                  > > Line 2: http://www.something.com
                  > >
                  > > How do I use ^!SelectLine or ^$GetLine$ store the text in a
                  > > variable preferably, so I can do an ^InsertHtml cmd to change the
                  > > text into:
                  > >
                  > > <a href="http:///www.something.com">Name of Link</a>
                  > >
                  > > ?
                  > >
                  >
                  > Probably the best way to accomplish the task is a regex replacement:
                  >
                  > ^!Jump Doc_Start
                  > ^!Replace "^(.+)\R(.+)$" >> "<a href="$2">$1</a>" RS
                  >
                  > Jump to the start to make sure it finds the first two lines. In the search text, the parenthesized portions can be referenced on the replacement side with $<num> where <num> is the consecutive number of the parentheses counting from the left. So the link's name is in $1 and the link itself is in $2. The "\R" in the pattern is a metacharacter that stands in for the control characters between the lines.
                  >
                  > But you also asked how to store text into a variable. The ^!Set command does that.
                  >
                  > e.g.,
                  > ^!Set %LinkName%="^$StrTrim(^$GetLine(1)$)$"
                  > ^!Set %Link%="^$StrTrim(^$GetLine(2)$)$"
                  > ^!Jump Doc_Start
                  > ^!Select 2
                  > ^!InsertHtml <a href="^%Link%">^%LinkName%</a>
                  >
                  > There is no such command as ^!SelectLine
                  >
                  > You can select the current line with
                  >
                  > ^!Select Line
                  >
                  > but keep in mind that the selection then includes the carriage return and line feed control characters as well as the other characters on the line. To exclude them, use ^!Select EOL instead.
                  >
                  > ^!Jump Line_Start
                  > ^!Select EOL
                  > ^!Set %LineContent%=^$GetSelection$
                  > ^!Prompt Line Content is ***^%LineContent%***
                  >
                  > In Standard and Light, ^$GetLine$ includes the two line-breaking control characters -- that is why I used ^$StrTrim$ in the sample usage above.
                  >
                  > Regards,
                  > Sheri
                  >
                • swimmer70002
                  Hey Don, Thanks for the response. I got the syntax to work, but the program breaks when there s a massive html link inserted in my second line. I m discussing
                  Message 8 of 14 , Feb 5, 2010
                  • 0 Attachment
                    Hey Don,

                    Thanks for the response. I got the syntax to work, but the program breaks when there's a massive html link inserted in my second line. I'm discussing it with Sheri, because her regex replacement command overcomes this problem. But that trick with the ^!Open (ask for filename) is pretty genius and I wouldn't have thought you could do that. Programming is so much fun.

                    --- In ntb-clips@yahoogroups.com, Don Daugherty <daugherty@...> wrote:
                    >
                    > Oops! Set %Result%= line should read as follows (WITHOUT a single-quote
                    > after href):
                    >
                    > ^!Set %Result%="<a href="^%Link%">^%Name%</a>"
                    >
                    > Don Daugherty wrote:
                    > > swimmer70002 wrote:
                    > >
                    > >> I'm trying to create a simple clip that will take the first two lines of text, from a random .txt file, and turn it into an HTML hyperlinked name.
                    > >>
                    > >> My problem is that I don't know if it's better to use a ^!SelectLine or ^$GetLine$ command. Unfortunately, NoteTab Help doesn't give enough usage examples for me to really figure out how these two commands work.
                    > >>
                    > >> Say I have a text file, and it has lines to follow
                    > >>
                    > >> Random.txt
                    > >> Line 1: Name of link
                    > >> Line 2: http://www.something.com
                    > >>
                    > >> How do I use ^!SelectLine or ^$GetLine$ store the text in a variable preferably, so I can do an ^InsertHtml cmd to change the text into:
                    > >>
                    > >> <a href="http:///www.something.com">Name of Link</a>
                    > >>
                    > > Either will work, a illustrated by running the following test clip;:
                    > >
                    > > ^!Open ^?{(T=O)Select File to work from}
                    > > ^!SetCursor 1:1
                    > > ^!Select 1
                    > > ^!Set %Name1%=^$GetSelection$
                    > > ^!SetCursor 2:1
                    > > ^!Select 1
                    > > ^!Set %Link1%=^$GetSelection$
                    > > ^!Select 0
                    > > ; The following should produce the same results, but with fewer lines of
                    > > code.
                    > > ^!Set %Name2%=^$GetLine(1)$
                    > > ^!Set %Link2%=^$GetLine(2)$
                    > > ^!Continue Name1=^%Name1% and Link1=^%Link1%^%NL%Name2=^%Name2% and
                    > > Link2=^%Link2%
                    > >
                    > > So to do your task I'd use something like this:
                    > >
                    > > ^!Open ^?{(T=O)Select File to work from}
                    > > ^!Set %Name%=^$GetLine(1)$; %Link%=^$GetLine(2)$
                    > > ^!Set %Result%="<a href'="^%Link%">^%Name%</a>"
                    > > ^!Continue Result=^%Result%
                    > >
                    > >
                    > >
                    > > ------------------------------------
                    > >
                    > > Fookes Software: http://www.fookes.com/
                    > > NoteTab website: http://www.notetab.com/
                    > > NoteTab Discussion Lists: http://www.notetab.com/groups.php
                    > >
                    > > ***
                    > > Yahoo! Groups Links
                    > >
                    > >
                    > >
                    > >
                    > >
                    >
                  • loro
                    ... Do you have WordWrap on? If so you may need to turn it off (in the clip). These line commands and functions work with displayed lines or what they should
                    Message 9 of 14 , Feb 5, 2010
                    • 0 Attachment
                      swimmer70002 wrote:
                      >Thanks for responding. I have an ^InsertHTML going into another txt
                      >file. Yea, the Line 1: and Line 2: were just expression from where
                      >the text is positioned in the file. I think another issue I'm facing
                      >is that the hyperlink text is so huge, it messes this up when I do a
                      >loop. I tried swapping Line with Paragraph in ^!Select, but it keeps
                      >on becoming broken.

                      Do you have WordWrap on? If so you may need to turn it off (in the
                      clip). These line commands and functions work with displayed lines or
                      what they should be called. That is, the result may be different
                      depending on if WW is on or off.

                      Lotta
                    • Don - HtmlFixIt.com
                      Do you get the same response if you turn off line wrap before starting the project?
                      Message 10 of 14 , Feb 5, 2010
                      • 0 Attachment
                        Do you get the same response if you turn off line wrap before starting
                        the project?

                        swimmer70002 wrote:
                        > Hey Sheri,
                        >
                        > Thanks for your response. I realized in my post, that I could find better syntax use for both commands in older posts here. I did forget a space as well. I'm using NoteTab Pro, btw.
                        >
                        > I another problem, I had discovered, was that the hyperlink was so big, it would seem to break my program. For some reason that regex replacement code works like a charm. I looked at the problem a little more and discovered that text editors don't constitute a new line, until the 'Enter' key is pressed. When notetab opens the file internally, it sees a massive line of text, and then chops it up into more lines. In other words, my single hyperlink line becomes two or three new lines, when opened, and the prgm goes nuts.
                        >
                      • Axel Berger
                        ... Thanks, Lotta, thats good to know. It hasn t bitten me yet but it surely would have some day. Hope I ll remember. Axel
                        Message 11 of 14 , Feb 5, 2010
                        • 0 Attachment
                          loro wrote:
                          > These line commands and functions work with displayed lines

                          Thanks, Lotta, thats good to know. It hasn't bitten me yet but it surely
                          would have some day. Hope I'll remember.

                          Axel
                        • John Shotsky
                          [Hope I ll remember.] I have a clip called My Notes. It calls up a text file I stick in the documents folder of NoteTab. In that, I leave myself notes about
                          Message 12 of 14 , Feb 5, 2010
                          • 0 Attachment
                            [Hope I'll remember.]

                            I have a clip called My Notes. It calls up a text file I stick in the documents folder of NoteTab. In that, I leave
                            myself notes about various things, gotchas, etc. Sometimes, a sample clip section to remind myself how it works.



                            I don't know why it took me so long to create that little clip, but now I use it constantly, and almost always have that
                            document open. I even post my own bugs in there, and delete them when I fix them. It's my 'yellow sticky note' feature.
                            I used to write these notes down in a notebook, but then I had to flip pages forever to find what I had written. In a
                            text file, you just search.



                            Regards,

                            John



                            From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Axel Berger
                            Sent: Friday, February 05, 2010 12:57 PM
                            To: ntb-clips@yahoogroups.com
                            Subject: Re: [Clip] Not sure to use ^!SelectLine or ^$GetLine$





                            loro wrote:
                            > These line commands and functions work with displayed lines

                            Thanks, Lotta, thats good to know. It hasn't bitten me yet but it surely
                            would have some day. Hope I'll remember.

                            Axel





                            [Non-text portions of this message have been removed]
                          • swimmer70002
                            Yep. That solves the problem now. Thanks.
                            Message 13 of 14 , Feb 5, 2010
                            • 0 Attachment
                              Yep. That solves the problem now. Thanks.

                              --- In ntb-clips@yahoogroups.com, "Don - HtmlFixIt.com" <don@...> wrote:
                              >
                              > Do you get the same response if you turn off line wrap before starting
                              > the project?
                              >
                              > swimmer70002 wrote:
                              > > Hey Sheri,
                              > >
                              > > Thanks for your response. I realized in my post, that I could find better syntax use for both commands in older posts here. I did forget a space as well. I'm using NoteTab Pro, btw.
                              > >
                              > > I another problem, I had discovered, was that the hyperlink was so big, it would seem to break my program. For some reason that regex replacement code works like a charm. I looked at the problem a little more and discovered that text editors don't constitute a new line, until the 'Enter' key is pressed. When notetab opens the file internally, it sees a massive line of text, and then chops it up into more lines. In other words, my single hyperlink line becomes two or three new lines, when opened, and the prgm goes nuts.
                              > >
                              >
                            • swimmer70002
                              Yea. I just discovered that. Thanks for the help.
                              Message 14 of 14 , Feb 5, 2010
                              • 0 Attachment
                                Yea. I just discovered that. Thanks for the help.

                                --- In ntb-clips@yahoogroups.com, loro <tabbie@...> wrote:
                                >
                                > swimmer70002 wrote:
                                > >Thanks for responding. I have an ^InsertHTML going into another txt
                                > >file. Yea, the Line 1: and Line 2: were just expression from where
                                > >the text is positioned in the file. I think another issue I'm facing
                                > >is that the hyperlink text is so huge, it messes this up when I do a
                                > >loop. I tried swapping Line with Paragraph in ^!Select, but it keeps
                                > >on becoming broken.
                                >
                                > Do you have WordWrap on? If so you may need to turn it off (in the
                                > clip). These line commands and functions work with displayed lines or
                                > what they should be called. That is, the result may be different
                                > depending on if WW is on or off.
                                >
                                > Lotta
                                >
                              Your message has been successfully submitted and would be delivered to recipients shortly.