ASPCompiler Compile Time Scripting (CTS)
ASP Compiler 1.1 documentation is under development. See also the examples.

The CTS is a powerful way to extend the compiler, generate sites from a DB or another sources of data, implement automatic and semi-automatic code generation helpers and many others.

It works during the first phase of the files processing - i.e. CTS takes place during the HTML/ASP preprocessing phase. It is applicable for HTML and ASP files and other files that resemble the HTML syntax. Limited processing can be done also for some other file types.

What is the goal? With CTS the compiler can be "taught" to perform programming tasks for you. In other words this a technique that enables the compiler to generate or modify code (ASP and HTML) in the compiled files. CTS is able to generate/modify HTML, ASP and other text as well. Thus its applications may vary from HTML generation to automatic or semi-automatic ASP code generation. The both can be mixed as appropriate.

Some possible applications:  

Suppose you have a DB driven WEB site with dynamic content. You could implement it in ASP, but this will need considerable server resources. If the visitors are many thousands or millions per day you will need an expensive server hardware, may be even cluster of servers and corresponding DB and WEB server software. It will be times cheaper if you could place on the server static HTML pages and regenerate them (or different parts of the site) when the information in the DB changes. In fact most dynamic sites did not change their content on every request or such change are related only to a limited number of elements on some pages (such as rotating advertisements). Then it is possible to use static HTML pages or at least very simple ASP pages (containing code only for the rotating advertisements for example)! ASP Compiler and compile time scripting will make this easy enough and the costs will be times lower. And you can do such thing step by step simplifying the online pages and moving the slowest tasks to the CTS in the compiler. 

Another example are code generation tasks. WEB projects often include common parts - common enough to make you wander if they cold be implemented as library and much enough to make the final page too big, including too many files. Repeating the boring tasks a few times is ok but repeating them every week with a little differences worth something better to be done. Then a developer could begin to write a CTS that generates part of the code - over a template or using some kind of algorithm and corresponding parameters. The CTS in ASP Compiler is designed to fit in these situations - you could begin with some simple embedded scripts (as simple as ASP programming)  to "see how it can be done this time", then move them in external files and finally extend them with GUI (configuration dialog and help) Take the simplest example - listing some data from a DB query. It is simple but if you could prepare a HTML as a template, after many boring conversations persuade the client to like it - it will be good to put the ASP code with minimal efforts in there. There is one example in ASPC package and much more could be done. Finally, we hope, ASP Compiler is a little step in the right direction - a way to teach the computer to do part of your work!  

The CTS in some aspects could be compared to such features like "project wizards" or "mail merge" (in MS Word) but it combines features of the both and is also a developer oriented technique. CTS is not for the final users of the applications - it is for the developers. With it frequently performed programming or site creation/management tasks can be automated. Probably the most important feature of the CTS are the different ways it can be used. For example the simplest CTS is an embedded script in a page (HTML or ASP) using the <SCRIPT RUNAT=Compiler> tag. But while this technique is quite good for the time you wander exactly how to automate the task or how to order your code that generates the page content, it can be replaced by something more extended when you are4 ready to pack the CTS you wrote for usage in another projects and by other developers. Thus the compile time scripts can be embedded, loaded from file in the project's directory or executed from the CTS global library. Therefore depending on the reusability and fields of application of a certain script you have appropriate opportunities. To do something that will be used only a few times or to do something that will be used many times and by many people. The CTS development could begin with a few lines embedded in the file and end with script equipped with configuration dialog and help page.

Already interested? Then you may begin with the following:

Note that almost the half of the events and objects are rarely needed. They are supplied to ensure the script will have access to any information it may need, but usually only a small part of the objects and events are required. Copyright 2001-2006 newObjects [ ]