Highlighted
PaoloR Honored Contributor.
Honored Contributor.
559 views

CALLing sub-program error

Jump to solution

I'm trying to develop a project where a main program (say MAINCBL) accepts options and then CALLs sub programs. I created a MAINCBL solution and then added SUBPROG to the solution.

MAINCBL works fine but when I call SUBPROG I get an error message: 'Called program file not found in drive/directory: SUBPROG'.  Both MAINCBL.EXE and SUBPROG.EXE are in my \bin\x86\Debug directory so I'm at a loss to know what's wrong.

I changed the Application properties to Output to: Multiple Executables (not sure if this correct so please correct me if not.)

Thanks

0 Likes
1 Solution

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

Re: CALLing sub-program error

Jump to solution

Try the attached simple demo where MainProg calls SubProg. Both projects have the output path pointing to ..\Deploy, which gets created if it doesn't exist.

–Ғɑɳօ
0 Likes
16 Replies
Austin1 Honored Contributor.
Honored Contributor.

Re: CALLing sub-program error

Jump to solution

You can't call an EXE.  It needs to be a DLL.  Change it from EXE to a DLL.

 

0 Likes
PaoloR Honored Contributor.
Honored Contributor.

Re: CALLing sub-program error

Jump to solution

Austin

Thanks for the reply. Given that I have SUBPROG.CBL in my project folder alongside MAINCBL.CBL how do I generate SUBPROG.DLL?

I have found the documentation somewhat confusing since it talks about linking and choosing run time systems.

0 Likes
Austin1 Honored Contributor.
Honored Contributor.

Re: CALLing sub-program error

Jump to solution

Sorry, I don't have Visual Studio and Visual COBOL available to me at the moment.

It is a drop-down box on the called program's same tab where you found the Multiple Executables option (which you probably need to set back to the default).

Also, on the tab where you specify the OUTPUT, that needs to be the same absolute directory - after compiling, use Windows Explorer to make sure the calling EXE and the called DLL are really in the same directory. 

0 Likes
Micro Focus Expert
Micro Focus Expert

Re: CALLing sub-program error

Jump to solution

I just wanted to add that you'd need to create separate projects, one for the EXE and another for the DLL.

Since your current project already creates an EXE, you simply need to create a different project identified as 'Link Library' for the subprogram.

As already indicated by @Austin1, you may change the Output path for these projects to the same location. This will allow the EXE to find and call the subprogram in DLL.

OutputPath.jpg

–Ғɑɳօ
PaoloR Honored Contributor.
Honored Contributor.

Re: CALLing sub-program error

Jump to solution

@Austin1, @Fano_MF

I removed SUBPROGRAM from the MAINPROG project and created a new SUBPROGRAM Link Library project with its own project folder.

I compiled the SUBPROGRAM, having set the output directory to be the same one where MAINPROG.EXE resides. A copy of SUBPROGRAM.CBL now sit in the MAINPROG project folder plus SUBPROGRAM.DLL resides alongside MAINPROG.EXE in bin/x86/Debug.

When I run MAINPROG it attempts to call SUBPROG but I get the same error as before: "173 called program file not found in drive directory".

???

0 Likes
Austin1 Honored Contributor.
Honored Contributor.

Re: CALLing sub-program error

Jump to solution

Use Windows Explorer to make sure MAINPROG.EXE and SUBPROGRAM.DLL are both in fact in the same folder.

0 Likes
PaoloR Honored Contributor.
Honored Contributor.

Re: CALLing sub-program error

Jump to solution

Austin1

Yes, that's what I did originally. They're both in the Debug folder in the MAINPROG project area. There is nothing in the SUBPROG Debug folder.

 

0 Likes
Austin1 Honored Contributor.
Honored Contributor.

Re: CALLing sub-program error

Jump to solution

Sorry you are having so much trouble.

After you have done it for a while, it becomes second nature, and you don't think much about it as you do it each time.

My issue is that I am away from work, and cannot bring up Visual Studio, etc.

Here is something you might want to review closely, including the Tutorial.zip attachment, as this directly relates to what you are working on.  There are a bunch of these knowledge base items here that can be reviewed for various techniques.

https://community.microfocus.com/t5/Visual-COBOL-Knowledge-Base/Visual-COBOL-for-Visual-Studio-Getting-Started-with-Solutions/ta-p/1755670

Please let us know how it goes.  I will need for @Fano to help you if you need further assistance.

0 Likes
Austin1 Honored Contributor.
Honored Contributor.

Re: CALLing sub-program error

Jump to solution

Sorry, that was @Fano_MF  not @Fano.

 

0 Likes
PaoloR Honored Contributor.
Honored Contributor.

Re: CALLing sub-program error

Jump to solution

Thanks, Austin1. I can't download/open the tutorial.zip file though.

0 Likes
Micro Focus Expert
Micro Focus Expert

Re: CALLing sub-program error

Jump to solution

Try the attached simple demo where MainProg calls SubProg. Both projects have the output path pointing to ..\Deploy, which gets created if it doesn't exist.

–Ғɑɳօ
0 Likes
Austin1 Honored Contributor.
Honored Contributor.

Re: CALLing sub-program error

Jump to solution

Just to confirm and verify, that worked for me - I was able to download it and bring it up under Visual Studio and do a BUILD, Rebuild Solution on it and then a DEBUG, Start Without Debugging.

 

PaoloR Honored Contributor.
Honored Contributor.

Re: CALLing sub-program error

Jump to solution

Fano_MF

That worked, as expected. I checked the Properties in my MAINPROG and the only difference with your solution was that I had in COBOL LINK -> Run Time Model -> Shared whereas yours was Dynamic.

The other difference is that I have 2 separate projects (as I believe I was advised by Austin1), MAINPROG and SUBPROG whereas yours seemed to be MAINPROG solution containing 2 projects.

I am stumped. This is a modernisation/rewrite of  a program that I wrote in 2005. In those days, when I was using Professional COBOL, I seem to recall that it was possible to call .EXE files or .INT/.GNT files rather than .DLL files.

0 Likes
PaoloR Honored Contributor.
Honored Contributor.

Re: CALLing sub-program error

Jump to solution

Well, I'm going to have to start again. I screwed up my MAINPROG.cbl file and I don't have a backup ☹️. So back to the drawing board. Thanks for the help Fano_MF and Austin1.

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.