/ Forums / Advansys Formativ / Creating Solutions with Formativ / CopyHTMLToClipboard and space characters in file names

  • Creator
    Topic
  • #4168
    Immi
    Participant

      CopyHTMLToClipboard appears not to work with strings containing spaces. It cuts the string at the first space.

      Here is my sample code:

      sFilename = “C:Program FilesGroupWiseGroupWise.exe”
      Utilities.CopyHTMLToClipboard(“<DIV><A href=file://” & sFilename & “>” & sFilename & “</DIV>”)
      GroupWise.EditPaste

      This will cut the link to “C:Program” … :-(

      Any ideas? Help is appeciated.
      Stephan

    • Author
      Replies
    • #7343
      Support 1a
      Participant

        The MS DOM doesn’t like spaces. I suspect you may need to replace the spaces in the URL with HTML encoded spaces, ‘%20’ from memory, before you copy the data to the clipboard.

        Regards,

        Advansys Support

        #7340
        Support 1
        Participant

          In your sample, sFileName should be encoded so it is a valid component of a URL (“file://…” in this case). You can do this with Formativ:

            dim iFileName
            dim oHtmlDom
          
            set oHtmlDom = Utilities.HTMLDom
            iFilename = oHtmlDom.HTMLEncode("C:Program FilesGroupWiseGroupWise.exe")
            ...

          You may need to use other methods of HTMLDom to do all that’s needed, eg. DosPathToUnixPath.

          I hope this helps you.

          Regards,
          Advansys Support

          #7341
          Immi
          Participant

            Hi Support 1 & 3

            I have tried both solutions (HTMLencode and DosPathToUnixPath). They both cause the same problem. Thae path gets truncated. This is the HTML generated code:

            HTMLEncode:
            <A href=”file:///C:/Program” FilesGroupWiseGrpWise.exe>C:Program FilesGroupWiseGrpWise.exe</A>

            DosPathToUnixPath:
            <A href=”file:///C:/Program” GrpWise.exe GroupWise Files>C:/Program Files/GroupWise/GrpWise.exe</A>

            Obviously the ” gets put in at the wrong place. This happens with GW6.5 and 7.0.
            Funny enough I can later correct the path with the ‘insert link’ button and the space problem is gone. Not really a work around…. 🙁

            I have resorted converting the filename to a 8.3 filename. This works.

            Thanks for your help!

            Stephan

            #7342
            Support 1
            Participant

              My apologies for misinforming you about HtmlEncode. In fact this function is for encoding characters deemed ‘special’ in HTML, eg. “&” is encoded as “&amp;”.

              If you need a general-purpose routine for encoding a URL, you will need to write one (unless you can track down some source code via the Web, say). Google turns up this reference on which characters must be encoded.

              I hope this is helpful.

              Regards,
              Advansys Support

            Viewing 4 replies - 1 through 4 (of 4 total)
            • You must be logged in to reply to this topic.