Highlighted
Absent Member.
Absent Member.
1275 views

Case sensitive

Jump to solution

How do I make variable case sensitive.  I would like to make policyNumber and PolicyNumber different variables.  How is that done?

 

      

working-storage section.

       01 policyNumber type String property no set.

      

method-id New.

procedure division using by value policyNumber as type String.

 Set PolicyNumber to policyNumber.

end method.

Tags (1)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Case sensitive

Jump to solution

COBOL does not allow data names to differ only by case, but you can distinguish an instance or static field from a method local variable or parameter by using the self:: prefix like this:

working-storage section.

      01 PolicyNumber String property no set.

method-id New.

procedure division using by value PolicyNumber as String.

Set self::PolicyNumber to PolicyNumber.

end method.

If you really want two properties (or public fields to differ only by case, you could use the AS phrase:

      01 PolicyNumber String property no set .

      01 PolicyNumber2 String property no set as "policyNumber".

...but I can't really think of any reasons one might want to do this...

View solution in original post

0 Likes
3 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Case sensitive

Jump to solution

COBOL does not allow data names to differ only by case, but you can distinguish an instance or static field from a method local variable or parameter by using the self:: prefix like this:

working-storage section.

      01 PolicyNumber String property no set.

method-id New.

procedure division using by value PolicyNumber as String.

Set self::PolicyNumber to PolicyNumber.

end method.

If you really want two properties (or public fields to differ only by case, you could use the AS phrase:

      01 PolicyNumber String property no set .

      01 PolicyNumber2 String property no set as "policyNumber".

...but I can't really think of any reasons one might want to do this...

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Case sensitive

Jump to solution

The reason I was doing this was to stick to C# naming conventions.  I will probably use self::fieldname or just change the name thanks.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Case sensitive

Jump to solution

Other .NET languages have similar constraints, most notably VB.NET. This has been recognised since the earliest days of .NET. Microsoft introduced the Common Language Specification (CLS) to ensure .NET libraries could be effectively used by different languages, and one of it's rules is that names cannot differ just by case.

Related to this, if you need to use a Cobol reserved word as the name of a dataname, then you can prefix it with hash e.g. #move if you need a member name "move".

0 Likes
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.