Absent Member.
Absent Member.
955 views

default parameters

Jump to solution

Is there a way to provide a default parameter in Visual Cobol like you can in C#?

public void MyString(String passedString = " ")

0 Likes
1 Solution

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

Yes, this is possible using the 2.2 version of Visual COBOL, and the syntax is quite similar to the C# syntax.  

As an example:

      class-id a.

      method-id main static.

          invoke self::MyString("Hello")

          invoke self::MyString

      end method.

      method-id MyString static public.

      procedure division using by value passedString as string = " ".

          display passedString

      end method.

      end class.

View solution in original post

0 Likes
2 Replies
Micro Focus Expert
Micro Focus Expert

Yes, this is possible using the 2.2 version of Visual COBOL, and the syntax is quite similar to the C# syntax.  

As an example:

      class-id a.

      method-id main static.

          invoke self::MyString("Hello")

          invoke self::MyString

      end method.

      method-id MyString static public.

      procedure division using by value passedString as string = " ".

          display passedString

      end method.

      end class.

View solution in original post

0 Likes
Absent Member.
Absent Member.

Thanks.  I thought I tried that.  I must have done something wrong.

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.