是 --- Cobol 图片有效

发布于 2024-12-08 03:47:47 字数 166 浏览 1 评论 0原文

我正在对 Cobol 图片进行一些测试,想知道 --- 是否是有效的图片。我说的对吗,这张图片接受 -99 到 +99 范围内的值。如果有效,那么图片是否可以接受 3 个空格作为值?

例如:

12 将返回 12
1 会返回 1

干杯

I'm running some tests on Cobol pictures and wondering if --- is a valid picture. Am I right in saying that this picture accepts values in the range of -99 through to +99. If it is valid then it is possible for the picture to accept 3 spaces as a value?

For example:

12 would return 12
1 would return 1

Cheers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北音执念 2024-12-15 03:47:47

是的 --- 是有效的 PICTURE 子句。与此 PICTURE 对应的变量将接受 -99 到 +99 范围内的数值分配。不能为其分配非数字(例如空格)。但是,如果您在为该变量分配数值后DISPLAY,则前导零将被空格替换。因此,如果您MOVE ZERO 到此项目,它将仅DISPLAY 空格。尝试MOVE SPACES到此项将导致编译错误(数据类型不兼容)。最后一点可能看起来有点违反直觉,但请记住,这种类型的 PICTURE 子句意味着显示的 USAGE 基本上以这种方式定义的项目用于“漂亮打印” ' 数字。您可以使用 USAGE DISPLAY 项目执行的唯一操作是向它们MOVE 或从它们DISPLAY 进行操作。

编辑 - 对评论的回复

---X(2)PICTURE 无效。下图说明了符号在 PICTURE 字符串中可能出现的组合和顺序。请注意,括号不在图表中。从逻辑上讲,您可以在读取字符串之前将它们替换为前面字符出现的相应次数。例如,X(3) 读作 XXX。如果你确实想正确解析出PICTURE字符串,你可以使用这个图表专门为它们构造一个BNF语法。

在此处输入图像描述

Yes --- is a valid PICTURE clause. The variable corresponding to this PICTURE will accept assignments of numeric values in the range -99 through to +99. It cannot be assigned non-numerics (space for example). However, if you were to DISPLAY this variable after assigning a numeric value to it, leading zeros will be replaced by spaces. Consequently, if you MOVE ZERO to this item it will DISPLAY only spaces. Attempting to MOVE SPACES to this item will result in a compile error (incompatible data types). This last bit may seem a little counter intutive, but remember that this type of PICTURE clause implies a USAGE of display - basically items defined in this manner are used to 'pretty print' numbers. About the only operations you can preform with USAGE DISPLAY items is MOVE to or from and DISPLAY them.

EDIT - Response to Comment

A PICTURE of ---X(2) is invalid. The chart below illustrates combinations and the order that symbols may appear in a PICTURE string. Notice that parenthesis are not in the chart. Logically you can replace them with the corresponding number of occurences of the preceding character before reading the string. For example X(3) is read as XXX. If you really want to parse out a PICTURE string properly, you can use this chart to construct a BNF grammar specifically for them.

enter image description here

女皇必胜 2024-12-15 03:47:47

如果这是数字图片,则不接受空格。

If this is a numeric picture, it won't accept spaces.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文