Auto correct an existing file

Auto correct an existing file

1
NewbieNewbie
1

    Jan 09, 2005#1

    I have a number of existing files containing lower case Transact-SQL that I would like to open and have UE capitalize the keywords. I have the SQL language in my wordfile, and the keywords are capitalized in there. UE will highlight and capitalize the keywords if I re-type them, but how do I get it to do this globally to pre-existing code? Thanks.

    3
    NewbieNewbie
    3

      Jan 12, 2005#2

      Good question, I have this problem as wel!

      best regards, Harry

      206
      MasterMaster
      206

        Jan 12, 2005#3

        I'm going to post a solution created by another user, whose name I can't locate. I remember seeing feedback from users who liked it, and I tried it myself this morning. It appeared to work. Thanks to whoever it was.


        "Here is how I do it using UltraEdit-32:

        1. Open the file with syntax highlighting and auto-correction enabled

        2. Make sure the cursor is positioned at the beginning of the file

        3. Record a macro by hitting the following sequence of keys, MAKING NO MISTAKES!!!

        Ctrl+Shift+R
        Ctrl+<RIGHT ARROW KEY>
        <LEFT ARROW KEY>
        <SPACE>
        <BACKSPACE>
        Ctrl+<RIGHT ARROW KEY>
        Ctrl+Shift+R

        4. BACK UP THE FILE!!!

        5. Note the number of characters in the file

        6. Hit Ctrl+L

        7. Check the box that says "Play macro to End of File"

        8. Click the OK button

        9. Try not to freak out as UltraEdit-32 seems to eat large chunks of your program source. Aparently the display routine can't quite keep up with the macro processor

        10. Scroll 1 line, the source code re-appears. The character count should be the same before and after running the macro

        Good luck."
        Software For Metalworking
        http://closetolerancesoftware.com

        1
        NewbieNewbie
        1

          Feb 04, 2005#4

          I have been searching for something to do this for ages. I love watching macros eat code. This rocks big time :D

          Hmsn
          Hmsn

            Jun 02, 2005#5

            I've been playing with a solution for a while, heres' a macro you can simply run which will position the cursor at the top of the file and play itself to the end. If syntax highlighting and auto-correct are active then the T-SQL reserved words will adjusted accordingly:

            Code: Select all

            Top
            Loop 
            " "
            Key BACKSPACE
            Key Ctrl+RIGHT ARROW
            IfEof
            ExitLoop
            EndIf
            EndLoop

            regenpfeifer
            regenpfeifer

              Re: Auto correct an existing file - problem with the macro

              Jun 06, 2005#6

              I tried the macro and it mostly worked, but there is a case where it fails.

              Code: Select all

              SELECT ext_num, GROUP_id, me.media_buy_sheets_id AS media_buy_sheets_id
              FROM media_ext_groups2 meg,  media_entries2 me
              WHERE meg.group_id = me.media_ext_groups_id
              In this case, it capitalized group_id where it shouldn't have.

              Here is a fix I made:

              Code: Select all

              Top
              Loop 
              " "
              Key BACKSPACE
              Loop 
              Key Ctrl+RIGHT ARROW
              IfCharIs "_"
              Copy
              Else
              ExitLoop
              EndIf
              IfEof
              ExitLoop
              EndIf
              EndLoop
              IfEof
              ExitLoop
              EndIf
              EndLoop
              -Supergibbs

              PS: I don't know much about macro writing so there is probably a nicer way to write this, maybe without using 'copy' as a 'noop' :-)

              Hmsn
              Hmsn

                Jun 07, 2005#7

                hmmm, that got me thinking so I tried replacing the space (" ") with a different character, an underscore did the trick :wink:

                Code: Select all

                InsertMode
                ColumnModeOff
                HexOff
                UnixReOff
                GotoLine 1
                Key HOME
                Loop 
                "_"
                Key BACKSPACE
                Key Ctrl+RIGHT ARROW
                IfEof
                ExitLoop
                EndIf
                EndLoop

                regenpfeifer
                regenpfeifer

                  Jun 07, 2005#8

                  Awesome, that's a lot better, here is one more minor cleanup (ColumnModeOff, UnixReOff don't matter and HexOff is very unlikely needed, plus Top does GotoLine 1; Key HOME)

                  Code: Select all

                  InsertMode 
                  Top
                  Loop 
                  "_"
                  Key BACKSPACE
                  Key Ctrl+RIGHT ARROW
                  IfEof
                  ExitLoop
                  EndIf
                  EndLoop
                  -Jesse

                  Hmsn
                  Hmsn

                    Jun 07, 2005#9

                    Excellent! thanks for the suggestions.

                    Paul.
                    Perth, Western Australia.

                    2

                      Oct 10, 2006#10

                      This is great... Thanks! :)