IMPORTANT NOTICE: As of 21 February, anything posted in this community WILL NOT BE MIGRATED to our new community site. We have pulled all user information and data from this site and are now in an approximately week long process of importing users, roles, and data to our new site. We are leaving this site open and active so you can post and hopefully get a response until the migration is complete. Once complete, the URL that currently takes you to this site will take you to our new site so your bookmarks will work as always. Please read the information on a New Login Process
Let’s start with a simple example.
Today variables are declared in the local-storage section of a method:
In the next release of Visual COBOL you will be able to declare them within the
procedure division body of your method.
Optionally, you will be able to assign a value to the variable during declaration :
The same principle
applies to framework types. For example, declaring the .NET Class Library structure System.DateTime.
and again, optionally a value can be assigned on declaration:
Declaration of Iteration Variables
In the current product, the variables i and s have to be declared in the local-storage section of the method. But as shown above, in the next release, the iteration variables can be declared within the scope of the iterator.
Likewise, currently the exception variable e has to be declared in
local-storage, but in the next release it can be delcared at point of use.
The scope of any in-line local variable is from the point of
declaration until the end of the innermost containing block, where paragraphs, sections
and the whole method are considered to be blocks.
NB. This new syntax will be available in Managed COBOL only.
Your feedback is welcome.
Just used some [paragraph-level]-scoped declared local variables today and proved to myself that the scope is the containing paragraph, as I had the same name declared within the same method but in another paragraph. Although I decided to change the name (for the developer's sake).