Auto correct an existing file

Syntax highlighting, code folding, brace matching, code indenting, and function list

Auto correct an existing file

Postby OlyRob » Sun Jan 09, 2005 9:08 am

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.
User avatar
OlyRob
Newbie
 
Posts: 1
Joined: Sun Jan 09, 2005 12:00 am

Re: Auto correct an existing file

Postby Harry » Wed Jan 12, 2005 2:53 am

Good question, I have this problem as wel!

best regards, Harry
User avatar
Harry
Newbie
 
Posts: 3
Joined: Thu Oct 07, 2004 11:00 pm

Re: Auto correct an existing file

Postby mrainey56 » Wed Jan 12, 2005 5:29 am

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."
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: Auto correct an existing file

Postby adejones » Fri Feb 04, 2005 2:36 pm

I have been searching for something to do this for ages. I love watching macros eat code. This rocks big time :D
User avatar
adejones
Newbie
 
Posts: 1
Joined: Wed Jan 05, 2005 12:00 am

Re: Auto correct an existing file

Postby Hmsn » Wed Jun 01, 2005 8:11 pm

I've been toying 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 iteself to the end. If syntax highlighting and auto-correct are active then the T-SQL reserved words will adjusted accordingly:

GotoLine 1
Key HOME
Loop
" "
Key BACKSPACE
Key Ctrl+RIGHT ARROW
IfEof
ExitLoop
EndIf
EndLoop
Hmsn
 

Problem with the Macro

Postby regenpfeifer » Mon Jun 06, 2005 5:36 pm

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
Key HOME
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' :-)
regenpfeifer
 

Re: Auto correct an existing file

Postby Hmsn » Mon Jun 06, 2005 7:43 pm

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
Hmsn
 

Re: Auto correct an existing file

Postby regenpfeifer » Mon Jun 06, 2005 8:04 pm

Awsome, 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
regenpfeifer
 

Re: Auto correct an existing file

Postby Hmsn » Mon Jun 06, 2005 8:13 pm

Excellent! thanks for the suggestions.

Paul.
Perth, Western Australia.
Hmsn
 

Re: Auto correct an existing file

Postby chrisgin » Fri Aug 18, 2006 1:35 am

Does anyone have a macro/script to autocorrect all files in a given folder?
User avatar
chrisgin
Newbie
 
Posts: 1
Joined: Thu Jul 13, 2006 11:00 pm

Re: Auto correct an existing file

Postby dyslexic_dba » Tue Oct 10, 2006 12:28 am

This is great... Thanks! :)
User avatar
dyslexic_dba
Newbie
 
Posts: 2
Joined: Sun Oct 08, 2006 11:00 pm


Return to Syntax Highlighting