是 --- Cobol 图片有效
我正在对 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的
---
是有效的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 validPICTURE
clause. The variable corresponding to thisPICTURE
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 toDISPLAY
this variable after assigning a numeric value to it, leading zeros will be replaced by spaces. Consequently, if youMOVE ZERO
to this item it willDISPLAY
only spaces. Attempting toMOVE 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 ofPICTURE
clause implies aUSAGE
of display - basically items defined in this manner are used to 'pretty print' numbers. About the only operations you can preform withUSAGE DISPLAY
items isMOVE
to or from andDISPLAY
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 aPICTURE
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 exampleX(3)
is read asXXX
. If you really want to parse out aPICTURE
string properly, you can use this chart to construct a BNF grammar specifically for them.如果这是数字图片,则不接受空格。
If this is a numeric picture, it won't accept spaces.