Try OpenEdge Now
skip to main content
Developing WebSpeed Applications
SpeedScript : Elements of SpeedScript syntax : Compile-time versus run-time code : How compile-time and run-time code interact
 
How 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 FIELDS(Balance Name Phone) NO-LOCK
  WITH FRAME alpha SIDE-LABELS:
  {&DISPLAY} Customer.Name Customer.Phone Customer.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 (cProc[iProc]) to provide a compile-time object name:

sample6

DEFINE VARIABLE cProc AS CHARACTER NO-UNDO EXTENT 3
  INITIAL ["proc1.p", "proc2.p", "proc3.p"].
DEFINE VARIABLE iProc AS INTEGER   NO-UNDO.

{&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 iProc = 1 TO 3:
  RUN VALUE(cProc[iProc]).
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.