exposing .Net classes

I have a Visual Studio 2013 - Visual COBOL Managed (can I just refer to it as Visual Cobol .Net?) program that I am using to convert a string data type to a decimal data type, using the "convert" function (ignoring validation for now).

Currently, I have a REPOSITORY with this:

    class convertClass as "System.Convert".

and in the procedural code, I am doing this:

   MOVE convertClass::ToDecimal(myString)  TO myDecimal.

What I want to know is how to do this using the alternate approach of using the $set ilusing directive so that I can do something like this instead:

  MOVE convert::ToDecimal(myString)  TO myDecimal.

I have tried it several ways ($set ilusing"System.Convert" and $set ilusing"System"), but I can't seem to get it to recognize System or System.Convert such that I can do this.


  • Verified Answer

    Actually, the repository is no longer required in Visual COBOL. That is a holdover from Net Express.

    In VC you use the type keyword to specify a class name.

    You should be able to use:

       set myDecimal to type Convert::ToDecimal(mystring)

    without specifying $set ilusing"System" because the System namespace is automatically included by default.

    If you wish to do validation then you could instead use the TryParse method of the Decimal class.

      if not type Decimal::TryParse(mystring, myDecimal)

          move 0 to myDecimal


    Or you could insert a try catch block around the Convert statement.


  • Thanks, Chris.

    Your "set" example above works, and the $set directive is not required to do this, since System is auto-included (and incidentally, thanks for the validation tip).

    But, how would you code this using a MOVE statement instead of a set statement???

    (Or, could you be implying that the MOVE statement and the set statement are not exactly equivalent and that this is one of those exceptional situations???)

  • Verified Answer

    I prefer to use the set statement but you can use move if you prefer but you must use the type keyword in front of the class name which is Convert (or System.Convert)

    move type Convert::ToDecimal(mystring) to myDecimal