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

Select URL and ^$IsUrl$

Expand Messages
  • joy8388608
    I m sure I ll be shot down if I go so far as to call this a bug , but I m surprised at the workings of Select URL and the IsUrl function. Perhaps someone
    Message 1 of 3 , Mar 27, 2014
    • 0 Attachment
      I'm sure I'll be shot down if I go so far as to call this a 'bug', but I'm surprised at the workings of "Select URL" and the IsUrl function. Perhaps someone can set me straight if I'm missing something.

      The help for Select URL says selects a URL at the cursor position, if any. I was hoping to have it set the error flag for IfError and select nothing if a URL was not found but it seems to select anything at the cursor position no matter what it is.

      I started looking at ^$IsUrl$ and found it returns true only for strings that begin with ftp:// and http://. It also returns true for af://wwwbingcom and httxxp://abcde which seems wrong. It is even more odd since something like www.bing.com turns blue with an underline which I thought indicated it was regocnized by NT as a URL. If so, why does IsUrl say it is not?

      I was obviously trying to select a URL at cursor position and test if it was valid. This appears to be harder than I thought it would be short of creating my own RegEx to examine the string.

      Any comments or suggestions on the above behavior and how to do what I want?

      Thanks
      Joy
    • flo.gehrke
      ... You are right. ^!Select URL selects any word and doesn t check whether it s an URL or not. So the if any in Help seems to be misleading. Probably, it s
      Message 2 of 3 , Mar 28, 2014
      • 0 Attachment
        ---In ntb-clips@yahoogroups.com, <mycroftj@...> wrote :

        > I'm surprised at the workings of "Select URL" and the IsUrl function.

        You are right. '^!Select URL' selects any word and doesn't check whether it's an URL or not. So the "if any" in Help seems to be misleading. Probably, it's "by design".

        > www.bing.com turns blue with an underline which I thought
        > indicated it was regocnized by NT as a URL. If so, why does
        > IsUrl say it is not?

        Can't confirm this. My test clip below will regard 'www.bing.com' as TRUE.

        It's a similar issue with EMAIL, FILENAME and may be more options.

        Though '^!Select URL' doesn't check a string the advantage is that - different from the WORD option - the selecting isn't limited by dots, colons, backslashs etc.

        Regards,
        Flo


        Clip for testing a list of URLs:

        ;  Add empty line to list if missing
        ^!Replace "\R*\Z" >> "\r\n" WRS
        ^!Jump Doc_Start

        :Select
        ^!Select URL
        ^!IfTrue ^$IsUrl(^$GetSelection$)$ True Else False

        :True
        ^!Jump Line_end
        ^!Insert ^%Space%=^%Space%TRUE
        ^!Goto Jump

        :False
        ^!Jump Line_end
        ^!Insert ^%Space%=^%Space%FALSE

        :Jump
        ^!Jump +1
        ^!If ^$GetRow$=^$GetLineCount$ End
        ^!Goto Select

      • joy8388608
        Interesting. The help places quotes around the string. This makes a difference in the results which I would say is a bug. Also, with or without quotes, there
        Message 3 of 3 , Mar 30, 2014
        • 0 Attachment
          Interesting. The help places quotes around the string. This makes a difference in the results which I would say is a bug. Also, with or without quotes, there are strings that are blue underlined in the text, but reported as NOT a url by the function.

          ^$IsUrl(^$GetSelection$)$
          www.true.com = TRUE (blue underlined)
          true.com = FALSE
          false.is.not.a.url = FALSE
          http://trueisaurl.com = TRUE (blue underlined)
          ftp://truealsoaurl.net = TRUE (blue underlined)
          xs://falsewhatisthis = FALSE (blue underlined)
          sy://falsewhatisthis?  = FALSE (blue underlined)
          https://truesymantec.com = TRUE (blue underlined)
          https://www.truesymantec.com = TRUE (blue underlined)


          ^$IsUrl("^$GetSelection$")$
          www.true.com = FALSE (blue underlined)
          true.com = FALSE
          false.is.not.a.url = FALSE
          http://trueisaurl.com = TRUE (blue underlined)
          ftp://truealsoaurl.net = TRUE (blue underlined)
          xs://falsewhatisthis = TRUE (blue underlined)
          sy://falsewhatisthis? = TRUE (blue underlined)
          https://truesymantec.com = TRUE (blue underlined)
          https://www.truesymantec.com = TRUE (blue underlined)

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