COBOL“ Hello World”与终端一起使用视觉代码时会出现错误
因此,我开始学习COBOL,尝试了我的第一个“ Hello World”程序,并获得了无法解决的错误。
这是代码:
*hello
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
ENVIRONMENT DIVISION.
PROCEDURE DIVISION.
DISPLAY 'HELLO'.
STOP RUN.
我正在使用与gnucobol(Opencobol)交谈的扩展名的VS代码,在 this 视频(使用Windows)。当我运行代码时,我会收到此消息:
hello.cbl:1:错误:program-id标题缺失,
我尝试从其他一些具有示例代码但仍然收到此消息的来源复制代码。
感谢任何帮助。
So I'm starting to learn COBOL, tried my first "hello world" program, and got an error that I can't solve.
this is the code:
*hello
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
ENVIRONMENT DIVISION.
PROCEDURE DIVISION.
DISPLAY 'HELLO'.
STOP RUN.
I'm using vs code with extensions that talk with gnucobol(openCobol), did that with the help of this video (using windows). When I'm running the code, I get this message:
hello.cbl:1: error: PROGRAM-ID header missing
I've tried to copy the code from a few other sources that have an example code but still got this message.
I would appreciate any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它可能会帮助您查看COBOL专用IDE中代码的外观。这是直接副本& OpenCobolide中的代码粘贴:
主要问题是代码在第2至5行上的位置。COBOL通常要求您的代码非常具体格式化,正如您可以从上面的红线中看到的那样,有限制数据应该存在的位置。可以更改这一点,但我建议与之保持一致,因为这可能会增加您在使用世界的旧版代码方面的舒适感。这是应该写这本书的示例。我将同时共享图片和代码本身,以便您可以看到与这些红线有关的位置。
与错误有关的代码仍然显示为示例:
没有错误的工作代码:
一定要查看 Opencobolide 这是开始COBOL并降低基础知识的绝佳自由IDE!当我新来时,它帮助我更好地处理了格式化。
It might help you to see what your code looks like in a purpose-made IDE for COBOL. Here is a direct copy & paste of your code in OpenCobolIDE:
The main issue is the position of the code on lines 2 through 5. COBOL generally will require your code to be very specifically formatted, as you can see from the red lines above, there are limits to where data should exist. This can be changed, but I recommend keeping with it as this may increase your comfort in working with the legacy code that runs the world. Here is an example of how this should be written. I will share both a picture and the code itself so you can see where it is in relation to those red lines.
Code with errors still to show as an example:
Working code with no errors:
Definitely check out OpenCobolIDE which is a great free IDE for getting started with COBOL and getting the basics down! It helped me to get a better handle on formatting when I was new.