Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Computer Science is merely the post-Turing decline in formal systems theory.


computers / comp.os.vms / ChatGPT can *almost* write working OpenVMS code

SubjectAuthor
o ChatGPT can *almost* write working OpenVMS codeJake Hamby (Solid State Jake)

1
ChatGPT can *almost* write working OpenVMS code

<364ef36a-a2e0-4e36-ba94-d01cfcbfaa9dn@googlegroups.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=31256&group=comp.os.vms#31256

  copy link   Newsgroups: comp.os.vms
X-Received: by 2002:ac8:478c:0:b0:420:210c:650a with SMTP id k12-20020ac8478c000000b00420210c650amr231149qtq.3.1700170557291;
Thu, 16 Nov 2023 13:35:57 -0800 (PST)
X-Received: by 2002:a17:903:25c9:b0:1cc:3f29:2904 with SMTP id
jc9-20020a17090325c900b001cc3f292904mr2346189plb.7.1700170556970; Thu, 16 Nov
2023 13:35:56 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.os.vms
Date: Thu, 16 Nov 2023 13:35:56 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:46b0:abc0:1290:397f:45b6:f859;
posting-account=OGFVHQoAAAASiNAamRQec8BtkuXxYFnQ
NNTP-Posting-Host: 2600:1700:46b0:abc0:1290:397f:45b6:f859
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <364ef36a-a2e0-4e36-ba94-d01cfcbfaa9dn@googlegroups.com>
Subject: ChatGPT can *almost* write working OpenVMS code
From: jake.ha...@gmail.com (Jake Hamby (Solid State Jake))
Injection-Date: Thu, 16 Nov 2023 21:35:57 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 5387
 by: Jake Hamby (Solid St - Thu, 16 Nov 2023 21:35 UTC

I was curious if ChatGPT knows enough to write OpenVMS code. The answer is "yes, but it's buggy."

Me: "Write an OpenVMS program in C to create a file and write a message to it."

ChatGPT: "Certainly! Below is a simple example of an OpenVMS program written in C that creates a file and writes a message to it. Please note that OpenVMS uses the Record Management Services (RMS) for file operations."

#include <stdio.h>
#include <rms.h>

int main() {
// Define file attributes
struct FAB fab = cc$rms_fab;
struct NAM nam = cc$rms_nam;
char filename[] = "MYFILE.TXT";

// Set up the file name
fab.fab$l_fna = filename;
fab.fab$b_fns = sizeof(filename) - 1;
fab.fab$l_nam = &nam;

// Create the file
if (sys$create(&fab) != RMS$_NORMAL) {
fprintf(stderr, "Error creating file\n");
return 1;
}

// Open the file for writing
if (sys$connect(&fab) != RMS$_NORMAL) {
fprintf(stderr, "Error opening file\n");
return 1;
}

// Write a message to the file
char message[] = "Hello, OpenVMS!\n";
int message_length = sizeof(message) - 1;
if (sys$write(&fab, 0, 0, message, message_length) != RMS$_NORMAL) {
fprintf(stderr, "Error writing to file\n");
sys$disconnect(&fab);
return 1;
}

// Close the file
if (sys$disconnect(&fab) != RMS$_NORMAL) {
fprintf(stderr, "Error closing file\n");
return 1;
}

printf("File created and message written successfully.\n");

return 0;
}

This program uses the RMS system services to create a file, open it for writing, write a message to it, and then close the file. Please make sure to adjust the file name (filename array) and the message content (message array) according to your requirements. Also, handle errors appropriately in a production environment."

Me: "Your program has a bug. sys$connect takes an RAB struct, not an FAB struct."

ChatGPT: "You're absolutely correct, and I appreciate your diligence in catching that mistake. Here is the corrected version of the program, using the correct RMS structure for opening the file:

#include <stdio.h>
#include <rms.h>

int main() {
// Define file attributes
struct FAB fab = cc$rms_fab;
struct NAM nam = cc$rms_nam;
struct RAB rab = cc$rms_rab;
char filename[] = "MYFILE.TXT";

// Set up the file name
fab.fab$l_fna = filename;
fab.fab$b_fns = sizeof(filename) - 1;
fab.fab$l_nam = &nam;

// Create the file
if (sys$create(&fab) != RMS$_NORMAL) {
fprintf(stderr, "Error creating file\n");
return 1;
}

// Open the file for writing
rab.rab$l_fab = &fab;
rab.rab$b_rac = RAB$C_SEQ;
if (sys$open(&rab) != RMS$_NORMAL) {
fprintf(stderr, "Error opening file\n");
sys$close(&rab);
return 1;
}

// Write a message to the file
char message[] = "Hello, OpenVMS!\n";
int message_length = sizeof(message) - 1;
if (sys$write(&rab, 0, 0, message, message_length) != RMS$_NORMAL) {
fprintf(stderr, "Error writing to file\n");
sys$close(&rab);
return 1;
}

// Close the file
if (sys$close(&rab) != RMS$_NORMAL) {
fprintf(stderr, "Error closing file\n");
return 1;
}

printf("File created and message written successfully.\n");

return 0;
}

This corrected version now uses the RAB structure for opening the file with sys$open. Thank you for pointing out the issue, and I hope this helps!"

There are multiple bugs remaining in the "corrected" version, but it's still pretty wild that ChatGPT knows enough to give a rough approximation of a program using an API that's confusing enough that it's not immediately apparent to me how to initialize the FAB and RAB structs to use it correctly.

What's more worrisome is that it confidently returned buggy programs that compile and link but do the wrong thing at runtime.

Regards,
Jake Hamby

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor