A while back I posted a quick function in one of the threads in answer to a request for help. By hand, I highlighted the syntax of the code so that it was easily readable. Maybe you've had a similar experience.
I then searched for a utility that would do this automatically. When I couldn't find one, I wrote one (in AMS). This file, AMS Code Pretty, is my donation to the AMS community. It was put together over the last four days in my spare time (about 20 hours).
Once the lexer engine was coded, it was a small step to also provide a functionality to convert AMS/LUA code to HTML. The program does this as well, plus more.
The following is a sample output. Notice the line numbers; this is one of several user-definable features.
The download installs and starts it for you. I'm interested to know if anyone else finds this utility useful. Questions, comments, and suggestions are welcome.
AMS_Code_Pretty_1.0.3_Install.exe
I then searched for a utility that would do this automatically. When I couldn't find one, I wrote one (in AMS). This file, AMS Code Pretty, is my donation to the AMS community. It was put together over the last four days in my spare time (about 20 hours).
Once the lexer engine was coded, it was a small step to also provide a functionality to convert AMS/LUA code to HTML. The program does this as well, plus more.
The following is a sample output. Notice the line numbers; this is one of several user-definable features.
Code:
01 02 [b][COLOR='#0000FF']function[/COLOR][/b] appPathOriginal[COLOR='#FF0000']([/COLOR][COLOR='#FF0000'])[/COLOR] 03 [i][COLOR='#008000'] -- returns the original EXE's path ONLY (with trailing \)[/COLOR][/i] 04 [i][COLOR='#008000'] -- this is useful for compressed single-file apps run from a CD[/COLOR][/i] 05 [i][COLOR='#008000'] -- but, it also works with folder-based apps[/COLOR][/i] 06 07 [b][COLOR='#0000FF']local[/COLOR][/b] cdPath [COLOR='#FF0000']=[/COLOR] [COLOR='#800080']""[/COLOR]; 08 [b][COLOR='#0000FF']local[/COLOR][/b] findMarker [COLOR='#FF0000']=[/COLOR] [COLOR='#800080']"SFXSOURCE:"[/COLOR]; 09 [b][COLOR='#0000FF']local[/COLOR][/b] cmdArgs [COLOR='#FF0000']=[/COLOR] [COLOR='#800080']""[/COLOR]; 10 11 [b][COLOR='#0000FF']if[/COLOR][/b] [COLOR='#FF0000']([/COLOR]Table[COLOR='#FF0000'].[/COLOR]Count[COLOR='#FF0000']([/COLOR]_CommandLineArgs[COLOR='#FF0000'])[/COLOR] [COLOR='#FF0000']>[/COLOR] 0[COLOR='#FF0000'])[/COLOR] [b][COLOR='#0000FF']then[/COLOR][/b] 12 [b][COLOR='#0000FF']for[/COLOR][/b] i [COLOR='#FF0000']=[/COLOR] 1[COLOR='#FF0000'],[/COLOR] Table[COLOR='#FF0000'].[/COLOR]Count[COLOR='#FF0000']([/COLOR]_CommandLineArgs[COLOR='#FF0000'])[/COLOR] [b][COLOR='#0000FF']do[/COLOR][/b] 13 [b][COLOR='#0000FF']if[/COLOR][/b] [COLOR='#FF0000']([/COLOR]String[COLOR='#FF0000'].[/COLOR]Find[COLOR='#FF0000']([/COLOR]_CommandLineArgs[COLOR='#FF0000'][[/COLOR]i[COLOR='#FF0000']][/COLOR][COLOR='#FF0000'],[/COLOR] findMarker[COLOR='#FF0000'])[/COLOR] [COLOR='#FF0000']>[/COLOR] 0[COLOR='#FF0000'])[/COLOR] [b][COLOR='#0000FF']then[/COLOR][/b] 14 cmdArgs [COLOR='#FF0000']=[/COLOR] _CommandLineArgs[COLOR='#FF0000'][[/COLOR]i[COLOR='#FF0000']][/COLOR]; 15 break; 16 [b][COLOR='#0000FF']end[/COLOR][/b] 17 [b][COLOR='#0000FF']end[/COLOR][/b] 18 [b][COLOR='#0000FF']end[/COLOR][/b] 19 20 [b][COLOR='#0000FF']if[/COLOR][/b] [COLOR='#FF0000']([/COLOR]cmdArgs [COLOR='#FF0000']~[/COLOR][COLOR='#FF0000']=[/COLOR] [COLOR='#800080']""[/COLOR][COLOR='#FF0000'])[/COLOR] [b][COLOR='#0000FF']then[/COLOR][/b] 21 [b][COLOR='#0000FF']if[/COLOR][/b] [COLOR='#FF0000']([/COLOR]String[COLOR='#FF0000'].[/COLOR]Find[COLOR='#FF0000']([/COLOR]cmdArgs[COLOR='#FF0000'],[/COLOR] findMarker[COLOR='#FF0000'])[/COLOR] [COLOR='#FF0000']=[/COLOR][COLOR='#FF0000']=[/COLOR] 1[COLOR='#FF0000'])[/COLOR] [b][COLOR='#0000FF']then[/COLOR][/b] 22 [b][COLOR='#0000FF']local[/COLOR][/b] fullPath [COLOR='#FF0000']=[/COLOR] String[COLOR='#FF0000'].[/COLOR]Replace[COLOR='#FF0000']([/COLOR]cmdArgs[COLOR='#FF0000'],[/COLOR] findMarker[COLOR='#FF0000'],[/COLOR] [COLOR='#800080']""[/COLOR][COLOR='#FF0000'],[/COLOR] true[COLOR='#FF0000'])[/COLOR]; 23 [b][COLOR='#0000FF']local[/COLOR][/b] tblFullPath [COLOR='#FF0000']=[/COLOR] String[COLOR='#FF0000'].[/COLOR]SplitPath[COLOR='#FF0000']([/COLOR]fullPath[COLOR='#FF0000'])[/COLOR]; 24 cd_Path [COLOR='#FF0000']=[/COLOR] tblFullPath[COLOR='#FF0000'].[/COLOR]Drive [COLOR='#FF0000'].[/COLOR][COLOR='#FF0000'].[/COLOR] tblFullPath[COLOR='#FF0000'].[/COLOR]Folder; 25 [b][COLOR='#0000FF']end[/COLOR][/b] 26 [b][COLOR='#0000FF']else[/COLOR][/b] 27 cd_Path [COLOR='#FF0000']=[/COLOR] _SourceFolder [COLOR='#FF0000'].[/COLOR][COLOR='#FF0000'].[/COLOR] [COLOR='#800080']"\\";"[/COLOR] 28 [b][COLOR='#0000FF']end[/COLOR][/b] 29 [b][COLOR='#0000FF']return[/COLOR][/b] cd_Path; 30 [b][COLOR='#0000FF']end[/COLOR][/b] 31
The download installs and starts it for you. I'm interested to know if anyone else finds this utility useful. Questions, comments, and suggestions are welcome.
AMS_Code_Pretty_1.0.3_Install.exe
Comment