This article demonstrates how to build a script beautifier, and was the winning solution for the "ASP Connections Free Pass" Programming Challenge. There were several submitals for each of the five programming challenges, and thanks to all who submitted a solution! (All of those who submitted a correct solution were entered into raffle, and Misty's name was drawn out of the several who submitted correct solutions.)
This ASP code serves as a script beautifier - that is, it accepts a relative URL through
the querystring and, using the
FileSystemObject, grabs the contents of the
file. Then, a nice color coding is applied to the file's contents, and the contents
are outputted. Such a script beautifier is good for showing ASP script through a
One thing that Misty doesn't address in her script is security. If you provided a script beautifier that displayed the code for a given ASP page, then, theoretically, a visitor could view the ASP source for any ASP page on your site. A good approach would be to create a directory that contained only ASP pages that you didn't mind the user seeing. Then, in the script beautifier code, you could check to make sure that only scripts that existed in that directory were displayed.
The script is too long to show in the article, so you'll have to check out the entire source here.
There is also a demo available. The demo displays
the source code for
Sunrise.asp, a script that calculates the sunrise and
sunset times for a given latitude and longitude. You can read more about how to accomplish
this at the article
Determining the Sunrise and Sunset for a Particular Location.
Congratulations Misty, and thank you for all who entered!