Questions tagged [gnucobol]

GnuCOBOL is a free (like both in "free speech" and in "free beer") COBOL compiler, formerly known as OpenCOBOL. It implements a substantial part of the COBOL 85, COBOL 2002 and COBOL 2014 standards, as well as many extensions. GnuCOBOL translates COBOL into C and compiles the translated code using the native C compiler on various platforms, including GNU/Linux, Mac OS X, IBM z/OS, Unix, AS/400, and Microsoft Windows.

GnuCOBOL is an implementation of COBOL. For further information see:

An IDE explicit targeting GnuCOBOL is Gix-IDE, which comes with a source-level debugger, ESQL preprocessor and more. Editors based on vscode can also be setup for a "near IDE" experience to edit, compile and debug GnuCOBOL.

Please report bugs and raise issues you see with migrations to GnuCOBOL at either the discussion boards or in the feature request tracker.

Additional tools and COBOL source samples tested with GnuCOBOL are made available by the community.

See info pages for COBOL and COBOL85 for more information about the language.

201 questions
1
vote
1 answer

COBOL code wont compile and create an executable

I'm trying to create a report for a given input file where I am supposed to ill examine each record to determine if it fails to meet certain criteria. The issue that I am facing now is that the cob file wont compile eventhough it doesn't explicitly…
NicholasC
  • 11
  • 1
1
vote
1 answer

Gnucobol compiles .cob to .c failed to pass compiler of clang

I was trying to compile hello.cob to hello.c: $ ls hello.cob $ cobc -x -C hello.cob $ ls hello.c hello.c.h hello.c.l.h hello.cob But clang failed to compile hello.c to executable file: $ clang hello.c /tmp/hello-479acf.o: In function…
illyrix
  • 153
  • 2
  • 11
1
vote
1 answer

GNUCobol compiled program counts one more record than expected

I'm learning COBOL programming and using GNUCobol (on Linux) to compile and test some simple programs. In one of those programs I have found an unexpected behavior that I don't understand: when reading a sequential file of records, I'm always…
jantoniomartin
  • 215
  • 3
  • 9
1
vote
1 answer

DevC++ C calling OpenCobolIDE module

I'm trying to call an OpenCobol file handling routine from a program written in C using the Dev C++ IDE (they're free and I like them). The Cobol environment generates a DLL when you compile the code as a module so I was hoping that I could just use…
AdyB
  • 11
  • 1
1
vote
1 answer

Is it possible to display multiple screens in a loop in cobol?

So I'm trying to make a program in OpenCobolIDE that uses the SCREEN SECTION feature in COBOL to create a menu where the user chooses whether he wants to input data or display it. This data is being recorded in a sequential .txt file. The writing…
Levi Moraes
  • 57
  • 1
  • 8
1
vote
1 answer

Indexed File Error

I'm trying to open a file as indexed but keep getting the following error. From all the examples of COBOL code that I could find I can't see where my error is. I am able to open the file as sequential just fine. It seems to be something with…
Iron3eagle
  • 1,077
  • 7
  • 23
1
vote
1 answer

Using an index from another table

If a table element (table without an index) is accessed using an index of another table it can give a Table overflow error on IBM Host. But the same program does not result in a crash or a message (even with debug options) when using GnuCOBOL…
cobp
  • 772
  • 1
  • 5
  • 19
1
vote
1 answer

Generic function from dlsym with dereferenced float

The GnuCOBOL compiler supports dynamic CALL by using dynamic symbol lookup, but the MCVE here is strictly C, and is a little less than minimal to demonstrate (what I think) is both 4 and 8 byte sizes working. This is AMD-64, so sizeof *float is not…
Brian Tiffin
  • 3,978
  • 1
  • 24
  • 34
1
vote
1 answer

How to get all files in directory in cobol

I am working with GnuCOBOL(Using Windows) and I need to write a compiler with it. What i am asking is - given directory path, can i modify the files inside of it using COBOL? It is important to say that you can't know the files names. You know only…
I1265
  • 51
  • 6
1
vote
1 answer

Table indexing in cobol

I have a 2-D array in cobol and I want to write each row to the output file. I write the following code to do this. FILE-SECTION. 01 FILE-TABLE. 05 FILE-TABLE-ROW OCCURS 10 TIMES INDEXED BY I. 10 FILE-TABLE-COL PIC X(1) OCCURS 10 TIMES…
Louis Kuang
  • 727
  • 1
  • 14
  • 30
1
vote
2 answers

Redefining an array as a string works in MFCOBOL but warns in GnuCOBOL

01 COUNTER. 03 DIGITS1 OCCURS 40 TIMES PIC 9. 03 STRING1 REDEFINES DIGITS1 pic X(40). That compiles fine in Micro Focus Visual COBOL 2.3 in Visual Studio 2015. It gives an error in GnuCOBOL, viz The original…
bugmagnet
  • 7,631
  • 8
  • 69
  • 131
1
vote
1 answer

Invoke Java class from GnuCobol

Apologies if this question has been asked previously... I'm working on a proof of concept which requires GnuCobol(opencobol) to call/execute a Java class. Googling through a number of pages suggested use of INVOKE statement by instantiating the Java…
sandy
  • 63
  • 5
1
vote
2 answers

Comparing 2 PIC X strings of characters in COBOL

I'm really new to COBOL and I would like to ask a question. What if I have 2 PIC of characters and I would like to know if they are the same string 77 name1 PIC x(20). 77 name2 PIC x(20). PROCEDURE DIVISION. DISPLAY "Type the first…
Kofuku-san
  • 11
  • 1
  • 1
  • 2
1
vote
2 answers

Error using OCCURS in a very simple COBOL program

This is my code where iIam declaring a variable using OCCURS. IDENTIFICATION DIVISION. PROGRAM-ID. ARRAYEX. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT StudentFile ASSIGN TO "STUDENTS.DAT" …
chows2603
  • 167
  • 1
  • 2
  • 12
1
vote
3 answers

Displaying zeroes in COBOL

I'm new to COBOL and our latest training activity is we will try to get an output of three items like this: 0000/2013 00012345 12345** I have tried with my code below but it clearly does not give me the output I want. It does not display…