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

Help with "escaping" double quotes from an input control

Expand Messages
  • spanishfreak88
    I am having trouble and think I may know what I am doing wrong, but have no idea as to how to correct it. I am designing a clip that will accept input from a
    Message 1 of 6 , Sep 15 11:11 PM
    • 0 Attachment
      I am having trouble and think I may know what I am doing wrong, but
      have no idea as to how to correct it. I am designing a clip that
      will accept input from a text box and reformat it to escape "illegal"
      characters for a URL. This clip, however, malfunctions when it comes
      to dealing with quotes inside of a string. I believe the notetab
      parser interprets the quotes within the string as string delimiters
      instead of string literals. I can't seem to find a way to correct
      this problem, though, since commands such as ^!Set %QueryString%
      =^$StrReplace(^$DecToChar(34)$;%25;^%QueryString%)$ return syntax
      errors (I have tried all the variations on the above command that I
      could think of). When I set the debug mode on, I could see the
      command is parsed, for example, as ^!Set %QueryString%=^$StrReplace
      (";%25;+"easter egg";)$
      (+"easter egg" is a search phrase for a search engine). I also
      attempted to perform a character-by-character analysis of the string
      and convert all non-alphanumeric characters to their appropriate url
      escape codes (" to %25, etc.) with the same result. Can anyone offer
      a suggestion?
    • Alan C.
      On Tue, 16 Sep 2003 06:11:44 -0000, spanishfreak88 wrote: [..]  I am designing a clip that ... [ . . ] ... ^!Set %QueryString%=~easter egg~ ^!Set
      Message 2 of 6 , Sep 15 11:46 PM
      • 0 Attachment
        On Tue, 16 Sep 2003 06:11:44 -0000, spanishfreak88 wrote:
        [..]
         I am designing a clip that
        > will accept input from a text box and reformat it to escape "illegal"
        > characters for a URL.  This clip, however, malfunctions when it comes
        > to dealing with quotes inside of a string.
        [ . . ]
        >^!Set %QueryString%
        > =^$StrReplace(^$DecToChar(34)$;%25;^%QueryString%)$ return syntax
        > errors
        > ^!Set %QueryString%=^$StrReplace(";%25;+"easter egg";)$


        ^!Set %QueryString%=~easter egg~
        ^!Set %QueryString%="^$StrReplace("~";""";"^%QueryString%";False;False)$"
        ^!Info ^%QueryString%

        (note the use of qoutes, 1 at very right hand end of critical string and another immediately after the =) shows quotes for me. (replaces tilde (or another character) with quote) May or may not work for what you are doing.

        ^!setcode may be another option if the above three lines don't do it.

        --
        Alan.
      • hsavage
        ... sf88, First, some commands and functions have optional fields. ^$StrReplace, as far as I know, doesn t have optional fields. The last 2 fields are
        Message 3 of 6 , Sep 16 6:30 AM
        • 0 Attachment
          spanishfreak88 wrote:

          > I believe the notetab
          > parser interprets the quotes within the string as string delimiters
          > instead of string literals. I can't seem to find a way to correct
          > this problem, though, since commands such as,
          >
          > ^!Set %QueryString%=^$StrReplace(^$DecToChar(34)$;%25;^%QueryString%)$
          >
          > return syntax errors (I have tried all the variations on the
          > above command that I could think of). When I set the debug
          > mode on, I could see the command is parsed, for example, as
          >
          > ^!Set %QueryString%=^$StrReplace(";%25;+"easter egg";)$
          >
          > I also attempted to perform a character-by-character analysis
          > of the string and convert all non-alphanumeric characters to
          > their appropriate url escape codes (" to %25, etc.) with the
          > same result.
          > Can anyone offer a suggestion?

          sf88,

          First, some commands and functions have optional fields. ^$StrReplace,
          as far as I know, doesn't have optional fields. The last 2 fields are
          missing.

          You may have omitted the fields just for email purposes because it was
          expedient. If not, one of the reasons the command is failing is
          probably because 2 fields are missing. The syntax should be fully
          utilized as in Help.

          ^$StrReplace("SubStr";"ReplaceStr";"Str";CaseSensitive;WholeWord)$

          The command in your email is,

          ^!Set %QueryString%=^$StrReplace(^$DecToChar(34)$;%25;^%QueryString%)$

          It should be closer to this,

          ^!Set
          %QueryString%=^$StrReplace("^$DecToChar(34)$";"%25";"^%QueryString%";0;0)$

          You might get by with this,

          ^!Set %QueryString%=^$StrReplace(""";"%25";"^%QueryString%";0;0)$

          The command is trying to remove quotes from Querystring and replace them
          with the html code for a quote, the elements being searched and replaced
          are, as far as the clip is concerned, just so much text.

          Quoting the search and replace elements delineates them as plain text.
          At least, that's the way I understand it.

          Missing or misplaced quotes can do odd things in a clip.

          hrs
        • spanishfreak88
          ... ^$StrReplace, ... are ... was ... You are partially correct; I did omit the last two options, but not intentionally. I do have both in my clip, but forgot
          Message 4 of 6 , Sep 16 8:47 PM
          • 0 Attachment
            --- In ntb-clips@yahoogroups.com, hsavage <hsavage@p...> wrote:
            > First, some commands and functions have optional fields.
            ^$StrReplace,
            > as far as I know, doesn't have optional fields. The last 2 fields
            are
            > missing.
            >
            > You may have omitted the fields just for email purposes because it
            was
            > expedient.

            You are partially correct; I did omit the last two options, but not
            intentionally. I do have both in my clip, but forgot to type them in
            my post <:-I. My problem however does not appear to be a result of
            improper use of the command itself, but with the appearance of quotes
            within a string. In my example, +"easter eggs", (I think) notetab
            interprets the quotes as delimiters of the string easter egg and
            returns an error because the plus sign occurs outside of the quotes.
            What I need is some way to force notetab to accept the quotes as part
            of the string itself. BTW, the string is input via a wizard field as
            such: ^!Set %QueryString%=^?{Enter your search term here:=Keyword or
            phrase}. Therefore, if I type quotes in the text box as part of the
            search expression, they have to be converted into the url escape
            codes. Is it perhaps possible to achieve this with a regular
            expression? (It would really be helpful if notetab had an onkeypress
            sort of event handler...) Thanks in advance for any other responses.

            Craig Nicholson
          • Larry Thomas
            Hi Craig, ... The solution to your problem is to enclose all of the quotes in quotes. Example: change + eastereggs to + easter eggs . Regards, Larry
            Message 5 of 6 , Sep 16 10:06 PM
            • 0 Attachment
              Hi Craig,

              At 03:47 AM 9/17/03 -0000, you wrote:
              >My problem however does not appear to be a result of
              >improper use of the command itself, but with the appearance of quotes
              >within a string. In my example, +"easter eggs", (I think) notetab
              >interprets the quotes as delimiters of the string easter egg and
              >returns an error because the plus sign occurs outside of the quotes.
              >What I need is some way to force notetab to accept the quotes as part
              >of the string itself. BTW, the string is input via a wizard field as
              >such: ^!Set %QueryString%=^?{Enter your search term here:=Keyword or
              >phrase}. Therefore, if I type quotes in the text box as part of the
              >search expression, they have to be converted into the url escape
              >codes. Is it perhaps possible to achieve this with a regular
              >expression? (It would really be helpful if notetab had an onkeypress
              >sort of event handler...) Thanks in advance for any other responses.

              The solution to your problem is to enclose all of the quotes in quotes.
              Example: change +"eastereggs" to "+"easter eggs"".

              Regards,

              Larry
              lrt@... e¿ê
            • hsavage
              ... Craig, I tried to give the example of quoting all the strings but I didn t know you were using a wizard to collect the input for the string. The example
              Message 6 of 6 , Sep 17 6:09 AM
              • 0 Attachment
                spanishfreak88 wrote:

                >> wrote:
                >
                > You are partially correct; I did omit the last two options, but not
                > intentionally.
                >
                > What I need is some way to force notetab to accept the quotes as part
                > of the string itself.
                >
                > BTW, the string is input via a wizard field as
                > such: ^!Set %QueryString%=^?{Enter your search term here:=Keyword or
                > phrase}. Therefore, if I type quotes in the text box as part of the
                > search expression, they have to be converted into the url escape
                > codes. Is it perhaps possible to achieve this with a regular
                > expression? (It would really be helpful if notetab had an onkeypress
                > sort of event handler...) Thanks in advance for any other responses.
                >
                > Craig Nicholson

                Craig,

                I tried to give the example of quoting all the strings but I didn't know
                you were using a wizard to collect the input for the string. The
                example below should ensure the string, at creation, is surrounded by
                quotes.

                quote after first = quote after
                closing curly brace.
                ^!Set %QueryString%="^?{Enter your search term here:=Keyword or phrase}"

                Try this, see if it helps.

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