Article View: comp.lang.cobol
Article #4Re: codeconvert.ai
From: Arnold Trembley
Date: Mon, 12 Oct 2026 02:11
Date: Mon, 12 Oct 2026 02:11
97 lines
4771 bytes
4771 bytes
On 2026-10-11 10:54 AM, docdwarf@panix.com wrote:
> In article <hq6dnR6bKpYFnFb3nZ2dnZfqn_qdnZ2d@giganews.com>,
> Arnold Trembley <arnold.trembley@att.net> wrote:
>>
>> Found this in a thread in the GnuCOBOL forums. It's a link to a website
>> for creating a COBOL program using AI prompts.
>
> MAIN-PARA. Ain't seen one of those in a while.
>
> DD
I asked it to create a program that performs a credit card Mod 10 check
digit validation using the Luhn algorithm, which is described in a
Wikipedia article:
https://en.wikipedia.org/wiki/Luhn_algorithm
The check digit algorithm is intended to detect digit transposition or
substitution when a credit card number is manually typed.
In this case it generated a "MAIN-LOGIC" paragraph instead of
"MAIN-PARA", but the generated COBOL looked pretty reasonable. I
compiled it with GnuCOBOL 3.2 and it appeared to execute correctly, and
I also tested it with different "card numbers" generated with difference
check digit values.
IDENTIFICATION DIVISION.
PROGRAM-ID. LUHN-VALIDATOR.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-INPUT.
05 WS-CARD-NUMBER PIC X(16) VALUE "49927398716".
01 WS-VARIABLES.
05 WS-I PIC 9(2) COMP.
05 WS-DIGIT PIC 9(2) COMP.
05 WS-SUM PIC 9(4) COMP VALUE 0.
05 WS-DOUBLED PIC 9(2) COMP.
05 WS-REMAINDER PIC 9(2) COMP.
05 WS-MOD-RESULT PIC 9(4) COMP.
01 WS-TABLE.
05 WS-TABLE-DIGITS PIC X OCCURS 16 TIMES.
01 WS-OUTPUT-MSG.
05 WS-RESULT-MSG PIC X(30).
PROCEDURE DIVISION.
MAIN-LOGIC.
PERFORM INITIALIZATION
PERFORM VALIDATE-LUHN
PERFORM DISPLAY-RESULT
STOP RUN.
INITIALIZATION.
MOVE WS-CARD-NUMBER TO WS-TABLE.
MOVE 0 TO WS-SUM.
VALIDATE-LUHN.
PERFORM VARYING WS-I FROM 16 BY -1 UNTIL WS-I < 1
MOVE WS-TABLE-DIGITS(WS-I) TO WS-DIGIT
IF FUNCTION MOD(WS-I, 2) = 1
COMPUTE WS-DOUBLED = WS-DIGIT * 2
IF WS-DOUBLED > 9
COMPUTE WS-DOUBLED = WS-DOUBLED - 9
END-IF
ADD WS-DOUBLED TO WS-SUM
ELSE
ADD WS-DIGIT TO WS-SUM
END-IF
END-PERFORM.
DISPLAY-RESULT.
COMPUTE WS-MOD-RESULT = FUNCTION MOD(WS-SUM, 10)
IF WS-MOD-RESULT = 0
DISPLAY "CREDIT CARD NUMBER IS VALID."
ELSE
DISPLAY "CREDIT CARD NUMBER IS INVALID."
END-IF.
Of course, this means the pointy-haired bosses will want all the new
programs written by AI bots, so they can pay us less.
Cheers,
--
https://www.arnoldtrembley.com/
--
This email has been checked for viruses by Avast antivirus software.
www.avast.com
Technical Details
Message-ID:
<yZqdneuIArRD3FH3nZ2dnZfqnPidnZ2d@giganews.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!69.80.99.24.MISMATCH!border-3.nntp.ord.giganews.com!nntp.giganews.com!local-2.nntp.ord.giganews.com!Xl.tags.giganews.com!local-4.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mailReferences:
<hq6dnR6bKpYFnFb3nZ2dnZfqn_qdnZ2d@giganews.com> <11agbfe$gau$1@reader2.panix.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!69.80.99.24.MISMATCH!border-3.nntp.ord.giganews.com!nntp.giganews.com!local-2.nntp.ord.giganews.com!Xl.tags.giganews.com!local-4.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 12 Oct 2026 02:11:39 +0000 Date: Sun, 11 Oct 2026 21:11:36 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: codeconvert.ai Newsgroups: comp.lang.cobol References: <hq6dnR6bKpYFnFb3nZ2dnZfqn_qdnZ2d@giganews.com> <11agbfe$gau$1@reader2.panix.com> Content-Language: en-US From: Arnold Trembley <arnold.trembley@att.net> In-Reply-To: <11agbfe$gau$1@reader2.panix.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: Avast (VPS 261011-4, 10/11/2026), Outbound message X-Antivirus-Status: Clean Message-ID: <yZqdneuIArRD3FH3nZ2dnZfqnPidnZ2d@giganews.com> Lines: 97 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-ltIvrdCHbpnTWRW4wM1fuMIs7AMNekyYsGHN6Dz6rv9JJWqyr5Lyg8eEn67zMyntwQCSk7Ag0sy1C7T!emBaU/8Zp9wlZvPH5+dGiMx39tupIKui/1SvC8uUiz8j3CeXF/u8vFPT0cpxNpr5wLrg+IFxcw== X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40