Skip to main content
Question

Windows.cpy has errors!

  • January 30, 2026
  • 3 replies
  • 33 views

InsyteDeveloper
Forum|alt.badge.img

After installing the Visual COBOL PE, a took a utility program written in Fujitsu COBOL, to see how much of the source would or would not compile. There were few lines of code in the utility program that did not compile and I changed and/or deleted them so as the original source compiled successfully. However, the source included the COPY WINDOWS statement and that is where the majority of the errors occurred when compiled the windows.cpy file! My first thought was that the original source was to blame. I subsequently took the COBOL source template  file that is created when a new project is started. Below is the contents of that file: 

 

       identification division.
       program-id. Program1.

       environment division.
       configuration section.

       data division.
       working-storage section.
       COPY WINDOWS. *> pick up Windows defines
       procedure division.

           goback.

       end program Program1.
 

The above code produced the same errors in the windows.cpy file. So my question is why this COPY file fails to compile. Are there project settings that I must set to eliminate this situation? Any help is greatly appreciated. I have attached a text file containing the error messages produced. 

Kevin

3 replies

Gael Wilson
Forum|alt.badge.img+1
  • Rocketeer
  • January 30, 2026

Kevin,

The windows.cpy included with Fujitsu COBOL is likely to be VERY different to the one provided with Visual COBOL. The Visual COBOL version includes the definitions of Windows APIs as well as data items and therefore defines program-ids which is why it cannot be included via a COPY statement in the working-storage section.

If you move it to the first line of your demo program it will compile cleanly but it almost certainly won’t be that simple in your utility program if that depends on any definitions from the Fujitsu version that are different.

Gael Wilson


InsyteDeveloper
Forum|alt.badge.img
  • Author
  • Participating Frequently
  • January 30, 2026

Gael, 

    Thanks for the quick reply. My basic understanding of COBOL, COPY statements typically are placed in the WORKING-STORAGE section. Am I wrong about that? If so, then your suggestion to move the COPY WINDOWS statement to the beginning of the source would make sense.

FYI - I unexpectantly inherited maintenance of our COBOL source a couple of years back and the last time I used COBOL was during my studies for computer programming over 40 years ago. So, my skills with the language are very rusty! 


InsyteDeveloper
Forum|alt.badge.img
  • Author
  • Participating Frequently
  • February 5, 2026

The moving of the COPY WINDOWS statement allowed me too successfully build the utility program. However, when the following code is debugged: 

CALL GetCurrentDirectory  
USING BY VALUE     PC-PATH-LENGTH
BY REFERENCE CURRENT-PC-DIRECTORY
RETURNING iRet
END-CALL.

it fails with the error message: 

173     Called program file not found in drive/directory: GetCurrentDirectoryA

I have set the ‘Link with libs’ project property to use the KERNEL32.LIB, so I think that the compiler would know to load KERNEL32.DLL into memory and call the appropriate function. But my interpretation of the error says it does NOT! So is this a limitation of the PE version or some other property to build has not been set correctly?

Any help is appreciated. 

Kevin