FindInFiles and ReplInFiles not correct compiled after creating/editing a macro with them with UE v25.00 (fixed)

FindInFiles and ReplInFiles not correct compiled after creating/editing a macro with them with UE v25.00 (fixed)

5
NewbieNewbie
5

    Mar 29, 2018#1

    Version 25.00 German - I just need the FindInFiles command in a macro and found the macro editor is doing weird stuff when closing. It appends or replaces the strings containing folder, extensions and search term. It's impossible NOT to have "" "" "" at the end of the line starting with FindInFiles. Inserting content into this string results in appending new "" triplets.

    Even when I try to copy an existing and working macro into a new one it fails that way.

    Anyone else noticed that behavior?

    6,680583
    Grand MasterGrand Master
    6,680583

      Mar 29, 2018#2

      Yes, I can confirm unfortunately this issue (bug) of macro editor with 32-bit English UltraEdit v25.00.0.58.

      I quick recorded a simple Find in Files into a macro. Playing the quick recorded macro works fine. But after opening macro editor, making any change on macro containing FindInFiles with correct parameters, closing the macro editor with confirming update of the macro and running the recompiled macro, the FindInFiles is not working anymore. After reopening the recompiled macro in macro editor, I can see two additional "" displayed on FindInFiles line. If a make once again a change on macro not in line with FindInFiles, close the macro editor, confirm update of macro and reopen the macro again in macro editor, there are once again two "" added resulting now in four wrong "" on FindInFiles line.

      A similar issue exists with macro command ReplInFiles on which UltraEdit v25.00.0.58 on update of modified macro appends always three additional "".

      Please report this issue by email to IDM support. I have done the same to increase the priority for fixing it although I suppose this issue gets immediately a very high priority for fixing. I have received already the reply with the confirmation that the issue could be reproduced by IDM support too.

        Jul 08, 2018#3

        This bug is fixed with UltraEdit for Windows v25.00.0.82. UEStudio v18.00 (any build) doesn't have this bug.

        The bug was caused by a change on how strings of the following macro commands must be written in Edit/Create Macro dialog in multi-line macro code edit field:
        • Find
        • FindInFiles
        • Replace
        • ReplInFiles
        There was since beginning of UltraEdit the problem that UltraEdit supported recording macros with multi-line search/replace strings and as well as search/replace strings with one or more double quotes inside. While in binary code of a macro such search/replace strings were never a problem, it was always a problem to compile macro code edited or created in Edit/Create Macro dialog on a search/replace string containing " or being a multi-line search/replace string on which one line inside the multi-line string by chance ends with a double quote.

        Where does one string containing " and/or spanning over multiple lines and containing a line ending with " really end and where does the next string really start?

        For that reason there was taken the decision by IDM to ultimately solve this problem by introducing a new decoding of binary recorded/stored macros and encoding of macro sources entered directly in Edit/Create Macro dialog window containing one of the four macro commands Find, FindInFiles, Replace and ReplInFiles.

        For all strings of those four commands, and only those four commands, the rules regarding to " (straight double quote) and \ (backslash) are as follows:
        1. A double quote inside a string must be always escaped with a backslash.
        2. A backslash inside a string must be escaped with a backslash only
          • if the backslash is the last character on a string like the directory path on FindInFiles, or
          • if the backslash is followed by a double quote or another backslash.
        In every other case a single backslash has to be used for representing a single backslash.

        Example:

        PerlReOn
        ReplInFiles RegExp Log "C:\Temp\Test\\" "*.txt" "(\\\".+)\\\
        (.+\")" "\1 \2"

        A multi-line Perl regular expression search string is used here to replace for example

        "Hello\
        world!"

        by

        "Hello world!"

        in all *.txt files in directory C:\Temp\Test\.

        The first " is escaped unnecessarily in Perl regular expression search string with a backslash which requires two more escaping backslashes resulting in \\\".

        As a \ in a Perl regular expression string must be escaped with a backslash to be interpreted as literal character, the search string in Edit/Create Macro dialog window must be escaped with one more backslash resulting in \\\.

        The " as last but one character of Perl regular expression search string must be escaped with a backslash resulting in \".

        What is the search string really entered on recording this Perl regular expression Replace in Files command?

        It was:

        (\".+)\\
        (.+")

        Better would be using the search string (\x22.+)\x5C\r\n(.+\x22) which is the same search string for Perl regular expression engine, but no character must be escaped in Edit/Create Macro dialog window on using this variant.


        What does this mean for existing macros?

        Every macro code posted in the forums containing Find, FindInFiles, Replace or ReplInFiles or stored in text files as backup to binary *.mac files not explicitly using this syntax and containing in a search/replace string a double quote or a backslash as last character on a string or \" or \\ needs to be modified before the macro code can be copied into Edit/Create Macro dialog window and compiled by UE v25.00.0.82 or UEStudio v18.00 or any later version.

        Otherwise (hopefully) following error message is displayed on closing the Edit/Create Macro dialog window and confirming to update the macro:
        Incorrect Macro Command Parameter

        At least one string parameter contains improperly escaped quotes or
        backslashes, or the expected amount of string parameters was not met.
        Macros recorded or created with UltraEdit for Windows < 25.00 or UEStudio < v18.00 and stored already binary as *.mac files work as long as UltraEdit/UEStudio doesn't fail to upgrade the binary macro code on load for whatever reason. Macros created with any build of UltraEdit v25.10 stored as binary *.mac file work also with any build of UltraEdit v25.00.


        What is about macro usage and editing with UE versions 25.00.0.53, 25.00.0.58, 25.00.0.59 and 25.00.0.68?

        Those are the public released versions of UltraEdit version 25.00 prior version 25.00.0.82.

        Macros containing one of the four commands recorded with those three builds of UE v25.00 work. But it is nearly impossible with those three commands to make any modification on any macro containing Find, FindInFiles, Replace or ReplInFiles with Edit/Create Macro dialog.

        PS: The Windows commands forfiles, reg and robocopy use the same special interpretation of backslashes within an argument string of the command.
        Best regards from an UC/UE/UES for Windows user from Austria