在 INSPECT 子句中使用变量
我正在尝试使用 INSPECT 子句来查看名称 (PIC X) 是否包含某个子字符串。
当我使用
INSPECT NAME TALLYING COUNTER FOR ALL "lee"
该程序按预期工作时,
当我用变量替换“lee”时,该命令找不到任何内容。
...
WORKING-STORAGE SECTION.
01 ZOEKTERM PIC X(40).
...
MOVE "lee" TO ZOEKTERM
INSPECT NAAM TALLYING COUNTER FOR ALL ZOEKTERM
谁能解释为什么会发生这种情况以及我能做些什么?
I'm trying to use the INSPECT clause to see if a name (PIC X) contains a certain substring.
When I use
INSPECT NAME TALLYING COUNTER FOR ALL "lee"
The program works as expected,
When I replace the "lee" with a variable the command doesn't find anything.
...
WORKING-STORAGE SECTION.
01 ZOEKTERM PIC X(40).
...
MOVE "lee" TO ZOEKTERM
INSPECT NAAM TALLYING COUNTER FOR ALL ZOEKTERM
Can anyone explain why this is happening and what I can do about it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
解决方法是明确指定长度。
The fix is to explictly specify the length.
文字“lee”的长度为 3 个字符,而 ZOEKTERM 的长度为 40 个字符。
这会影响它们可以匹配的子字符串。
The literal 'lee' is three characters long, while the ZOEKTERM is 40 characters long.
That affects the substrings they can match.
博·佩尔森是正确的。如果您阅读了 中的“比较周期”文档,你会看到
Bo Persson is correct. If you read the "Comparison cycle" in the documentation, you will see