Skip to main content

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

public void MyString(String passedString = " ")


#VisualCOBOL
#TranslatefomCtovisualcobol

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

public void MyString(String passedString = " ")


#VisualCOBOL
#TranslatefomCtovisualcobol

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.


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

public void MyString(String passedString = " ")


#VisualCOBOL
#TranslatefomCtovisualcobol

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


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

public void MyString(String passedString = " ")


#VisualCOBOL
#TranslatefomCtovisualcobol

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


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

public void MyString(String passedString = " ")


#VisualCOBOL
#TranslatefomCtovisualcobol

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