ALP ASP-like scripts page structure
Pages contain textual information. ASP-like scripts are applicable for HTML, plain text and any other format that is represented textually. By default ScriptGen assumes that pages are HTML and sets default content type to text/html (see Response.ContentType property).

Contents of this page:

The elements of the ASP page

Within the page code embeddings can be placed. The embeddings can be of these types:

Script code in <% %> tags

There are two script embedding tags <% %> and <%= %>.

  • <% %> There is no requirement about tags placement. The important rules are

    - No nesting is allowed
    - Every opening tag <% must have corresponding closing tag %>
    - Tags cannot be mixed with other tag types i.e. Directives and File include
    - Tags must not break unbreakable script language constructions.

<% %> contain script code not HTML or other text that will not complain the corresponding script language syntax. The content of the <% %> tags is executed "as is" without modification.

  • <%= %> Are modification of the <% %> tags dedicated to help for creation of the output constructions. Content of the <%= %> tag is translated to an output statement using the current scripting language.

Here is one example:

<%
  For I = 1 To 7
    %>
        <FONT SIZE="<%= I %>">Hello world (font size=<%= I %>)</FONT><BR>
    <%
  Next
%>

The example will output 7 lines of text with growing font size.

In VBScript <%= x %> construction is equivalent of the <% Response.Write x %> and in the JScript to <% Response.Write(x) %>.

The entire page and it include files can contain only script written in one script language. Mixing of the script languages is not permitted.

One helpful configuration setting is (int)ViewSource. Value of 2 instructs ScriptGen to show the resulting source of the page and error line is colored in red.

Script code in <SCRIPT RUNAT=SERVER ... > tags 

These tags play a role very similar to the <% %> tags but allows the developer put also code in scripting language different then the default scripting language of the page. The syntax is:

<SCRIPT RUNAT="SERVER" LANGUAGE="languagename" ID="idname">
... script code ...
... script code ...
</SCRIPT>

The rules are the same as for the <% %> tags (see above). The parameters are as follows:
RUNAT=SERVER is required for it gives the ALP ability to distinguish these scripts from the client side scripts.
LANGUAGE="languagename" is required. The languagename must specify the key name of the language in which the script in the tag is written. For example it can be VBScript or JScript.
ID="idname" is optional. It may help you find an error when developing the application. It is listed with the error text when an error occurs in your script.

The scripts in RUNAT=SERVER tags may output only by using Response.Write/BinaryWrite. They cannot use <%= %> or another similar technique.

See also the order of execution below.

Directives

The general syntax of the directives is:

<% @Language=JScript %>
or
<% @Language="JScript" %>

The above example line must present in the beginning of the page - on the first line. Another requirement is that <% %> tags containing a directive are not be mixed with a script code:

<% @Language=JScript
var i =5;
%>

is illegal! Correct syntax will be:

<% @Language=JScript %>
<%
  var i =5;
%>

When you need to put more than one directive you put them comma separated - for example:

<% @Language="JScript", CODEPAGE=1252, EXECUTEORDER=REVERSE %>

The directive names are not case sensitive as their values. However you should tend to specify the values with the correct case in order to avoid any future incompatibilities.

The supported directives:

Language directive tells to the ScriptGen what scripting language is used in the page by default (in all the <% %> tags. If the directive is not present default language is used see configuration setting (string)DefaultLanguage. The factory default states VBScript as default language.

CODEPAGE specifies the code page used by ALP to read the from the file (and any include files referred in it). This concerns the literal strings and the HTML source as well. While often this seems to be not so important it is recommended to set the directive. For the list of the code page codes you can search the Internet or MSDN or also look in the ActiveX Pack1 constants for some of the most popular ones. By default the code page used is the machine's code page as set in the regional settings. In general all the European languages may do without need to specify this option, but for far-east and other multibyte character sets it is vital to specify the correct code page here.

EXECUTEORDER is ALP specific directive that allows you to reverse the order in which the scripts written in different languages are executed. The values allowed are REVERSE and NORMAL (in fact any other value then REVERSE will set normal execution order but you should use the keyword NORMAL to avoid incompatibilities with future extensions). If omitted the order is normal (see the execution order below).

File includes

File include statement uses the HTML comment syntax but can be used in other textual documents without a problem (for example in plain text or RTF documents). Samples:

<!-- #include virtual="/includes/file.inc" -->
<!-- #include file="addons/file.inc" -->

If the first word in the <!-- --> HTML comment statement is #include comment parser used by the ScriptGen marks the comment statement as an include directive and searches for named values - pairs: name="string". Two keywords are recognized:

  • virtual - the value given is a file path relative to the root of the current site. Must begin with "/"
  • file - the value given is a relative path. The path is relative to the location of the file in which it was found.

The include file must be ASP-like script too. Include directives must be placed outside any <% %> or <%= %> tags. Include file should not contain @ directives. For wider compatibility there must be spaces between the after the comment open and before the comment close tags and the text of the directive in them. 

<OBJECT RUNAT=SERVER .. > tags

Creates an object and and makes it available to the page under the ID specified. The attributes supported are:

<OBJECT
  RUNAT=SERVER
  PROGID="programID"
  CLASSID="classID"
  ID="name"
></OBJECT>

RUNAT=SERVER is required. If not specified the object will be skipped and ALP will leave the element "as is" for further processing by IE.

PROGID or CLASSID - Only one of the both must be specified. If PROGID is used you need to specify the program ID for the object, and if CLASSID is used you must specify the ClassID - {xxxx-....} for the object (autorun applications should use ClassIDs).

ID="name" specifies a variable name for the object. It is then accessible for the page under this name. This parameter is required (for without it the object would remain unaccessible).

Remarks: Unlike the global.asa file in the regular ASP pages there is no SCOPE parameter. The objects created with this tag in regular ASP pages are available only to the page where they were created. Their lifetime matches the page lifetime.

The execution order

For developer convenience ALP matches the IIS execution order by default. However ALP allows a bit more control over it then the classic ASP. In classic ASP the script written in the default script language for the page (i.e. the language assumed for the <% %> tags) is executed first and just then the scripts/parts written in other (foreign) languages in <SCRIPT RUNAT=SERVER ..> drectives. This is a kind of de-facto standard, but obviously it is not convenient for all the pages. For example it allows a page that uses VBScript as default language to include JScript fragments that refer to some routines defined in the VBScript part but not reverse. As the <% %> and <%= %> tage are more convenient for the applied part of the work this seems a bit unusable. So, ALP supports the EXECUTEORDER directive (see above) that allows you to reverse the order and execute first the "foreign" script language parts and just then the main script in the page which seems to be more useful. However this means such a page will not be compatible with IIS any more and you should consider the advantages and the disadvantages of using the feature.

Further the above means that any <SCRIPT RUNAT=SERVER  ... > tags that specify language different from the default page language will execute after the entire page! Which means that any output in them will fall after all the other output made by the default script in the page. This is so in IIS too.

If your page contains <OBJECT RUNAT=SERVER ... > they are resolved before any script is executed. So, by using them you have the objects specified there created from the very beginning of the page execution. As like the objects created through the Server.CreateObject method the objects created with the <OBJECT RUNAT=SERVER ... > tags are allowed to access the ASP objects directly if they support OnStartPage method (event). 

The included files are just textually included in the place where the directive is found. So they do not change anything in the execution order.

 

newObjects Copyright newObjects 2001-2004