PowerWeb Macros
 

No CGI Required! - Works with ALL Web Browsers!
PowerWeb Server++ Macros let you create dynamic documents with unprecedented ease and power, without having to program in CGI or any other complex programming language. PowerWeb Macros are an extension to the HTML tags, and work with all Web browsers.

Table of Contents

Introduction
WebMacro Syntax
WebMacro Reference Append Appends text to an existing variable.
Begin Tells the browser that HTML3 will be used.
Call Executes a WebScript embedded within HTML.
Comment Strips comment away before sending to client.
Concat Concatenates the contents of several PowerWeb variables.
Config Customises error messages and date and number formatting.
Copyright Outputs the PowerWeb copyright notice.
Counter Outputs a page access counter.
Create Creates a new PowerWeb variable.
Database Rapid Development of HTML Database Applications.
Destroy Destroys an existing PowerWeb variable.
Dir Display an FTP-like directory listing.
DirectoryMap Displays a Map of the Public Directories of your Site.
Echo Outputs form parameters, the contents of CGI variables, PowerWeb configuration settings, or runtime variables.
Elif Implements the next condition in the equivalent of a C language switch...case command.
Else Outputs the block if the condition in the If command was FALSE.
End Closes off the HTML body and document.
Endif or /if Defines the ending point of an If/Else/Endif conditional block.
EndScript or /Script Defines the ending point of a Script definition.
Exec Executes an API, Perl, Rexx, or CGI script or an operating system program.
Fetch Fetches the contents of an external HTTP Document or File.
FSize Outputs the size of a file.
FLastMod Outputs the date and time of last modification of a file.
If Defines the start of a conditional block.
Include Include another file into the current document.
Input Displays a populated input field.
List Displays a table suitable for editing a list of items.
Loop Iterates over a series of values or WebObjects.
Redirect Redirect the client's browser to another URL.
Script Defines an embedded WebScript using InSide HTML technology.
Set Defines a new value for a variable.
Split Splits the contents of a single PowerWeb variable into its components.
Table Displays a table suitable for editing multiple records and fields.

Introduction

PowerWeb Macros allow the HTML document author to create dynamic documents that closely integrate with the PowerWeb++ server, without coding in CGI.

PowerWeb Server++ Macros have access to the PowerWeb Server++ internals that manage requests, connections, services, configuration and performance information, across all protocols, not just HTTP.

This level of power and richness of functionality cannot be found on any other Web server today.

An excellent set of examples of how to use PowerWeb Macros can be found in the \powerweb\system\install and \powerweb\system\admin directories on your server. Look at \powerweb\system\admin\ResWiz.htm in particular for how many PowerWeb Macros can be used in conjunction with one another, while powerfully exploiting the PowerWeb Variable interface to the server's configuration.

PowerWeb Server++ Macros can:

Serve Different Documents According to the Client's Browser or Host Name

Validate Form Data Entry Without Writing CGI Programs

Process Forms Without Writing CGI Programs

Use Document Templates to Simplify Document Creation

Can Boldly Take You Where No-one Has Been Before!


PowerWeb Server++ Macro Syntax

The syntax of PowerWeb Macros is based on the familiar HTML tag syntax, while remaining compatible with current and future versions of HTML.

PowerWeb Macro Mime Type

All documents that contain PowerWeb Macros should be assigned a Mime type of text/x-server-parsed-html. A simple way of ensuring this is to use the Macro Template instead of the Default Template. This template automatically defines all .htm, .html, .inc and .nxt files as containing PowerWeb Macros. The Resource Editor allows you to change the Template to use for a Resource. Note that the Admin Template is derived from the Macro Template, so it automatically inherits the ability to show documents containing Web Macros. You can see which Templates are based on others by examining the Template Tree.

Understanding PowerWeb Macros

In PowerWeb Macro documents, tags define the start and end of macros. Most PowerWeb Macros are identified in a document as a single tag which gives the macro name and attributes. A few macros, such as conditional blocks, require a start and an end tag. Single and start tags are delimited by <!--# and -->, and end tags are delimited by <!--#/ and -->.

An example with a start and end tag:

<!--#if @connection:/RemoteHost?"*.widget.com" -->
This server is not allowed to show you this document.
<!--#/if -->
An example with a single tag:
<!--#echo format=escaped var=request:/header/in/referer -->
Here "echo" is the macro name, while "format" and "var" are attributes.

Macro Names

The macro name immediately follows the tag open delimiter. An element name consist of a series of letters. Names are not case sensitive. For example, IF is equivalent to if.

