Problem with Windows filesnames containing embedded spaces

Help
2014-07-24
2014-08-16
  • Bill Stephens
    Bill Stephens
    2014-07-24

    I'm trying to set up THE as a replacement for Kedit. I'm currently using THE 3.3RC1.

    I started with a simple batch file containing the following 2 lines:

    @echo off
    c:\thew\the.exe %1

    The idea is to be able to drag and drop a text file onto the icon associated with this batch file.

    When I drag and drop a file whose filename does not contain embedded spaces, this works. When the filename contains embedded spaces, it fails to edit the desired file, thinking that the spaces must mean multiple files are to be edited, and opens multiple windows for each space-delimited element on the command line that is not a switch.

    So I wrote an ooREXX program that does the following:

    • check if a filename contains spaces, and if so, substitute "_" for space characters in the filename and rename the file.
    • invoke THE
    • rename the file back to its original name

    When I do this, THE thinks this is a new file, saying "New file ..." and the filearea is empty. If I change the REXX program to invoke NotePad instead, everything works as expected, so there are no logic errors in the REXX program.

    I saw one other post regarding a problem with embedded spaces (from April of 2014) but I don't recall seeing a resolution.

    I have two suggestions:

    1) add another command-line switch, perhaps "-f", which would then be followed by a filename. This switch would have the restriction that it must always appear last, and that the argument which follows is to be interpreted as a single filespec, right up to the end of the line.

    2) allow filenames on the command line to be surrounded with delimiter characters, such as single or double quotes, braces, brackets or whatever, so that the parser would not space-parse out the contents of the delimited strings. In this manner, the native ability of THE to support multiple files to be edited is preserved.

    As it stands now, I cannot use THE, because the use of embedded spaces is ubiquitous within Windows, not only for filenames, but for folders as well (e.g., "c:\Program Files\etc...").

    I hope a solution can be made available.

     
    • Mark Hessling
      Mark Hessling
      2014-07-24

      I had a chance to experiment with this and here is what works for me:

      @echo off
      c:\thew\the.exe "%~1"

      Will work for files with spaces or without.

      As an extra, you may want to add THE's -1 (that's a one) switch, so all
      files dragged to the shortcut a placed in the ring in the one instance
      of THE.
      @echo off
      c:\thew\the.exe -1 "%~1"

      Cheers, Mark

      On 24/07/14 22:19, Bill Stephens wrote:

      I'm trying to set up THE as a replacement for Kedit. I'm currently
      using THE 3.3RC1.

      I started with a simple batch file containing the following 2 lines:

      @echo off
      c:\thew\the.exe %1

      The idea is to be able to drag and drop a text file onto the icon
      associated with this batch file.

      When I drag and drop a file whose filename does not contain embedded
      spaces, this works. When the filename contains embedded spaces, it
      fails to edit the desired file, thinking that the spaces must mean
      multiple files are to be edited, and opens multiple windows for each
      space-delimited element on the command line that is not a switch.

      So I wrote an ooREXX program that does the following:

      • check if a filename contains spaces, and if so, substitute "_" for
        space characters in the filename and rename the file.
      • invoke THE
      • rename the file back to its original name

      When I do this, THE thinks this is a new file, saying "New file ..."
      and the filearea is empty. If I change the REXX program to invoke
      NotePad instead, everything works as expected, so there are no logic
      errors in the REXX program.

      I saw one other post regarding a problem with embedded spaces (from
      April of 2014) but I don't recall seeing a resolution.

      I have two suggestions:

      1) add another command-line switch, perhaps "-f", which would then be
      followed by a filename. This switch would have the restriction that it
      must always appear last, and that the argument which follows is to be
      interpreted as a single filespec, right up to the end of the line.

      2) allow filenames on the command line to be surrounded with delimiter
      characters, such as single or double quotes, braces, brackets or
      whatever, so that the parser would not space-parse out the contents of
      the delimited strings. In this manner, the native ability of THE to
      support multiple files to be edited is preserved.

      As it stands now, I cannot use THE, because the use of embedded spaces
      is ubiquitous within Windows, not only for filenames, but for folders
      as well (e.g., "c:\Program Files\etc...").

      I hope a solution can be made available.


      Problem with Windows filesnames containing embedded spaces
      https://sourceforge.net/p/hessling-editor/discussion/93310/thread/b36bb418/?limit=25#eb12


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/hessling-editor/discussion/93310/
      https://sourceforge.net/p/hessling-editor/discussion/93310

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/
      https://sourceforge.net/auth/subscriptions

      --

      • Mark Hessling, mark@rexx.org http://www.rexx.org/
      • Author of THE, a Free XEDIT/KEDIT editor and, Rexx/SQL, Rexx/CURL, etc.
      • Maintainer of Regina Rexx interpreter
      • Use Rexx? join the Rexx Language Association: http://www.rexxla.org/

       
      Attachments
      • Bill Stephens
        Bill Stephens
        2014-08-08

        Doesn't work - just get message "command completed" and an empty file. This is 3.3RC1.

         
  • LesK
    LesK
    2014-08-09

    Your profile also has to be capable of handling files with imbedded
    blanks or you're in trouble.

    I do all my coding (THE & ooRexx) from within THE, using it as an IDE.
    To that end I have a lot of tools to make life easier. You can see
    my presentations about them at the rexxla.org symposium pages for
    2007, 2008, 2011, 2012 & 2013. I tried posting the links once, but
    SF didn't let me.

     
  • Bill Stephens
    Bill Stephens
    2014-08-13

    There are no statements currently in my profile that do anything other than set a few function keys and colors and other settings.

    Apparently I can't use THE as a drop-in replacement for KEDITW in a Windows environment. Too bad ...

     
  • LesK
    LesK
    2014-08-16

    No, probably not as a 'drop in' replacement for KEDITW, no more
    than it was a 'drop in' replacement for VM Xedit for me when I was
    forced to retire. But I adapted and, in fact, was impressed by how
    powerful THE was. Especially since it was free and I was facing some
    severe financial restrictions.

    The biggest change for me was to do all my work from within THE,
    whereas on VM I did my work from FULIST (now replaced with FILELIST,
    which runs in Xedit). That mental switch led me to develop the tools
    I needed for that environment, just like I had done for the CMS
    environment on VM. So now I seldom use Explorer or the command window.
    Instead, almost everything is done from THE.