Help with macros - change syntax highlighting

Help with macros - change syntax highlighting

6
NewbieNewbie
6

    Jun 08, 2006#1

    Hi,

    I haven't started using macros yet but want to ask if i can do the following and any pointers would be appreciated.

    I would like to search through a file(s) to find (all) function names as identified by eg 'def FUNCTIONNAME {' then append or edit the wordfile such that these function(name)s are highlighted in other files.

    Thanks,

    Cheers,

    pete

    6,675585
    Grand MasterGrand Master
    6,675585

      Jun 08, 2006#2

      This should be no problem. First you need my macro file from the ultimate word definitions sorting macro. Load this macro file and add the following macro to this macro file with name "AddFunctions" for example. AddFunctions needs also macro property Continue if a Find with Replace not found set and disable also the Cancel dialog for your macro.

      The code for your macro follows. It contains 2 colored strings which you have to adapt to your environment.

      The macro first collects in clipboard 9 all function strings in the current file.
      Then it pastes it to a new file and if this new file contains really characters (functions found), it's content is reformatted with a single regex replace to get 1 function name per line. This list of function names is again copied to clipboard 9 and the new file is closed without saving.

      Next your wordfile is opened and with a single Find the cursor is set to the color group of your functions. The name of this color group should be unique in your wordfile or you have to use more finds to get to correct position. Below this line the function names are inserted into the wordfile.

      The real hard work is done by my macro SortLanguage set. Last your macro has only to save the wordfile and close it. SortLanguage has restored already the standard editing environment (clipboard 9 cleared, switch to Windows clipboard, ...).

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      Top
      Clipboard 9
      ClearClipboard
      Loop
      Find RegExp "def[ ^t]+*[ ^t]+{"
      IfFound
      CopyAppend
      Else
      ExitLoop
      EndIf
      EndLoop
      NewFile
      UnicodeToASCII
      UnixMacToDos
      Paste
      IfColNum 1
      ClearClipboard
      Clipboard 0
      ExitMacro
      EndIf
      Find RegExp "def[ ^t]+^(*^)[ ^t]+{"
      Replace All "^1^p"
      SelectAll
      Cut
      CloseFile NoSave
      Open "Name of your wordfile with full path"
      Find "/C7"My Functions""
      EndSelect
      Key HOME
      Key DOWN ARROW
      Paste
      Key UP ARROW
      PlayMacro 1 "SortLanguage"
      CloseFile Save

      Add UnixReOn or PerlReOn (v12+ of UE) at the end of the macro and before the single ExitMacro command if you do not use UltraEdit style regular expressions by default - see search configuration. Macro command UnixReOff sets the regular expression option to UltraEdit style.

      Hope this macro really works because I have not tested it. I have written it directly here in the forum edit box.

      If you are brave and have time you can adapt this macro and replace the macro SortLanguage call by selecting all words of the color group of your functions only and use the appropriate code sequences from my macro set to sort only the words in this color group. This would speed up the execution of your macro.
      Best regards from an UC/UE/UES for Windows user from Austria

      6
      NewbieNewbie
      6

        Jun 10, 2006#3

        Hi Mofi,

        many thanks!

        It'll take me a few days to get to grips with UltraEdit & macros but in the meantime I appreciate the 'jump start'.

        Cheers,

        Pete