Examples of Valid and Invalid Syntax:

  • <!--#echo var=name -->
    is valid
  • <!--# echo var=name -->
    is valid
  • <!--# ECHO var=name -->
    is valid
  • <!--# Echo var=name -->
    is valid
  • <!-- #echo var=name -->
    is NOT valid, no spaces are allowed within "<!--#"
Attributes

In a single or start tag, white space and attributes are allowed between the macro name and the closing delimiter. An attribute typically consists of an attribute name, an equal sign, and a value (although some attributes may be just a name). White space is allowed around the equal sign. The value may be contained within quotes.


PowerWeb Server++ Macro Reference

This section is an alphabetically listed reference manual for each of the PowerWeb Server++ Macros.


Append
Appends text to an existing PowerWeb Server++ variable. The variable must have write permission set for this macro to succeed.

Attributes:

Live = (yes/no)
Whether to access the variable in the live configuration, or in the parallel copy used for editing purposes. Default is "not live".

(path) = (value)
The attribute name specifies the full path to the variable to be modified. The attribute value gives the new value to be appended to the variable.

Examples:
Create a Database Query String from a Submitted Form
<!--#set table_query="select * from " -->
<!--#append table_query=@database -->
<!--#append table_query=".." -->
<!--#append table_query=@table -->

Begin
Outputs the following HTML code:
<!doctype html public "-//IETF//DTD HTML 3.0//EN"><html>
which informs the browser that the document will make use of HTML 3.0 tags, as well as declaring the start of the document.

Examples:

A Simple Page
<!--#begin -->
<h1>A Simple Page</h1>
<!--#end -->

Call
This WebMacro is used in conjunction with the Script WebMacro to call embedded scripts within HTML.

Attributes:

into = (variable)
The name of the variable in which to store the result. If this attribute is empty or undefined, the result is automatically displayed within the current document.

varprefix = (character)
Translates embedded WebObject variable names into their text contents before executing the script. If this attribute is not present, the translation does not occur (which is the default). WebObject variable names are recognised by the special character prefix specified by this attribute. To include a literal character and not perform name lookup, prefix the character by a backslash.

For example if the varprefix is "@", and your script reads:

Your name is @name
it will be equivalent to:
Your name is <!--#echo var=name-->
which in turn is equivalent to:
Your name is <!--#echo var=Request:/Argument/name-->
but is obviously a lot easier to type and to read.

The #loop and #database WebMacros both use an implicit varprefix="@" when they call a script.

macro = (script name)
Executes the embedded WebMacro script with the specified name.

perl = (script name)
Executes the embedded WebPerl script with the specified name.

rexx = (script name)
Executes the embedded WebRexx script with the specified name.

Examples:
Call the Perl TimeZone Script
<!--#call perl=PerlTime -->

Call an InSide HTML WebMacro Script
<!--#call varprefix="@" macro=Example -->
The script "Example" will be called after all variables with an "@" prefix within the script have been translated into their text contents equivalents.


Comment
Allows you to include comments within your HTML which are not visible to the client, because they are stripped from the file before the HTML is sent to the client.

Examples:

Include a private comment
<!--#comment This is a private comment. -->

Concat
Concatenates the text of several existing PowerWeb Server++ variables into another variable. The destination variable must have write permission set for this macro to succeed.

Attributes:

Live = (yes/no)
Whether to access the variable in the live configuration, or in the parallel copy used for editing purposes. Default is "not live".

Var = (variable)
The name of a variable to concatenate with the result so far. Multiple "var" attributes may be used to combine several variables. If the variable is a "list" then each of its members is concatenated. It is essential that the "var" attribute follow any applicable "prefix", "suffix" and "separator" attributes, otherwise they will be ignored.

Prefix = (value)
The text value to output before each concatenated item.

Suffix = (value)
The text value to output after each concatenated item.

Separator = (value)
The text value to output between each concatenated item. The default separator is a comma ",".

Into = (variable)
The name of the variable in which to store the result. If this attribute is empty or undefined, the result is automatically displayed within the current document.

varprefix = (character)
Translates embedded WebObject variable names within attribute values before processing the value text.

varformat = (EscapeURL/EscapeHTML/EscapeSingleQuotes/EscapeDoubleQuotes)
Specifies how to format the contents of an embedded WebObject variable. See the #echo WebMacro's format attribute for more information.

Examples:
Show all the Database Query Headings
<!--#concat prefix='<b>' suffix='</b>' separator='<br>' var=Request:/Loop -->

Config
The Config macro allows for overriding the default error message, the default date and time format, and the default file size format.

Attributes:

errmsg = (text)
The (text) defines the new error message to display when a macro encounters an error, such as a syntax error or a variable not found error.

