Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
COBOL
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====Scope termination==== Some statements, such as {{code|IF}} and {{code|READ}}, may themselves contain statements. Such statements may be terminated in two ways: by a period (''{{dfn|implicit termination}}''), which terminates ''all'' unterminated statements contained, or by a scope terminator, which terminates the nearest matching open statement. <syntaxhighlight lang="cobolfree"> *> Terminator period ("implicit termination") IF invalid-record IF no-more-records NEXT SENTENCE ELSE READ record-file AT END SET no-more-records TO TRUE. *> Scope terminators ("explicit termination") IF invalid-record IF no-more-records CONTINUE ELSE READ record-file AT END SET no-more-records TO TRUE END-READ END-IF END-IF </syntaxhighlight> Nested statements terminated with a period are a common source of bugs.{{sfn|ISO/IEC JTC 1/SC 22/WG 4|2014|p=899}}{{sfn|McCracken|Golden|1988|loc=Β§ 8.4}} For example, examine the following code: <syntaxhighlight lang="cobolfree"> IF x DISPLAY y. DISPLAY z. </syntaxhighlight> Here, the intent is to display <code>y</code> and <code>z</code> if condition <code>x</code> is true. However, <code>z</code> will be displayed whatever the value of <code>x</code> because the <code>IF</code> statement is terminated by an erroneous period after {{code|DISPLAY y|lang=cobolfree}}. Another bug is a result of the [[dangling else problem]], when two <code>IF</code> statements can associate with an <code>ELSE</code>. <syntaxhighlight lang="cobolfree"> IF x IF y DISPLAY a ELSE DISPLAY b. </syntaxhighlight> In the above fragment, the <code>ELSE</code> associates with the {{code|IF y|lang=cobolfree}} statement instead of the {{code|IF x|lang=cobolfree}} statement, causing a bug. Prior to the introduction of explicit scope terminators, preventing it would require {{code|ELSE NEXT SENTENCE|lang=cobolfree}} to be placed after the inner <code>IF</code>.{{sfn|McCracken|Golden|1988|loc=Β§ 8.4}}
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
COBOL
(section)
Add topic