WebSpeed
Developer’s Guide


Compile-time Versus Run-time Code

Like many languages, SpeedScript includes two basic types of code:

However, as an interpretive language, WebSpeed syntax combines compile-time and run-time components in many more ways than a compiled language like C. The flexibility of this syntax helps implement the rich variety of overridable defaults that characterizes SpeedScript.

Compile-time Code

Certain statements exist only to generate r-code when WebSpeed compiles them. These are compile-time statements. That is, they create static data and form buffer resources (frame and field objects) that the run-time statements can reference and modify, but not destroy, during execution.

Compile-time Syntax Elements

Most compile-time code consists of the following syntax elements:

Run-time Code

Run-time statements use the static resources created by compile-time statements, but can also create, use, and destroy dynamic resources at run time. That is, run-time statements include statements that interact with static resources, dynamic resources, or both. Many run-time statements also include compile-time options. These are options that generate resources at compile time that are later used by the same statements at run time.

Run-time Syntax Elements

Most run-time code consists of the following syntax elements:

How Do Compile-time and Run-time Code Interact?

Because SpeedScript is a run-time interpreted language, it can combine compile-time and run-time code in a number of interesting and powerful ways.

As noted earlier, some run-time statements can also include compile-time options. Thus, you can define a frame to display data using a DEFINE FRAME statement, then add options to that static definition using Frame phrase options in subsequent run-time statements, such as FOR and {&DISPLAY}.

In this example, the data fields, frame type, and title for frame alpha are all defined at compile time and in three different statements:

sample5
DEFINE FRAME alpha Customer.Name Customer.Phone.

FOR EACH Customer WITH FRAME alpha SIDE-LABELS:
    {&DISPLAY} name phone balance WITH TITLE "Customer Balances".
END. 

A powerful example of the interaction between compile-time and run-time code is the use of the VALUE option in a number of run-time statements. In sample6, the VALUE option allows you to use a run-time expression (proc-name[proci]) to provide a compile-time object name:

sample6
DEFINE VARIABLE proci AS INTEGER.
DEFINE VARIABLE proc-name AS CHARACTER EXTENT 3
    INIT ["proc1.p", "proc2.p", "proc3.p"].

{&OUT} "<P>These are STATIC procedure executions.</P>" .
RUN proc1.p.
RUN proc2.p.
RUN proc3.p.

{&OUT} "<P>These are DYNAMIC procedure executions.</P>" .
DO proci = 1 TO 3:
    RUN VALUE(proc-name[proci]).
END. 

In the RUN statement, the object name is the name of a procedure to execute. sample7 thus shows how the same three procedures can be executed using static compile-time object names or using object names evaluated by the VALUE option at run time.

NOTE: The procedures proc1.p, proc2.p, and proc3.p exist for illustration only.


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