timefmt = (format)
A format string to use when displaying dates with the FLastMod macro. This format string is compatible with the C runtime library strftime function, allowing the following special sub-format specifications:

a
abbreviated weekday name

A
full weekday name

b
abbreviated month name

B
full month name

d
day

H
24 hour

I
12 hour

m
month

M
minute

S
second

w
weekday 0-6, Sunday=0

x
date representation

X
time representation

y
2 digit year

Y
4 digit year

%
percent

sizefmt = (format)
A format string to use when displaying file sizes with the FSize macro. The allowed formats are "bytes" and "abbrev". "Bytes" shows the size as a thousands-separated count of bytes, and "abbrev" shows the size as a number of "K" (kilobytes), "M" (megabytes) or "G" (gigabytes).

Examples:
Display the Current Time with Graphics
The time is now <!--#config timefmt="%H:%M:%S" -->
<img src=/$font?text=<!--#flastmod timezone=local now -->&style=gif&file=digital1.gif&charset=time&dir=/icons/digits -->

Copyright
Outputs a copyright message including links to the company's Web Home Page and e-mail contact address.

Attributes:

Company = (text)
The name of the company.

Mail = (text)
The e-mail address of the contact at the company.

URL = (text)
The Web Home Page for the company.

Examples:
Display a Standard Copyright Notice
<!--#copyright company="Acme Insurance" mail="info@acme.com" url="www.acme.com" -->

Counter
Read the Documentation and Examples for automated page access counters and counter displays.
Create
Create a new PowerWeb Server++ variable. If the variable already exists, it is overwritten, unless write permission has been denied.

Attributes:

Parent = (variable)
The directory in which to create the variable. If no parent is given, then "request:/argument" is assumed.

Name = (text)
The name of the variable to create.

Type = (type)
The type of variable to create, with the default being "text".

It Can Be One Of:

Text
A sequence of printable characters ending in a null (0) character. The maximum length is 2 gigabytes, subject to virtual memory constraints.

Integer
A 4-byte (32 bit) signed integer.

Float
An 8-byte (double precision) signed floating point number.

Binary
A sequence of bytes that may contain embedded null (0) characters. The maximum length is 2 gigabytes, subject to virtual memory constraints.

List
A directory of other variables. There is no limit to the number of hierarchy levels.

Value = (text)
The initial value to assign to the variable. If this attribute is absent, the variable is given a null value.

Live = (yes/no)
Whether to create the variable in the live configuration, or in the parallel copy used for editing purposes. Default is "not live".

Examples:
Create a Variable if the User did not Submit a Complete Form
<!--#if !defined=Quantity -->
<!--#create name=Quantity type=integer value=1 -->
<!--#endif -->

Database
Read the Documentation and Examples for details on how to achieve rapid development of HTML Database Applications by interfacing PowerWeb to databases, using a simple Web Macro syntax common across all database vendors.
Destroy
Removes an existing PowerWeb Server++ variable. The variable must have delete permission set for this macro to succeed.

Attributes:

Live = (yes/no)
Whether to delete the variable in the live configuration, or in the parallel copy used for editing purposes. Default is "not live".

(path)
The full path to the variable to be deleted.

Examples:
Destroy a Temporary Variable after use
<!--#destroy Request:/Argument/TempVar -->

Dir
Outputs a directory listing in the same format as the dynamic directory indexing facility which is accessed when a user specifies a directory on your site, without mentioning a document name.

This PowerWeb Macro is more powerful in that you have full control over what files are displayed, as well as their format and surrounding text above and below the directory listing.

Attributes:

file = (wildcard pattern)
The files that you wish to see listed.

virtual = (wildcard pattern)
The virtual URLs on your site that you wish to see listed.

Fancy = (yes/no)
Default is TRUE.

IncludeDirectories = (yes/no)
Default is FALSE.

IconsAreLinks = (yes/no)
Default is FALSE.

ScanHTMLTitles = (yes/no)
Default is FALSE.

SuppressDescription = (yes/no)
Default is TRUE.

SuppressLastModified = (yes/no)
Default is FALSE.

SuppressSize = (yes/no)
Default is FALSE.

Examples:
List all ZIP files present in the Current Directory
<!--#dir file="*.zip" -->

DirectoryMap
Displays a map of your site as a tree view. Users can click on the hyperlinks to go directly to any HTTP directory within your site to which they have access.

Only directories which the current user is allowed to access are shown, thereby protecting the privacy of your site.

Because DirectoryMap is a WebMacro, you can add any other HTML before or after the map to explain its usage, or to embed it within another page.

Examples:

A sample page:
Use this map to navigate within this site:
<!--#DirectoryMap -->

