Beginning with Visual COBOL V6.0 Visual COBOL supports the DECLARE statement in native code.
This allows you to declare one or more local variables within the procedure division body. The scope of any inline 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.
This support was already in managed .NET/JVM programs although in managed code the local data items are statically scoped, but (unlike managed COBOL local items) they are not perform-range-local: if you re-enter a paragraph or section, fresh copies of any associated local data items are not created.
Example:
01 names pic x(10) typedef.
...
declare i1 as binary-long
display i1
*> Optionally, the variables can be initialized inline
declare c2 as binary-long = 5
display c2
declare name-list as names occurs 3#localvariables
#declare
#HowTo-BestPractice
#VisualCOBOL
#SupportTips/KnowledgeDocs
#.net
#JVM
#SupportTips/SupportTips/KnowledgeDocs
#VisualCOBOL