Admiral
Admiral
1105 views

Convert a C# or VB program to Cobol

Jump to solution

Hello,

I come again to ask for your help to convert a program to Cobol.

There is a version in C # and VB.

Attached is the complete solution with both languages.

There is a .bat file in both Tutorial folders that generates the solution to be used.

Within the solution the program I need is pr04_analyze.

I think that what I send allows me to do what I need.

Thank you again for your help.

Best regards,

Alberto Ferraz

0 Likes
1 Solution

Accepted Solutions
Admiral
Admiral

Thanks Chris, it's works fine.

Now I will improve the program.

Best regards

Alberto Ferraz

View solution in original post

0 Likes
10 Replies
Micro Focus Expert
Micro Focus Expert

There is an on-line tool that will convert C# to COBOL for you.

https://cs2cobol.microfocuscloud.com/

Just copy in the C# code that you wish to convert and it will generate the equivalent COBOL code.
In some cases, the generated code may require some tweaking in order to get it to run but in most cases it does a fine job.

Admiral
Admiral

Hi Chris,

Thanks for the tip.
I will try the solution. If you have any difficulties, I will contact you.

Best regards

Alberto Ferraz

0 Likes
Admiral
Admiral

Hi Chris,

I have been using the tool whose link you sent me.

I just couldn't convert the following statement:

"try {CurrentField.GetImage (). Save (Pr22.Imaging.RawImage.FileFormat.Png) .Save (Fieldname +" .png ");} catch (Pr22.Exceptions.General) {}".

 

It has been converted into:

"try invoke CurrentField :: GetImage () :: Save (type Pr22.Imaging.RawImage.FileFormat :: Png) :: Save (Fieldname & ".png") catch as type Pr22.Exceptions.General end-try".

The error goes in attachment.

Apparently the type exists (see the other annex).


What I need is to record the image contained in the variable.

Thanks in advance.

Best regards

Alberto Ferraz

 

 

 

0 Likes
Micro Focus Expert
Micro Focus Expert

Do you have a reference to the assembly containing the Pr22.Imaging namespace as part of the references folder of the COBOL project?

Is the type recognized by Intellisense on any other statements?

Try typing in:

invoke type Pr22.

Does Intellisense list the classes within this namespace? 

0 Likes
Admiral
Admiral

Hi again,

Yes I have. And there are other calls to Pr22 that are ok.

This particular type is only used in this instruction.

Yes, list but only up to Pr22.Imaging.RawImage.

From here, you don't list anything else (although in the assembly you have this instruction). See annex 02 of the previous topic.

Best regards

Alberto Ferraz

0 Likes
Micro Focus Expert
Micro Focus Expert

Try a + sign in between RawImage and FileFormat like:

RawImage+FileFormat

0 Likes
Admiral
Admiral

Thanks Chris, it's works fine.

Now I will improve the program.

Best regards

Alberto Ferraz

View solution in original post

0 Likes
Admiral
Admiral

Hi again,

I have already managed to convert almost everything and the project is on track. I have a situation here that I cannot see how it is.

pr.PresenceStateChanged += PresentStateChanged;

In the converter it gives:

set pr::PresenceStateChanged to pr::PresenceStateChanged + PresentStateChanged

but give me an error.

 

Thanks,

Alberto Ferraz

 

0 Likes
Micro Focus Expert
Micro Focus Expert

What is the error message you are getting?

You can try the following:

attach method PresentStateChanged to pr::PresenceStateChanged

0 Likes
Admiral
Admiral

Hi Chris,

Thanks for the tip. I've tried it and it doesn't give a compilation error.

Still, I can't get the event to work, but I'll try to understand what's going on.

Thanks again for the help.

Best regards

Alberto Ferraz

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.