Echo
Displays the contents of a PowerWeb Server++ variable, or a CGI variable (for backwards compatibility).

Attributes:

Var = (path or CGI variable)
The full path of the PowerWeb Server++ variable to be displayed, or the name of an NCSA CGI variable. Usage of CGI variables is discouraged because of their higher overhead and lesser functionality.

NotFound = (text)
The text to display if the variable is not found.

Format = (text)
Choose one of "EscapeURL", "EscapeHTML", "EscapeSingleQuotes" or "EscapeDoubleQuotes" according to the destination of the result. For example, if you are echoing a variable to be used within a hyperlink URL as a form argument, use "EscapeURL". If you wish to include a general text string of unknown content which may contain special HTML markup characters, then use "EscapeHTML". The other format options for quotes handle situations such as including a variable within an SQL query string.

Attrib = (type)
Specifies that variables in any following conditional attributes will be evaluated according to the given attribute type.

Valid Attribute Types Are:

Value
The value of the variable.

Size
The size of the variable, 0 if it is empty.

Name
The name of the variable.

Path
The full directory path name of the variable.

Live = (yes/no)
If Live is YES, it specifies that the currently active live configuration is to be used, otherwise the copy of the configuration that is currently being edited is used. The default is YES.

Into = (variable)
The name of the variable in which to store the result. If this attribute is empty or undefined, the result is automatically displayed within the current document.

Examples:
Display the Current Number of Connections
<!--#echo var=Server:/Stats/Clients -->

Display the Number of Form Fields Submitted
<!--#echo attrib=size var=Request:/Argument -->

Create a Hidden Field to Pass on a Field from one Form to Another
<input type=hidden name=pass value= "<!--#echo notfound='my_default' var=pass -->" >


Elif
The Elif macro is only used in conjunction with IF and ENDIF.
Read the documentation on IF for more details.
Else
The Else macro is only used in conjunction with IF and ENDIF.
Read the documentation on IF for more details.
End
Outputs the following HTML code:
</body></html>
which informs the browser that the document is complete.

Examples:

A Simple Page
<!--#begin -->
<h1>A Simple Page</h1>
<!--#end -->

Endif or /if
The Endif macro is only used in conjunction with IF.
Read the documentation on IF for more details.
EndScript or /Script
The EndScript macro is only used in conjunction with Script.
Read the documentation on Script for more details.
Exec
The Exec macro executes an API, Perl, Rexx or CGI Script or Operating-system Executable Program and includes its output within the HTML document.

The C, Perl and Rexx scripts have full access to the PowerWeb APIs, so they can query or set variables, perform validation, output customised text, etc. Refer to the API reference manual for more information.

Attributes:

cmd = (executable program)
Executes an operating system executable program or built-in command, which takes no keyboard input. The program output is displayed in the document.

cgi = (CGI script)
The CGI script is a URL specifying the CGI program to run. Any headers output by the CGI script are ignored, because the headers of the current document take precedence.

api = (module!function)
The API script is a URL specifying the API library module and function to run.

rexx = (module)
The Rexx script is a URL specifying the Rexx command module to run. If no directory is mentioned, the file is assumed to be in the same directory as the HTML document referring to it.

perl = (package!function)
The Perl package name must be on your PERLLIB path and is case sensitive. Note that the "perl-bin" directory is automatically placed on your PERLLIB path when PowerWeb starts up. The function name must be the name of a function contained within the specified package and is called with the PowerWeb "parcel" as its argument.

Examples:
Execute a Rexx Script in the Current Directory, Displaying its Output Within the Current Document
<!--#exec rexx=common.cmd -->
Note: you must have set Access Control Permissions to allow API script execution from within the Resource protecting that directory.

Execute a Perl Package Function
<!--#exec perl=Sample!TimeZone -->

Load and Run a Perl Script within a Specific Directory
<!--#exec perl=/perl-bin/test.pl -->


Fetch
Fetches the contents of a Web document or image from another site and either includes it within the current document or stores it within a WebObject for further processing.

If you want to fetch a local file, it is more efficient to use the #include or the #exec WebMacro.

Attributes:

