|
<< Click to Display Table of Contents >> BLOCK |
![]() ![]()
|
Four types of options Gekko operates with four types of options: global options, general options, block-options and local options. Global options are read when Gekko launches and cannot be altered later on (they have the form option global ...). General options are stated with the OPTION command and apply until changed. Block options are stated with the BLOCK command and apply for a block of Gekko statements. Local options are stated inside the <> local option field and apply to that single statement only. See more here. |
A BLOCK structure is used to set the time period and/or other options temporarily (block options). A block can for instance be used inside a function or procedure definition, where the time period, frequency or other options may be changed, but where these changes should be undone after leaving the function/procedure. A block could be used together with LOCAL variables to avoid changing the state of the program when calling a function/procedure.
Using a block series dyn = yes; ... ; end; is the only way to set the <dyn> option on several expressions at the same time. This is because option series dyn should only be used when needed, that is, for expressions like x = x[-1] + 1; and similar. So using the option together with a BLOCK makes sure the option is turned off again.
Syntax
block option1, option2, ...;
...statements...
...statements...
...statements...
end;
option |
Can be one of two kinds:
•A time period, using the TIME keyword, for instance block time 2020 2030; ... ; end; This corresponds to time 2020 2030;. •An option setting (OPTION statement without the option keyword), for instance block freq q; ... ; end; to change the frequency, corresponding to option freq q;.
The options (including time period) can separated with commas, for instance block freq q, time 2020q1 2025q4, print width = 200;. The BLOCK keyword must always be ended with an END. |
Examples
The following is an example of nested blocks that set the time period
time 2001 2003; |
This is an example of setting two options for printing (corresponding to option print fields ndec = 1; option print fields pdec = 1;).
time 2001 2003; |
BLOCK can also be used to change frequency temporarily. The following example will create the quarterly series y1!q defined over 2001q3-2023q2. After the BLOCK, the time period will be back to annual 2021-23, therefore y2!a is defined over these three years.
reset; |
Note
A designated time period does not have to be the first item in a list of block options.
Related statements