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:
- Compile-time statements, including SpeedScript statements that begin with the DEFINE keyword
- The nonexecutable components of block header statements and END statements
- Options and phrases associated with compile-time statements, wherever they appear
- Literal expressions (constants)
- Preprocessor directives and definitions
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:
- All statements other than compile-time statements.
- The options and phrases associated with run-time statements, including the executable components of block header statements, except those options and phrases that are also associated with compile-time statements (such as Format and Frame phrases).
The block header statements of iterative blocks (DO, FOR, and REPEAT blocks) all have executable components. These executable components monitor and enforce the iteration conditions (when the block starts and stops executing) and select any database data that are available to the block.
NOTE: WebSpeed distinguishes variables from their field object representation. However, the references to variables (or fields) in the ASSIGN and {&DISPLAY} statements reference both the variables and their field object representations because WebSpeed moves data between them implicitly at run time.- Assignment statements and nonliteral expressions (variables, functions, attributes, and methods).
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:
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:
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 proceduresproc1.p
,proc2.p
, andproc3.p
exist for illustration only.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |