Tapatalk

Macro save automatically transforms byte 0x08 (backspace) into "Key BACKSPACE"

Macro save automatically transforms byte 0x08 (backspace) into "Key BACKSPACE"

14
Basic UserBasic User
14

    Jul 23, 2019#1

    😎 Greetings to all the great people using UE!

    I use French UE 14.00+14 with code page Windows-1252.

    🤓 How would one show the character 0x08 in a simple ASCII text file using a macro? Can 0x08 be automatically loaded into say 😇 clipboard 8?

    6,685587
    Grand MasterGrand Master
    6,685587

      Jul 23, 2019#2

      A text file contains only characters with a code point greater 0x1F and the control characters carriage return, line feed, form feed, horizontal tab, perhaps also a vertical tab although that is really, really rare, and perhaps at end of file the control character End of File. A file containing any other control character in code point range 0x00 to 0x1F is per definition not anymore a text file.

      It is not possible to put a character or a string directly from macro into a clipboard. This is supported only by UltraEdit scripts since v14.20.

      In a macro the control character with code point 0x08 must be copied from active file to clipboard. In text edit mode this is tricky, but can be done by inserting a space, move character back before inserted space, use a Perl regular expression replace to replace the space by character with hexadecimal value 0x08, select this control character and cut it to clipboard.

      Code: Select all

      InsertMode
      ColumnModeOff
      HexOff
      " "
      Key LEFT ARROW
      PerlReOn
      Find MatchCase RegExp " "
      Replace "\x08"
      StartSelect
      Key LEFT ARROW
      Clipboard 8
      Cut
      EndSelect
      
      Don't forget to append the command UnixReOff (UltraEdit) or UnixReOn (Unix) on using usually one of the legacy regular expression engines.
      Best regards from an UC/UE/UES for Windows user from Austria

      14
      Basic UserBasic User
      14

        Jul 24, 2019#3

        😎
        Incredibly precise detailed and complete, MOFI the YODA of UE universe does it again ... what in the hex are you guys drinking in Austria? Great job and thanks from all.
        😎
        That said, your snippet didn't work for me, but using the basic search replace idea, I came up with:

        ","
        StartSelect
        Key LEFT ARROW
        UnixReOff
        Find MatchCase SelectText ","
        Replace All PreserveCase "BS" ... here between quotes is literally the backspace char which I get by printing byte to a text file to begin with ...
        EndSelect

        ... which does work for me. 🤓
        Which makes me wonder ... is there a way to insert commentary into macros?

        6,685587
        Grand MasterGrand Master
        6,685587

          Jul 24, 2019#4

          You are right, my macro code does not work in UE v14.00 which was unexpected by me and which I could see after temporarily restoring this old version of UltraEdit from year 2008.

          It is not possible to store comments in a macro compiled by UltraEdit to binary data on close/save. I recommended to have additionally to a *.mac file also a *.uem text file with the names of all macros, their properties and of course their code. Here it is possible to add also comments and get them syntax highlighted on adding to wordfile.uew the content of the wordfile for UltraEdit macros. See sticky topic Macro examples and reference for beginners and experts. It is always good to have a text version of the *.uem file in case of *.mac file gets ever corrupt and fails to load in future.
          Best regards from an UC/UE/UES for Windows user from Austria