dynamically created macro file?

dynamically created macro file?

3
NewbieNewbie
3

    Sep 08, 2005#1

    i'm trying to do something difficult - so i'll try to be as descriptive as possible.

    i have the perl interpreter on my system and frequently use a perl script i authored called grep.pl. as you might guess the script will search through the files on my hard drive looking for text then outputs a list of files that matched including the lines that matched. i've added an option to my script that causes the script to open the matching files in my favorite text editer - UE. to accomplish this the script just basically passes the shell something like this: uedit32 "c:\machingfile.txt". i've had this working for a while. 8)

    next i thought, :idea: how cool would it be if i could automatically cause the matching lines to get bookmarked. sooo i've added some functionality in the script that edits a macro template file i've created (a text file) that contains this code...:

    Code: Select all

    InsertMode
    ColumnModeOff
    HexOff
    UnixReOn
    Loop
    Find MatchCase RegExp <SEARCHEXP>
    IfFound
    ToggleBookmark
    EndIf
    IfNotFound
    ExitLoop
    EndIf
    EndLoop
    GotoLine 1
    
    ...and replaces "<SEARCHEXP>" with whatever my script was searching for - perhaps all uses of the function "LoadFromFile". then the script saves the file with the changes with a new name, perhaps "newmac.mac" and passes this to the shell: uedit32 "c:\machingfile.txt" "/M:c:\newmac.mac". but lo and behold that doesn't work. :cry: after researching & playing around a bit - apparently the macro has to be saved from within the UE environment so it can get converted to the binary format i've discovered UE uses for macros.

    is there any way to do this? :?: can i somehow invoke UE with a cmd line instructing it to load a text file as a macro then save it....then re-invoke it with the cmd line above? any ideas would be helpful - thanks in advance.

    of course, any questions about this that might shed some light on something i've left out - don't hesitate to ask, i'll check back often and further describe whatever it is.

    --neb

    74
    Advanced UserAdvanced User
    74

      Sep 08, 2005#2

      I'm in a similar situation. I have a macro which contains 3500 lines, but UE won't let me paste the whole thing in the macro GUI. So I have it saved as a text file and would like to convert it to a macro file. But don't know if this is possible.

      Thanks, Max

      206
      MasterMaster
      206

        Sep 08, 2005#3

        Max,

        Can you break your huge macro into smaller pieces and use PlayMacro to call them as "subroutines"?
        Software For Metalworking
        http://closetolerancesoftware.com

        74
        Advanced UserAdvanced User
        74

          Sep 09, 2005#4

          That's what I'm doing now. But I'm trying to figure out if there is a way to break up the file on it's own and save them as individual macros.


          InsertMode
          ColumnModeOff
          HexOff
          UnixReOn
          Top
          GotoLine 500
          IfNotFound
          SelectToTop
          Cut
          NewFile
          Paste
          ClearClipboard


          Good to hear from you again. <smiles>Max

          6,610550
          Grand MasterGrand Master
          6,610550

            Sep 09, 2005#5

            To nebbish:
            You only have a single search string. So if possible, let perl copy the search string to windows clipboard and use following macro command:

            Find MatchCase RegExp "^c"

            This works also for regular expression strings. UltraEdit will not interpret the string on the clipboard as normal text, it is really interpreting it as regular expression string. In your case, this is good, but that was a problem for me 2 days ago.

            I have developed 3 macros which uses ^s (selected string) and ^c (clipboard content) in regular expression searches and UltraEdit also interpreted the special regular expression characters of the normal text, which was selected or copied to clipboard according the regular expression syntax.
            I was forced to write the searches with ^s and ^c without regular expression, which forced me to develop extra search and replaces before and after the ^s and ^c search and replaces to get the same result as a single regular expression search and replace would do, if the ^s and ^c strings in a regular expression search would be interpreted as normal text.

            If you have more than one search string, write the strings to an additional file with known and fixed file path/name and modify the macro code to load this information from this additional file dynamically. It's also possible to copy all needed dynamic information to clipboard and let the macro paste it to a new file, created by the macro itself. At end of the macro execution, the macro closes the new file without Save.
            Best regards from an UC/UE/UES for Windows user from Austria

            3
            NewbieNewbie
            3

              Sep 09, 2005#6

              thank you Mofi for the reply.

              i've experimented with the ideas you present and found some success - but not quite all i was hoping for.

              i've figured out how to manipulate the clipboard from perl and use the ^c from my UE macro.

              ...however...

              using the ^c code doesn't seem to work when unix style regular expressions is turned on. perl uses a unix style syntax for regex's (of course) - a style i am most familiar with.

              at this point the only way i can think of to make this work would be to add a translater into my perl script that would convert the regex it used into a UE style regex - that would take some time but i just might do it. :?

              --neb

              6,610550
              Grand MasterGrand Master
              6,610550

                Sep 11, 2005#7

                Wow, you are right!

                The regular expression string on the clipboard is only interpreted as regular expression for find with ^c if UltraEdit style is set. If Unix style is activated, the string on the clipboard is always interpreted as normal string even for regular expression finds. That's an inconsistent implementation of regular expression syntax and interpretation. I will inform IDM about that and ask why this is handled different.

                I personally always use UltraEdit style for regular expressions so I never noticed, that there is a different. I could have saved a lot of time on developing of my 3 macros if I had known about that different regular expression handling on ^c strings a few days ago.

                However this situation is now bad for you. At the moment (UltraEdit v11.10b) you are really forced to translate the unix style regular expressions to UltraEdit style with Perl before copying to clipboard to also use the expression in the UltraEdit macro. That's really a little shit.

                  Sep 16, 2005#8

                  While writing an example for IDM support I noticed that ^c and ^s are simply not working in a regular expression search with Unix style.

                  This is already mentioned in the help of UltraEdit at bottom of the regular expression help page.

                  So the difference is that UltraEdit supports ^c and ^s in an UltraEdit style regular expression find whereelse they are not supported in an Unix regular expression find. Sorry for my mistake!
                  Best regards from an UC/UE/UES for Windows user from Austria