Macro examples and reference for beginners and experts

Macro examples and reference for beginners and experts

6,686585
Grand MasterGrand Master
6,686585

    Mar 31, 2007#1

    Hello macro writers!
    • Are you a beginner and want to learn from an expert?
    • Or are you searching for a macro reference with some special hints and more?
    • Or do you want to comment your macros and view it with syntax highlighting and indentations?
    • Or do you write sometimes or often complex UltraEdit / UEStudio macros and don't like writing it in the small edit macro dialog?
    If you can answer one of those questions with YES, then you are right here.


    I have created a package which contains following:
    1. A macro file with complex macros ready for usage.
      To be more precise, the package contains 2 macro files:
      Mofis_Macro_Examples.mac is compatible with any UltraEdit since v10.20 and all versions of UEStudio.
      Mofis_Macro_Examples_old.mac is compatible also with UltraEdit v10.00 and later and maybe also lower versions of UE.

      Note: None of the macros are designed to work with enabled configuration setting Automatically copy to clipboard when selection is made. I will not modify any macro in this package or in my other macro packages to work correct when this in my point of view useless feature is enabled which is horrible for all macros and scripts. I can only strongly recommend not to use this auto copy feature when using macros or scripts. Also most macros will not work correct with word-wrap enabled. Disable word-wrap before running any macro from the macro file.
       
    2. A macro code file with the source code of the example macros.
      The UE / UES macro code file Mofis_Macro_Examples.uem contains the source code of the macros in the 2 macro files with lots of comments and at top of the file additional info how to setup UltraEdit or UEStudio to write macros in an edit window with all the great features of UE / UES like syntax highlighting, auto corrections, auto indent and re-indent existing macro code with a tab stop value individually specified for the file extension UEM for macro code files, macro commands tag list for quick help while editing, etc.
       
    3. A macro reference file written in HTML.
      The help page Edit Macro command of UltraEdit v13.00 and UEStudio v6.20 has been greatly improved and I hope contains now no mistakes or missing commands/parameters anymore (at least in the English version). But the table layout is not good for reading and it contains no special hints or any version information. So I have written my own macro reference with a list layout which is hopefully better readable. It contains also some special hints, some info about known bugs and version information as far as I was able to get it.
       
    4. A syntax highlighting wordfile for UE / UES macros.
      This file is hosted by UltraEdit, Inc. on their user-submitted wordfiles page. You can download it directly with the link above. Follow the instructions on the UltraEdit download page to add the content of this word file to the word file you currently use.
       
    5. A macro commands tag list file for UE / UES macros.
      This file is hosted also by UltraEdit, Inc. on their user-submitted tag files page. You can download it directly with the link above. Users of UltraEdit v13.00 or UEStudio v6.20 and later have a similar tag list for UE / UES macro commands already installed with the default taglist.txt / taglist.uet / taglistu.uet. In comparison with the tag list file on the download page the tag list in the default taglist*.* file is optimized for the version of UE / UES installed. Follow the instructions in the readme.txt at the tag list section on the download page or in Mofis_Macro_Examples.uem to add it to your current tag list file.
    The most important macro in Mofis_Macro_Examples*.mac is "Copy Macro Code" which copies the (selected) macro code into the Windows clipboard with all the steps necessary before it can be pasted into the edit macro dialog for compilation. Read the description for this macro in Mofis_Macro_Examples.uem for further details.


    The macro reference file is not a guidance for "How to start writing macros" and it is not a manual for UltraEdit / UEStudio macros.

    It is just a reference file with some additional hints, but certainly not a guidance for beginners. Learning by doing is the only method to become an UE / UES macro expert. Beginners should start with recording macros and then edit it a little and not try to write it directly as experts like I can do after years of practice.

    DISCLAIMER

    THE MACRO SET IN THE PACKAGE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, STATUTORY OR OTHERWISE, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO USE, RESULTS AND PERFORMANCE OF THE MACRO SET IS ASSUMED BY YOU AND IF THE MACRO SET SHOULD PROVE TO BE DEFECTIVE, YOU ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR OTHER REMEDIATION. UNDER NO CIRCUMSTANCES, CAN THE AUTHOR BE HELD RESPONSIBLE FOR ANY DAMAGE CAUSED IN ANY USUAL, SPECIAL, OR ACCIDENTAL WAY OR BY THE MACRO SET.

    DOWNLOAD

    You can download the package here:
    Mofis_Macro_Examples.zip (54.23 KiB)   0
    Mofi´s macro examples

    FEEDBACK

    If you have found a problem, or have suggestions, or feature requests, or additional info or just found a minor mistake, please reply to this thread and tell me.

    It would be fine if a native English speaking and writing user with good grammar and spelling correction skills could read the entire macro code file, the reference file and this post and report me the mistakes.

    HISTORY

    2007-04-12:
    In the macro reference file expanded the known bugs info of the commands GotoLine and GotoLineSelect. Made some other small changes mainly at top of the file. And last added appendix B - "Configuration options with influence on macro execution" - and appendix C - "History of this document".


    2007-04-22:
    In the macro reference file modified the known bug info for parameter Unicode of the commands FindInFiles and ReplInFiles. See history of the document for more details.


    2007-06-24:
    Updated the macro reference file because of new macro version introduced with UE v13.10 and UES v6.30 and some bugs are fixed by UltraEdit, Inc. as it is now documented too. See history of the document for details.


    2007-11-02:
    Updated the macro reference file by adding a new appendix about macro execution on files with active word-wrap, changed the CSS values to remove all fixed font size values and some other changes. See history of the document for details. The document uses now the base font size which the reader has specified in the browser settings.

    The macros DelDupInfo+ and DelDupInfo- are rewritten to work also on a file with active word-wrap mode. Other macros are not tested or adapted. So best disable word-wrap mode if you want to use any other macro from my collection.


    2007-12-09:
    Updated the macro reference file because of fixes for serious bugs done by UltraEdit, Inc. for UE v13.20a and UES v6.40a.


    2007-01-19:
    Updated the macro reference file again; just a few new information, nothing really important.


    2008-05-16:
    Updated the macro reference file by adding the new commands and parameters introduced with UE v14.00 and UES v6.50 and made some other small changes. See history of the document for more details. Updated also the URLs in Mofis_Macro_Examples.uem and some other general info in the comments. The macros are not modified.


    2008-05-26:
    Updated the macro reference file again; just a new bug info.


    2008-07-03:
    Updated the macro reference file again; added new FindInFiles parameter DisplayLinesDoNotMatch available since UE v14.10 and UES v6.60 and modified 2 bug info because the bugs were fixed with UE v14.10 and UES v6.60.


    2008-08-13:
    Added to the macro reference file a new bug info. Updated the macro "Convert hhk/hhc" because it did not work for *.hhk and *.hhc files created with Microsoft HTML Help WorkShop or Help & Manual because of a slightly different format then *.hhk and *.hhc files created by other CHM creating applications like Adobe RoboHelp.


    2008-10-17:
    Revised the macro reference file because of new Find parameter AllFiles available since UE v14.20 and some other macro related changes in UE v14.20. See history of the document for more details.


    2009-03-10:
    Small update of the macro reference file because of new command name UltraEditReOn instead of UnixReOff. The syntax highlighting wordfile and the tag list file on the server of UltraEdit, Inc. are also updated.


    2009-04-21:
    Small update of the macro reference file because of new command DelAllBookmarkLines and some other small changes. The syntax highlighting wordfile and the tag list file on the server of UltraEdit, Inc. are also updated. Furthermore there are some small changes in some comments in the macro source code file and the macros have been improved a little bit for correct adding a line termination at end of a file with feature auto indent enabled and last line of the file contains preceding whitespace.


    2009-07-19:
    Updated the macro reference file with the info about new remove duplicate parameters of the commands SortAsc and SortDes introduced with UE v15.10 and some other changes including a new bug info.


    2009-12-30:
    Updated the macro reference file with the info about the new commands DecodeBase64 and EncodeBase64 and some other small changes including a new bug info about a macro recorder bug on command SelectAll.


    2009-01-13:
    Removed a wrong hint at command SaveAs.


    2010-03-21:
    Updated the macro reference file with the commands CommentAdd, CommentRemove, CommentSelectionAdd, CommentSelectionRemove and DelAllHiddenLines, the FindInFiles and ReplInFiles parameter UseEncoding and other stuff related to changes in UltraEdit v16.00. See history in the macro reference file for details.


    2010-04-11:
    Improved the macro "Convert hhk/hhc" because the result HTML file for the index file looked different to the list on the Index tab. In other words the conversion to HTML was not really good for *.hhk files. And added some code to get correct HTML file if the input file contains also </li> after </object> and if all <ul> and <li> tags are at start of the line. Furthermore the previous macro version converted also backslashes in visible text to slashes instead of doing that only inside the URLs. This is also fixed.


    2011-10-16:
    Updated the macro reference file with information about new macro commands introduced with UE v17.20 and v17.30 and some other changes in this file. See history of the document for details.


    2012-09-11:
    Updated the macro reference file with information about new macro commands introduced with UE v18.20. See history of the document for details.


    2012-12-08:
    Updated the macro reference file with a more detailed description for command GotoBookMark and updated respectively corrected also the descriptions of the other 3 bookmark commands.

    206
    MasterMaster
    206

      Mar 31, 2007#2

      Mofi, you're a real treasure.
      Software For Metalworking
      http://closetolerancesoftware.com

      4
      NewbieNewbie
      4

        Apr 01, 2007#3

        Very nice, that's that, what I missed all the time, thanks :-)

        25
        Basic UserBasic User
        25

          Apr 09, 2007#4

          Bravo!!! Great references and tools! Danke!!! :D

          1
          NewbieNewbie
          1

            Jul 21, 2007#5

            Dude, you SO rock!!!

            The information in these files, even though I guarantee I don't totally understand it, has given me a start toward taking a process that I do four times a year, involving thousands of lines of text (schedule data for a Midwestern transit agency), which used to consume a week or more every time I did it, down to a matter of SECONDS (ten seconds to reformat an 8600-line tab-delimited text file into HTML table rows)!

            Once I master some of the looping constructs and get my regexes a little more refined, it'll be even better! I love community-supported software!

            I need to go read more about macros and regexes...

            2
            NewbieNewbie
            2

              Jan 04, 2008#6

              Mofi, in case you haven't heard it yet: You're a hero! Every time I come here I learn something new.

              I love the macro code files with the annotations. With one of your macros it's easy to go from code file to compiled macro, but is it also possible to do the reverse in batch? I'd love to "convert" my 80+ *.mac files into *.uem files and annotate them. At the moment I open each MAC file in the Macro-Edit window and copy the content into a new text window for annotation. I was wondering if this process could be automated. As far as I can see, it's not possible via another macro (no way to open the Macro-Edit dialog from within a macro), but there might be other ways (eg. Javascript - next on my list to be learned).

              Thanks a lot and a prosperous 2008 for all you helpful people.
              Cheers from Oz

              UE13.20a

              6,686585
              Grand MasterGrand Master
              6,686585

                Jan 05, 2008#7

                Sorry, no!
                There was a Visual Basic project by Dave Sisemore to create an alternative compiler/decompiler for UltraEdit macros which was able to decompile *.mac files to *.uem files (nearly with same syntax). But after a total loss of the sources and because of the JavaScript engine Dave has given up this project. I have used the beta of this alternative decompiler to decompile all my macro files and then commented them (this was a part of my beta tests). But the latest beta of this alternative macro compiler/decompiler is not able to decompile anymore the macro files of newer versions of UE because of several internal changes made by UltraEdit, Inc. as documented in my reference.

                The reference was originally designated as supplementary documentation for this alternative decompiler. After canceling this project I have continued the documentation, syntax highlighting wordfile, tag list file and macros I have had already written for this alternative macro compiler/decompiler like the macro "Copy Macro Code" and published it. During beta testing Dave and I have had also found several serious bugs and I have reported them all to UltraEdit, Inc. last year. As a result of this work the UltraEdit developers have fixed most of the known program mistakes and I'm quite sure that the minor problems will be also fixed in future releases.

                So there is no other method as the one you have described to convert already existing macro files to UEM files for re-indenting it and adding comments. I don't think there will be ever a tool which can decompile UltraEdit macros from any version of UE to a text file because it is really a hard work to write such a tool without having the UltraEdit macro sources.

                2
                NewbieNewbie
                2

                  Jan 08, 2008#8

                  Thanks Mofi for the info, sorry to hear it, but very much appreciated.
                  Cheers form Oz

                  1
                  NewbieNewbie
                  1

                    Feb 08, 2012#9

                    Thanks for reference. In my very old version of UE I had to try commands to understand what they do and sometimes when you need to find a solution it's so easier when you can read descriptions! Already found some ideas how to improve some of the macros I use. They all work, but seems like there can be easier solutions. Already got to use regular expressions which I somehow failed to understand before (found somewhere among your examples here on forum as well).

                    44
                    Basic UserBasic User
                    44

                      Jul 08, 2013#10

                      Hi Mofi,

                      Do you have a version of uemacro.uew that shows the macro names as functions?

                      I got as far as below, which works as a Perl regular expression find string, but wasn't working in the function list.

                      Code: Select all

                      ^.*[*]{5} (.*)[*]*$
                      Also, do you have a macro file of your own key utility macros you would care to share? :)

                      Marvellous tools you have here - I am about to start copying my own macros using your macro tools.

                      Rob :)

                      6,686585
                      Grand MasterGrand Master
                      6,686585

                        Jul 08, 2013#11

                        The function string in uemacro.uew  for the *.uem files which I have added to the ZIP archive would be:

                        Code: Select all

                        /Function String = "%// Macro "^(*^)""
                        That UltraEdit regular expression search string finds the macro names in the line comments near the macro code and list them in the function list view.

                        I don't know how you store the macro names in the text version of your macros. I have not added any function string to list the macro names in function list view to uemacro.uew as there is no general rule how to store macro names.

                        Your regular expression is a Perl regular expression search string. So you need in your copy of uemacro.uew the lines:

                        Code: Select all

                        /Regexp Type = Perl
                        /Function String = "^.*\*{5} (.+)\**$"
                        I have not so many key utility macros as you might think. The few small macros with an assigned hotkey which are of general usage are already published in topics with an appropriate title. My larger macros are very customized for my needs and are of no usage for other people.