URL = (http://site/document)
The full URL of the document to fetch. Currently only the HTTP and HTTPS (SSL version 3) protocols are allowed. This attribute must follow the "into" and "status" attributes within the WebMacro. Multiple "url" attributes are allowed within a single WebMacro and will cause multiple documents to be fetched.

Post = text
Used to send form data, in which case an HTTP POST is sent, instead of a GET command. It is up to you to correctly format the posted form data in HTTP argument list format.

Into = (variable)
The name of the variable in which to store the result. If an error occurs the error text is stored and not any (partial) document that may have been received.
If this attribute is empty or undefined, the result is automatically displayed within the current document.

Status = (integer variable)
The name of the variable in which to store the status return code. HTTP returns status 200 for success. You can omit this attribute if you do not need to know the status.

StatusText = (text variable)
The name of the variable in which to store the returned status text. Each Internet protocol defines semi-standard status text for each status return code, so it is best to use the status return code instead if you are performing error checking. You can omit this attribute if you do not need to know the status text.

Examples:
Include the Contents of an External Document:
<!--#fetch url=http://www.compusource.co.za/powerweb/index.htm -->

Execute a Command on an External Server and Store the Response:
<!--#fetch status=mystatus into=myvar url=http://www.compusource.co.za/example/bin/tour.dll!TourDirect -->
<!--#if !@mystatus=200 -->
Communications Failure!
<!--#elif empty=myvar -->
Empty Response from External Server!
<!--#else -->
The remote server responded with:
<!--#echo format=EscapeHTML var=myvar -->
<!--#endif -->

Retrieve an image from another server:
(this example code must all be on one line and be the only contents of your file)
<!--#set Request:/Header/Out/Content-type=image/gif--> <!--#fetch url=http://www.compusource.co.za/icons/clips/everest.gif -->


FSize
Outputs the size of a file or document, using the current size format specification (which can be changed by the Config macro). This macro is typically used in conjunction with an HTTP or FTP link to download a file.

Attributes:

file = (filename)
The filename path is relative to the current directory of the original HTML document.

virtual = (local URL)
The URL specified must be local to the current server and is specified in the same way as a normal local document hyperlink reference within an HTML document.

Thousands = (character)
The character to use as a thousands separator when displaying sizes. The default is a comma.

Into = (variable)
The name of the variable in which to store the result. If this attribute is empty or undefined, the result is automatically displayed within the current document.

Examples:
Display the Size of a Photo File
Download the <a href=photo.jpg>photo</a> which is of size <!--#fsize virtual=photo.jpg -->.

FLastMod
Outputs the date and/or time of the last modification of a file or document, using the current date and time format specification (which can be changed by the Config macro). This macro is typically used in conjunction with an HTTP or FTP link to download a file.

Attributes:

file = (filename)
The filename path is relative to the current directory of the original HTML document.

virtual = (local URL)
The URL specified must be local to the current server and is specified in the same way as a normal local document hyperlink reference within an HTML document.

Now
Uses the current date and time instead of that for a given file.

Timezone = (GMT/local)
Specifies a timezone for displaying the date and time. The default is GMT.

Into = (variable)
The name of the variable in which to store the result. If this attribute is empty or undefined, the result is automatically displayed within the current document.

Examples:
Display the Last Modification Date of the Current Document
This document was last updated on <!--#flastmod virtual=@Request:/VirtualResource -->

If
The If macro defines the start of a conditional block. The block is ended by an Endif or /If macro, and can optionally contain multiple Elif macros and a single Else macro.

The structure of IF/ELIF/ELSE/ENDIF is as follows:

<!--#if (conditions 1) -->
HTML to output if the "if" conditions are true.
<!--#elif (conditions 2) -->
HTML to output if the "elif" conditions are true.
<!--#elif (conditions 3) -->
HTML to output if the next "elif" conditions are true.
<!--#else -->
HTML to output if the "if" and all the "elif" conditions are false.
<!--#endif -->
The If and Elif macros contain conditional attributes which are evaluated to TRUE or FALSE to determine whether to include the block of HTML into the document.

Optional attribute attributes can be included to refine the evaluation of the conditional attributes.

Specification Attributes:

And
The conditions that follow are combined with AND. The first condition that evaluates FALSE, causes the entire IF condition to evaluate FALSE.

Or
The conditions that follow are combined with OR. The first condition that evaluates TRUE, causes the entire IF condition to evaluate TRUE.

Attrib = (type)
Specifies that variables in any following conditional attributes will be evaluated according to the given attribute type.

Valid Attribute Types Are:

Value
The value of the variable.

Size
The size of the variable, 0 if it is empty.

Name
The name of the variable.

Path
The full directory path name of the variable.

Live = (yes/no)
If Live is YES, it specifies that the currently active live configuration is to be used, otherwise the copy of the configuration that is currently being edited is used. The default is YES.

Conditional Attributes:

All conditional attributes can start with an optional '!' character which reverses the condition.

Defined = (variable)
Evaluates to TRUE if the specified variable exists.

Empty = (variable)
Evaluates to TRUE if the specified variable does not exist, or if its contents are empty or NULL.

Var = (variable)
Evaluates to TRUE if the specified variable exists and its contents evaluate to TRUE.

@(variable) (condition) (value)
Evaluates the expression where (variable) can be any PowerWeb variable, (value) can be a constant or a reference to any PowerWeb variable, and (condition) is one of:

=
Tests for equality.

<
Tests less than.

>
Tests greater than.

?
Tests whether the (value) can be found by a text search within the (variable). If (value) contains any wildcard characters (? or *), then a regular expression match is performed.

Note: text comparisons are case insensitive.

File = (wildcard pattern)
Evaluates to TRUE if any file exists on your site that matches the specified wildcard pattern.

Virtual = (wildcard pattern)
Evaluates to TRUE if any local URL exists on your site that matches the specified wildcard pattern.

Counter
Evaluates to TRUE if a page access counter exists for the current document.

Counter = (url)
Evaluates to TRUE if a page access counter exists for the specified local document.

0
Evaluates to FALSE.

1
Evaluates to TRUE.

Examples:
Test for Correctly Filled-in Forms

<!--#if or empty=LastName empty=FirstName -->
You did not fill in the FirstName or LastName field on the form.
<!--#endif -->

Tests whether the form fields FirstName and LastName were entered, and, if not, includes an error message in the document returned to the user.

Take Different Actions According to Form Fields

<!--#if @Pizza=Pepperoni -->
You ordered a Pepperoni pizza.
<!--#elif @Pizza=Hawaiian -->
You ordered our house speciality, the Hawaiian pizza.
<!--#else -->
There is no pizza named <!--#echo var=Pizza --> on our menu.
<!--#endif -->

Displays which pizza the user ordered, with an error message if the user ordered a pizza which is not on the menu.

Return Different Documents or Messages According to Domain or IP Address

<!--#if @connection:/RemoteAddress?"12.34.56.*" -->
You are on our private network.
<!--#elif @connection:/RemoteHost?"*.widget.com" -->
You are on the widget.com domain.
<!--#else -->
This server is not allowed to show you this document.
<!--#endif -->

This example illustrates how you can return different documents or messages according to the domain or IP address from which the user accesses your server. Access control rules within the server configuration can also be used to prevent unauthorised access.


Include
The Include macro substitutes the contents of the specified file or document into the current document. This macro is extremely useful when used in conjunction with the IF macro because it allows conditional display of documents according to a variety of conditions, such as the name or host machine of a user, or the contents of a form that has been submitted.

Attributes:

file = (filename)
The filename path is relative to the current directory of the original HTML document.

virtual = (local URL)
The URL specified must be local to the current server and is specified in the same way as a normal local document hyperlink reference within an HTML document.

Examples:
Include Boiler-Plate Text into a Document
<!--#include virtual=template.htm -->

Conditionally Show a Page According to the Client Browser
<!--#if @Request:/Header/In/User-Agent ? "Mozilla" -->
<!--#include virtual=netscape.htm -->
<!--#else -->
<!--#include virtual=generic.htm -->
<!--#endif -->


Input
Displays a data entry field which is automatically populated with a list of valid data items.

Attributes:

var = (directory)
The name of a PowerWeb Server++ variable directory which contains the list of allowed options.

name = (text)
The name to give to the HTML input field.

type = (text)
The type of data entry field to use, currently only listboxes and comboboxes are supported.

size = (number)
This is the number of data items to display without scrolling. A value of 1 results in a combobox, and a larger number results in a listbox which uses scrollbars only if the number of options exceeds the value given here.

live = (yes/no)
Whether to look for the directory in the live configuration, or in the parallel copy used for editing purposes.


List
The List macro presents an HTML table that is suitable for editing a list of PowerWeb Server++ variables all contained in the same directory.

Attributes:

var = (directory)
The name of a PowerWeb Server++ variable directory which contains the list of variables to edit.

mode = (text)
The mode determines whether the table is read-only or editable. Use "input" for an editable table, and "browse" for a read-only table.

live = (yes/no)
Whether to look for the directory in the live configuration, or in the parallel copy used for editing purposes.


Loop
The Loop macro iterates over a series of values or WebObjects, calling an embedded WebScript for each iteration. Refer to the documentation on the Script WebMacro for more information.

The Loop macro stores its loop control variable within a special WebObject directory. Its default location is "Request:/Loop/RowNumber". There are also other WebObject variables within that directory:

  • "ColumnCount", which is always 1.
  • "RowCount", which is the total number of iterations to be performed.
  • "Variable", which is the name of the current variable when a "var=" iteration is being performed.

The Loop macro is compatible with the Database WebMacro in terms of iteration specifications, loop variables and scripting.

Attributes:

var = (directory)
The name of a PowerWeb Server++ WebObject variable directory which contains the list of objects to iterate over. If this is specified, do not use the "from", "to" or "step" attributes.

from = (number)
The starting numeric value for the iteration. You should also specify the "to" attribute, but not the "var" attribute.

to = (number)
The ending numeric value for the iteration. You should also specify the "from" attribute, but not the "var" attribute.

step = (number)
The increment for the loop value for each iteration. Defaults to 1. You should also specify the "from" and "to" attributes, but not the "var" attribute.

maxrows = (number)
The maximum number of iterations to perform. If the from/to/step attributes imply a larger number of iterations, the "to" specification is adjusted accordingly. You must also specify either the "from" or the "var" attribute.

live = (yes/no)
Whether to look for the "var" WebObject in the live configuration, or in the parallel copy used for editing purposes. Defaults to "yes".

cursor = (directory)
The name of the directory in which to place loop control variables. It defaults to "Loop", and is always created under the "Request:/" directory. Naming your loop allows you to create nested loops. The directory and its variables are automatically created for you and are deleted at the end of the loop iteration.

heading = (script name)
The name of the embedded WebScript to execute to display a heading. Only output if the loop iteration is valid.

row = (script name)
The name of the embedded WebScript to execute for each iteration of the loop.

trailer = (script name)
The name of the embedded WebScript to execute to display a trailer. Only output if the loop iteration is valid.

Examples:

Iterating a WebMacro, According to the Submitted HTML Form Field named "Count"
<!--#script LoopScript -->
Row number <!--#echo var=Request:/Loop/RowNumber --><br>
<!--#/script -->
<!--#loop from=1 to="<!--#echo notfound=5 var=count -->" row=LoopScript -->

Redirect
Redirects the client's browser to a specified URL, which may be on any site. This PowerWeb Macro is useful within conditional blocks to display documents according to conditions. If the documents are local to your site, the use of the #Include PowerWeb Macro is more efficient.

Attributes:

virtual = (url)
The full URL to redirect the client's browser to.
Examples:
Redirect Users on a Specified Subnet to Another Server
<!--#if @connection:/RemoteAddress?"12.34.56.*" -->
<!--#redirect virtual="http://internal.acme.com/thispage.htm" -->
<!--#endif -->

Script
Defines a new embedded Script within the HTML document. The script can be written in any interpreted language supported by PowerWeb, such as WebPerl, WebRexx or WebMacros.

The "EndScript" or "/Script" WebMacro must be used to define the end of the script.

The script has a logical scope of the current HTTP request only and is deleted after the HTTP request is complete.

Scripts can be contained within #include files and can be called as many times as required by using the #call and #loop WebMacros.

Scripts offer an easier-to-use syntax for including the contents of WebObject variables within your script. Refer to the documentation on the "varprefix" attribute of the #call WebMacro. The #loop and #database WebMacros both use an implicit varprefix="@" when they call a script. In addition, when #loop and #database are used, the variable name is first looked up within the loop cursor's value directory, then the cursor directory itself and then only does the normal variable name lookup occur. This enables the script writer to directly write SQL column names in the html without worrying about where they are stored within PowerWeb.

You should read the API Reference Manual for details on creating scripts. In particular, you should also read the manuals on Perl Scripts or Rexx Scripts.

Attributes:

(name)
The name to give to the script. This is the name that must be supplied when using the Call or Loop WebMacros.
Examples:
Calling a Perl ODBC Package from within HTML
<!--#Script ODBC_Servers -->
use ODBC;
my($html) = WebPerl::Find(WebPerl::GetParcel(), 'Request:/Result');
WebPerl::AppendText($html, '', ODBC::AvailableServers());
0;
<!--#EndScript -->
<!--#Call perl=ODBC_Servers -->

Perl Script Example
Look at the code within "\powerweb\system\tour\perltime.htm".

Rexx Script Example
Look at the code within "\powerweb\system\tour\rexxtime.htm".


Set
Defines a new value for an existing PowerWeb Server++ variable. The variable must have write permission set for this macro to succeed.

Attributes:

Live = (yes/no)
Whether to access the variable in the live configuration, or in the parallel copy used for editing purposes. Default is "not live".

(path) = (value)
The attribute name specifies the full path to the variable to be modified. The attribute value gives the new value to be assigned into the variable. If the variable does not exist and only a name, not a path, is specified, then the variable is auto-created in the "Request:/Argument" variable directory as a text variable.

Examples:
Define a Temporary Variable
<!--#set TempVar="my_value" -->

Split
Uses a regular expression to split the contents of a PowerWeb variable into its constituent parts.

Attributes:

Live = (yes/no)
Whether to access the variable in the live configuration, or in the parallel copy used for editing purposes. Default is "not live".

Pattern = (text)
The regular expression pattern to use. Wildcards * and ? are allowed, and %0, %1, %2 etc are used as placeholders to segment the text. So component one stretches from %0 to %1 and component two stretches from %2 to %3, etc. This allows for overlapping regions.

Into = (variable)
The name of a list variable into which to place the components. Each component is named into/1, into/2, etc.

Value = (text)
The expression to evaluate prior to matching against the pattern.

varprefix = (character)
Translates embedded WebObject variable names within attribute values before processing the value text.

Regular Expression Syntax:

The following special characters are used within a regular expression:

'*' matches 0 or more of any char ([minimal] or maximal matching)
'?' matches exactly one of any char
'[' introduces a list of allowed chars, with '~' performing exclusion and '-' specifying ranges, followed by ']' and finally:

'@' 0+ repetitions with minimal matching
'+' 1+ repetitions with minimal matching
'!' 0+ repetitions with maximal matching
'#' 1+ repetitions with maximal matching
'' exactly one occurrence

'%' followed by a decimal digit stores a placeholder.
'$x.y'defines the text from placeholder x to placeholder y. This is useful for checking for recurring identical text segments.
':a' is single alphanumeric [a-zA-Z0-9]
':b' is single blank [ \t]
':c' is single alpha [a-zA-Z]
':d' is single digit [0-9]
':h' is hexadecimal number [0-9a-fA-F]#
':i' is C identifier [a-zA-Z_\$][a-zA-Z0-9_\$]!
':n' is decimal number {[0-9]#.[0-9]!|[0-9]!.[0-9]#|[0-9]#}
':s' is single whitespace [ \t\r\n]
':v' is simple C variable [a-zA-Z_\$][A-Za-z0-9_\$\-.>\[\]]!
':w' is multiple alpha (word) [a-zA-Z]#
':z' is multiple digits (integer) [0-9]#
':' followed by non-alpha char is treated as per normal
':' followed by unrecognised alpha char is undefined
'\t' matches tab
'\r' matches carriage return
'\n' matches new line
'\a', '\b', '\f', '\v' match their C-char equivalents
'\' treats next char as a literal ie allows matching on "*?[-]{|}@+!#$:" too. (unless alpha, in which case result is undefined).
'<' (reserved)
'>' (reserved)
'^' (reserved)
'$' (reserved)
'{' (reserved)
'}' (reserved)
Examples:
Split a name containing underscores
<!--#split pattern='%0*%1_%2*%3_%4*%5' into=Split value=@fieldname -->
There are <!--#echo attrib=size var=Request:/Split --> components, the first of which is <!--#echo var=Request:/Split/1 -->.

Table
The Table macro presents an HTML table that is suitable for editing a list of PowerWeb Server++ variables all of the same type. The editable table supports deletion, creation, modification and re-sequencing.

Attributes:

var = (directory)
The name of a PowerWeb Server++ variable directory which contains the list of variables to edit.

free = (number)
The Free attribute determines how many blank records are presented for creating new records at the end of the table. A value of 0 prevents the creation of new records.

mode = (text)
The mode determines whether the table is read-only or editable. Use "input" for an editable table, and "browse" for a read-only table.

type = (0/1)
The type determines the display and editing format of the table. If it is omitted, the default table type is used, as defined by the variable "Config:/Console/TableType". Use 0 for a table using pre-formatted text with a single record editing facility, and use 1 for an HTML 3.0 table with multiple record editing capability.

live = (yes/no)
Whether to look for the directory in the live configuration, or in the parallel copy used for editing purposes. The default value is live=no.

colX = (text)
Defines the contents of the column numbered X in the table. If the (text) includes a colon, then all text after the colon is used as a column heading, and the prior text defines the name of the field in the record to display.

colX_edit = (text)
Defines whether column X may be edited and whether it must be filled in when creating new records.

Legitimate Edit Modes Are:

No
The column is read-only.

Yes
The column is always allowed to be edited.

Auto
Determines whether the column is editable according to the variable's permission settings.

Required
The column is always allowed to be edited and must be filled in before a new record will be accepted.

OneOf
The column is always allowed to be edited and it, or another column also marked OneOf, must be filled in before a new record will be accepted.

Link
The column is read-only in this table, but hyperlinks to another data entry screen for editing.

colX_width = (number)
Defines the number of characters to specify as the input field width in column X.

colX_null = (text)
Defines the text to show if column X has a NULL value. Also any text entered which matches this value is considered to be NULL.