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
4
votes
2 answers

Splitting digits from a packed-decimal field

I have a 7-digit packed-decimal field on my file. How can I define data items that would extract/separate these 7 digits? For example I want to have the first two digits in one data item and the other digits in another, so I can manipulate them…
Murad
  • 41
  • 2
4
votes
1 answer

Reading floating-point numbers from file in COBOL

I have fixed-point numbers in file, one in each line, in this format S9(6)V9(2) but when they are actually read, I'm getting non numeric errors while trying to put them in math operations. What is more, when I try to display them in program, a…
Quentin
  • 1,090
  • 13
  • 24
4
votes
2 answers

Data type in COBOL

I have written the following program, I am confused why when I compile the program I get an error saying that A-COL(1,1) is not a numeric value while displaying A-COL(1,1) gives me 1. IDENTIFICATION DIVISION. PROGRAM-ID. TEST1. DATA…
Louis Kuang
  • 727
  • 1
  • 14
  • 30
4
votes
2 answers

Calling subroutine when using OpenCOBOLIDE

I am using OpenCOBOLIDE and trying to just simply call a subroutine. I am following along in a TutorialPoint document. I followed all the instructions but cannot seem to figure out why when I call the subroutine it still cannot find the module I am…
4
votes
2 answers

COBOL: Simple file reading issue

I have a very basic COBOL program that reads a file input.dat and simply outputs it in the console. The input.dat file looks like this: John Johnson Peter Peterson Juliette Julietteson…
Alvaro
  • 11,797
  • 9
  • 40
  • 57
4
votes
2 answers

OpenCOBOL sample won't compile

I am running Ubuntu and trying to learn COBOL. I have dabbled in a few online tutorials but have had inconsistent results with certain programs. I prefer to use vim in a bash shell; leading me to OpenCOBOL (cobc) Is there a decent tutorial that will…
user3025281
  • 157
  • 2
  • 10
4
votes
1 answer

Nested if statements in cobol

I am trying to use nested if statements in Cobol. As far as I can tell I am following the style guides, but keep receiving the error: file_name.cob:64: Error: syntax error, unexpected ELSE ^^ (This is the second ELSE statement) The purpose of the…
argonXM
  • 73
  • 3
  • 9
3
votes
1 answer

CALL unpredicatably changes unrelated variables in program

To preface, I am incredibly new to COBOL, and have only been writing it for about a week. I wrote a program that plays a Rock-Paper-Scissors (RPS) game and the computer randomly picks an option each turn. Originally, I had the section that generates…
Ethan Krug
  • 73
  • 6
3
votes
1 answer

GnuCOBOL calling Rust: libcob: error: module not found

I want to call Rust from GnuCOBOL. I've copied the code from the first example in Can GnuCOBOL interface with Rust? from Brian Tiffin's GNUCobol FAQ as a test but got an error when running it. Expected: $ make -B rustc --crate-type=dylib…
Joseph E
  • 33
  • 7
3
votes
1 answer

Could you reference a column in DECLARATIVES section when the column is used with SUM clause in COBOL REPORT WRITER Module?

Aside from the specific platform and the compiler, suppose you have this defined in a COBOL program using Report Writer Module: 01 CF-MM TYPE CONTROL FOOTING WS-MM. 02 LINE PLUS 1. 03 COLUMN 1 VALUE "* CF…
NoChance
  • 5,632
  • 4
  • 31
  • 45
3
votes
1 answer

mix cobol with c++/C

I tried to mix COBOL code with C++, but i not have success :( I see this topic in IBM forum: http://publib.boulder.ibm.com/infocenter/comphelp/v111v131/index.jsp?topic=/com.ibm.aix.cbl.doc/PGandLR/tasks/tpsub17.htm ( Calling between COBOL and C/C++…
Alexandre
  • 1,985
  • 5
  • 30
  • 55
3
votes
1 answer

GnuCOBOL PIC 999V99 - unexpected result?

What am I doing wrong with the following piece of code under GnuCOBOL 3.1-rc1.0? IDENTIFICATION DIVISION. PROGRAM-ID. NUMTEST. DATA DIVISION. WORKING-STORAGE SECTION. 01 NUM PIC 999V99. PROCEDURE DIVISION. …
3
votes
1 answer

ATAN DEGREES IN COBOL?

I have a little problem I don't know tow to turn in deegrees my ATAN/ASIN/ACOS function in cobol This is the code: ACCEPT A COMPUTE C= FUNCTION ATAN(A) END-COMPUTE …
aIDserse
  • 131
  • 8
3
votes
1 answer

How to validate a negative value being passed in as a alphanumeric literal?

Basically, I've been given an input file that gets passed in too a mix of fields that are alphanumeric and numeric. My goal is to test each field for valid data. The first field is an alphanumeric with a Pic X(3) description that should represent a…
3
votes
0 answers

PostgreSQL: How to store non-compliant (UTF8) raw bytes as bytea using GnuCOBOL?

The application that I use stores a 32 bit mask (1's and 0's) as a 4 character field in database by converting it to hex. (Its a pretty old application so can't change this). This used to work well with Oracle & DB2 (UTF8 encoding), however with…
Ankit Jain
  • 314
  • 3
  • 10
1
2
3
13 14