Macro set to run on each file load is not executed when file is opened using UltraEdit shell extension

Macro set to run on each file load is not executed when file is opened using UltraEdit shell extension

3
NewbieNewbie
3

    Sep 26, 2018#1

    The following macro is executed when file is loaded. It seems that the macro does not work when file is opened with right click. It works when the file is dragged on to UltraEdit. Could you help to comment why and how to solve the problem? Many thanks for your efforts!

    Code: Select all

    IfExtIs "gjf"
    InsertMode
    ColumnModeOff
    HexOff
    Top
    Find "%chk="
    IfFound
    Key END
    StartSelect
    Key HOME
    Delete
    EndSelect
    CopyFilePath
    "CopyFilePath seems to be async, write something to let it finish"
    Paste
    Find Up ".gjf"
    Replace ".chk"
    Find Up "\\"
    Replace ""
    StartSelect
    Key HOME
    Delete
    EndSelect
    Find "."
    Key LEFT ARROW
    StartSelect
    Key HOME
    Copy
    EndSelect
    Key HOME
    "%chk="
    PerlReOn
    Find RegExp "(?s)(?<=\n)\s*\n.*?\n\s*(?=\n)"
    "
    "
    Paste
    "
    "
    EndIf
    EndIf
    
    PS: UltraEdit 25.20.0.72 x86 on Windows 10 1709.16299 x64
    PPS: How to debug or run macro step by step?
    UEMacros.mac (834 Bytes)   31
    Alpha1_Alpha2_Alpha3.gjf (136 Bytes)   34
    Untitled Project.mp4 (1.18 MiB)   33
    video

    6,686585
    Grand MasterGrand Master
    6,686585

      Oct 01, 2018#2

      I can confirm that
      • opening a file using Explorer shell extension of UltraEdit (ue64ctmn.dll or ue32ctmn.dll) by right clicking on a file in Windows Explorer or any other application supporting the Explorer shell extensions like Total Commander and left clicking on context menu item UltraEdit as configured at Advanced - Settings or Configuration - File associations
      • and with an instance of UltraEdit already running
      • and with none of the options used at Advanced - Settings or Configuration - Application layout - Miscellaneous to start a new instance
      results in loading the file by 32-bit UltraEdit v25.20.0.72 without executing the macro set to run once on each load of a file.

      This issue is obviously a bug of 32-bit UltraEdit v25.20.0.72 and perhaps also 64-bit version (not tested by me) and former UltraEdit versions (not tested by me) which must be reported by email to IDM support to be fixed by a developer of UltraEdit in a future version.

      I use neither the shell extension of UltraEdit nor running a macro on each file load and so this issue does not bother me. For that reason I don't report this issue to IDM support by email.

      Please report this issue to IDM support by email.

      The macro configured to run on each file load is executed if no instance of UltraEdit is already running and so the shell extension has to start a new instance of UltraEdit with the full qualified file name passed as first argument to the UltraEdit executable on starting it.

      The macro can be optimized using following macro code:

      Code: Select all

      IfExtIs "gjf"
      InsertMode
      ColumnModeOff
      HexOff
      PerlReOn
      Top
      Find RegExp "%chk=\K.+$"
      IfFound
      Clipboard 9
      CopyFilePath
      Paste
      Top
      Find RegExp "%chk=\K.+\x5C(.+)\.gjf$"
      Replace "$1.chk"
      Top
      Find RegExp "%chk=\K(?:.+)(?=\.chk$)"
      Copy
      Find RegExp "(\r?\n)[\t ]*\1\K.*$"
      IfFound
      Paste
      EndIf
      ClearClipboard
      Clipboard 0
      EndIf
      EndIf
      
      It includes two workarounds for the bug discussed at Error when using Perl RegEx (.*\\). The first one is using \x5C instead of \\ and the second one is using $1 in replace string instead of \1 which is used in last search string on which $1 does not work. I really hope this bug is fixed in next hotfix version as it makes writing Perl regular expressions really a nightmare. Update: And the issue was fixed with UE v25.20.0.88 released two days after writing this reply.

      The macro works for files with DOS and with UNIX line endings.

      There is no macro debugger like the Visual Basic macro debugger in Microsoft Office applications. So it is not possible to single step debug UltraEdit macros.

      I insert command ExitMacro into the macro at a certain position in command sequence, run the macro, verify if everything is done as expected by the macro, use File - Revert to saved, open macro editor and move command ExitMacro downwards in macro code, run the macro again on file, verify if everything is done as expected again up to this point in command sequence, use again File - Revert to saved and so on until I could find out where I made the mistake or where the macro is not producing the expected result up to command ExitMacro.

      Very often I simply use Ctrl+Z one or more times after executing a macro to undo one modification after the other done by the macro to see the content of the file on the intermediate reformatting steps.
      Best regards from an UC/UE/UES for Windows user from Austria

      3
      NewbieNewbie
      3

        Oct 02, 2018#3

        Dear Mofi,

        Many thanks for your knowledgeable comments and your kind efforts to provide your previous debugging tips! 

        Sorry for not responding promptly!

        I have written to IDM support and referred to this forum post in the email.

        Best regards,

          Oct 09, 2018#4

          The bug is fixed in private user verification build 25.20.0.92 of UltraEdit for Windows. Many thanks for your helpful comments!

          I am wondering whether this post is going to be deleted? If yes, I will try to save a copy locally.

          6,686585
          Grand MasterGrand Master
          6,686585

            Oct 09, 2018#5

            This forum topic will not be deleted by me because of this bug was reproducible finally and exists in many versions of UltraEdit for Windows.
            Best regards from an UC/UE/UES for Windows user from Austria