When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sections:
Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
XML Info
Information:
Feedback
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Published: Monday, March 13, 2000

Building a Script Beautifier


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.)

- continued -

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 Web page.

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!

Happy Programming!


  • Download the source code in text format
  • Try out the demo!


  • ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article