WebSpeed
Developer’s Guide


Elements of SpeedScript Syntax

SpeedScript is a block-structured, but statement-oriented language. That is, much of the behavior of a WebSpeed application depends on how statements are organized into blocks, but the basic executable unit of a WebSpeed application is the statement.

Statements

This is the basic syntax of a WebSpeed application:

SYNTAX
statement { . | : } [ statement { . | : } ... 

Thus, a SpeedScript application consists of one or more statements. Each statement consists of a number of words and symbols entered in a statement-specified order and terminated by a period ( . ) or a colon ( : ), depending on the type of statement.

NOTE: SpeedScript is a case-insensitive language. However, by convention, SpeedScript keywords (such as FOR) are expressed in uppercase lettering. Also by convention, most preprocessor names in WebSpeed are expressed in uppercase and the CGI environment variables defined in SpeedScript are expressed in uppercase according to the usual CGI conventions. However, character string compares and database queries keyed on character strings can be case-sensitive or case-insensitive, depending on the context and specifications of the compare or query.

sample1 is a one-statement application that displays “Hello, World!” in a browser:

sample1
{&OUT} "<H1> Hello, World! </H1>" . 

NOTE: You can experiment with the sample code in this section by running the code in the WebTools Scripting Lab. From the AppBuilder, choose Tools WebTools and then choose Scripting Lab from the WebTools menu.

Comments

A WebSpeed application can also contain nonexecutable comments wherever you can put white space (except in quoted strings). Each comment begins with “/*” and terminates with “*/”, and you can nest comments within other comments.

Blocks

In SpeedScript, a block is a sequence of one or more statements, including any nested blocks, that share a single context. A context consists of certain resources that a block of statements share. The content of this shared context depends on the type of block and its relationship to other blocks. sample2 shows a typical layout of blocks in a procedure:

sample2
REPEAT WHILE TRUE: /* BEGIN Iterative Block */
    RUN max-customers.
END.              /* END Iterative Block */

PROCEDURE max-customers: /* BEGIN Internal Procedure Block */
    FOR EACH Customer USE-INDEX Name NO-LOCK: /* BEGIN Iterative Block */
        IF Balance > 20000 THEN DO: /* BEGIN Non-iterative Block */
            {&DISPLAY} Name Balance.
        END.                        /* END Non-iterative Block */
    END.                                      /* END Iterative Block */
END PROCEDURE.          /* END Internal Procedure Block */ 

The most basic block is the procedure, and the most basic procedure is an external procedure-a file containing one or more statements-because this is the smallest unit that WebSpeed can compile separately. Web objects are always external procedures. Most of the samples in this section are not external procedures because their execution depends on the context of an enclosing Web object. An external procedure block is also the only type of block that requires no special syntax to define it. WebSpeed always defines an external procedure block, by default, when the procedure executes.

You must begin all other types of blocks with appropriate header statements. Header statements, such as the DO, FOR, and PROCEDURE statements shown in sample3, are typically terminated with a colon, although you can use a period. Generally, you must terminate the block begun with a header statement with an END statement.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095