Try OpenEdge Now
skip to main content
Developing WebSpeed Applications
SpeedScript : Elements of SpeedScript syntax : Block context and resource scope
 

Block context and resource scope

The context of some blocks also helps determine the scope of certain resources. Conversely, the scope of other resources might have little to do with the context in which you initially define them. Scope is really the duration that a resource is available to an application. Scope can vary depending on the resource and the conditions of application execution.
In general, the scope of resources created at compile time (when WebSpeed compiles your application) is determined at compile time; the scope of resources created at run time (when WebSpeed executes your application) is determined at run time. (See Compile-time versus run-time code.) The scope of a resource begins when the resource is instantiated (created in your application) and ends when the resource is destroyed (removed from your application).
For example, a FOR statement defines the scope of any database buffer that it implicitly defines for record reading. The scope of such a record buffer is identical to the context of the FOR block, because the buffer is deleted when the FOR block finishes with it. For example, in sample4, the scope of the Customer buffer ends when the FOR block completes. Although the {&DISPLAY} statement following the FOR block can access fBalance, it can no longer access the Customer.Balance field for any record read into the Customer buffer by the FOR block.
* Unscoped resources
* Dynamic resources