|
APG Scripts |
|
See Also: |
APG scripts are text files, consisting of blocks of content and script. By default, they use a .APG extension, though any extension can be used. For example, you may wish to use the .inc extension to denote an APG include file. However, only APG scripts with a .APG extension can be run by double-clicking the script in Microsoft Windows Explorer.
APG Script files can be ANSI text files or Unicode text files.
An important rule for writing APG scripts is:
The output path should be set before any content is generated.
This rule has some exceptions, and requires a more thorough explanation. To read more about this rule, see When to Open the Output Stream.
Other miscellaneous guidelines for writing APG scripts:
Script blocks are surrounded by <%#... #%> brackets. Content blocks are blocks of content outside of these brackets. Content blocks are sent directly to the output file. For more information, see APG Script Brackets.
<%# = <expression> #%>can be used to send the results of an expression to the output file. For more information, see APG Output Expression .
<!-- #include apg = "includefile.apg" --> is the syntax used to include a file. The included file can contain script blocks (which are executed), and it can contain content blocks, which are sent directly to the output file. For more information, see Include Files . For information on other APG script Tags and directives, see APG Script Syntax Reference.
For more information on writing script blocks, see the Microsoft documentation on VBScript and JScript. Active Page Generator uses Microsoft Active Scripting technology, so the Microsoft documentation is the official script language reference. The Active Page Generator documentation covers APGen-specific features, but does not cover VBScript and JScript syntax.
For more information on debugging APG scripts, see Debugging APG Scripts. For more information on using the debugger, see the NT Option Pack Script Debugger documentation, or the Visual InterDev 98 documentation.
The APG Output object is similar to the ASP Response object. Output.Write corresponds to Response.Write. For more information on the APG Output object, see The Output Object. For more information on the similarities and differences between ASP and APG, see Comparison of ASP to APG.
A procedure named Main() can be placed within an APG script. If this procedure exists within an APG script, it will be called after all global-scope code (code not contained by any functions or procedures) is executed. Only one Main() procedure can exist in an APG script and all of its included files. For languages such as JScript that are case-sensitive, the Main() procedure should start with a capital M.