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

RE: [Clip] Setting Variables from text

Expand Messages
  • John Shotsky
    Don, that is indeed the problem. I had almost tried setting another variable, but didn t see how it would help, so I didn t. Still, it seems there should be an
    Message 1 of 4 , Dec 19, 2008
      Don, that is indeed the problem. I had almost tried setting another variable, but didn't see how it would help, so I didn't.

      Still, it seems there should be an easier way to suck some text into a variable.

      Thanks again,
      John

      From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of Don - HtmlFixIt.com
      Sent: Friday, December 19, 2008 8:11 AM
      To: ntb-clips@yahoogroups.com
      Subject: Re: [Clip] Setting Variables from text

      John,

      I believe you are a victim of a bug that arose in the latest version of
      notetab and that has been reported. GetReSubstrings will not work if
      there is just one substring! Add a second substring and you will get
      what you want.

      ^!Find "^(Source)\=(.+)\R" RS
      ^!IfError GoTo EndLoop001
      ^!SetArray %Value%=^$GetReSubstrings$

      ...
      ^!InsertText ^POCRSource is ^%Source1%

      I think will solve your issue until this is fixed.

      Don

      John Shotsky wrote:
      > I'm having a coding problem trying to set a variable from a text string. I've tried using the ^$GetReSubstrings$ function by
      > modifying another clip that works correctly, but it doesn't seem to work for this case. Maybe that's the wrong function to use.
      The
      > help system doesn't make it clear to me how to assign an unknown value from a text source to a variable.
      >
      > Here's the issue:
      > In the text, somewhere, will be a string like this:
      > Source=Book1 <==or Book2, or NewSource, etc.
      >
      > I want to find the string and set a variable named Source to the value found after the [=].
      > Here is my find, which works:
      > ^!Find "^Source\=(.+)\R" RS
      >
      > This is the whole segment:
      > ^!Jump Doc_Start
      > :Loop001
      > ^!Find "^Source\=(.+)\R" RS
      > ^!IfError GoTo EndLoop001
      > ^!SetArray %Value%=^$GetReSubstrings$
      > ^!Set %Source%=^%Value1%
      > ^!Jump Line_End
      > ^!InsertText ^POCRSource is ^%Source%
      > ^!If ^$GetRow$=^$GetTextLineCount$ EndLoop001
      > ^!Goto Loop001
      > :EndLoop001
      >
      > The output is always empty. It appears to me that Value1 isn't getting set.
      >
      > Can anyone see what I'm doing wrong? Is there a much simpler way to do this?
      >
      > Thanks,
      > John
      >



      [Non-text portions of this message have been removed]
    • Sheri
      ... That is true, but it seems kind of silly to be using arrays and getresubstrings when there is only one substring. You can use ^!Find to find a whole
      Message 2 of 4 , Dec 19, 2008
        --- In ntb-clips@yahoogroups.com, "Don - HtmlFixIt.com" <don@...> wrote:
        >
        > John,
        >
        > I believe you are a victim of a bug that arose in the latest
        > version of notetab and that has been reported. GetReSubstrings
        > will not work if there is just one substring! Add a second
        > substring and you will get what you want.

        That is true, but it seems kind of silly to be using arrays and
        getresubstrings when there is only one substring. You can use ^!Find
        to find a whole pattern or a substring, and assign ^$GetSelection$ to
        a variable.

        The original command given was

        ^!Find "^Source\=(.+)\R" RS

        and the ultimate variable (%source%) comes from substring 1.

        This pattern could be written so as to need no substrings. But for
        simplicity, I'm not changing the pattern.

        ^!Find "^Source\=(.+)\R" RS1
        ^!Set %source%=^$GetSelection$

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