related sites: <FREE Help> <ASP> <Asp.net> <worldwide> feedback: <lovethat> <hatethat> <thanks> <credits> <contact us>
The Organization Library <Next>
Showing Source Code in our Tutorials
We provide lots of sample code that people can press a button and run. We deliberately did not want to put code in .ZIP files where it could not be proven that they work (typoes might creep in) or cut and paste them into pages and introduce typos.
<%call showASPcode("whataver.asp")
We pretty print code by opening the file running on our server so you are ensured the code works before pasting it into your application. Seems simple enough... Some complex issues to solve creeped up.
Obstacle #1: Some code (like a library or include file) need to be displayed but don't need run-me buttons.
Obstacle #2: Some code only makes sense if invoked from a form. Displaying it is ok, but makin a run-me button would be useless as a form must be run to "feed it" the inputs.
Obstacle #3: Some code may need to be invoked with a GET, i.e. whatever.asp?state=md&city=Rockville or whatever.asp?state=tx&city=Dallas or they won't work.
Obstacle #4: If the user is printing the page, the "run-me" buttons do not need to be there. However, line numbers do need to be there. All the pages can at the press of a button, be formatted for printing.
Obstacle #5: CLS files from Visual Basic cannot be printed as-is yet we wanted to list source code for components. CLS files have several lines in the ASCII file that never appear on a VB programmers screen.
We solved these all. How? A lot of ways:
The learnlib.asp (source on the next page) is quite complex and actually includes some code that was submitted by a site reader Paul Rigor to replaced my source printing code that worked ok, but had some really annoying flaws. Paul donated source printing code that replaced my code that worked (albeit with some annoying glitches of it's own.)