Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Coming Soon... Local Variables in Managed COBOL

Coming Soon... Local Variables in Managed COBOL

Let’s start with a simple example.

Declaring Local Variables

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

or

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.

Declaration of Exception Variables

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.

Scope

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.

And finally...

Your feedback is welcome.

 

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Comments

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).

Version history
Revision #:
1 of 1
Last update:
‎2012-06-21 16:56
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.