嵌套条件语句中的点规则-COBOL [英] Dot rules in nested conditional statements - COBOL

查看:149
本文介绍了嵌套条件语句中的点规则-COBOL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人可以向我解释COBOL嵌套IF语句中的点规则.示例:

I'm wondering if anybody can explain to me the dot ruling in nested IF statements in COBOL. Example:

*The first if statement*
 IF SUCCESSFUL-STATUS 
     PERFORM 8300-REPL-LNNTBI00 
        THRU 8300-REPL-LNNTBI00-EXIT 
*The second if statement*
        IF SUCCESSFUL-STATUS 
            DISPLAY 'RECORD ALREADY UPDATED :' WS-INF-REC
        ELSE 
            DISPLAY 'UPDATE ERROR : ' WS-INF-REC ' / ' 
            WS-RETURN-STATUS 
 READ INFILE INTO WS-INF-REC.   

"WS-INF-REC"之后的点属于哪个if语句?第一个IF或第二个IF-ELSE?我知道在大多数编程中,它应该用于最后的if语句,但只是要确保对COBOL是否相同?

Which if statement does the dot placed after "WS-INF-REC" belong to? The first IF or the second IF-ELSE? I know that in most programming, it should be for the last if statement but just to make sure, is it the same for COBOL?

推荐答案

句点字符."结束所有if语句.请记住,编译器会忽略间距,因此READ语句是第二个IF语句的ELSE的一部分.

The period character "." ends all if statements. Remember that spacing is ignored by the compiler so therefore the READ statement is part of the ELSE of the second IF statement.

我们人类希望看到逻辑上使用的缩进.而且,如果是我,我会明确说明目标.我通常每段都有一个句点:

Us humans want to see the indentation used logically. And, if it were me, I would make the end-if's be explicit. I tend to have one period per paragraph:

* The first if statement *
     IF SUCCESSFUL-STATUS 
       PERFORM 8300-REPL-LNNTBI00 
         THRU 8300-REPL-LNNTBI00-EXIT 
* The second if statement*
       IF SUCCESSFUL-STATUS 
         DISPLAY 'RECORD ALREADY UPDATED :' WS-INF-REC
       ELSE 
         DISPLAY 'UPDATE ERROR : ' WS-INF-REC ' / ' 
           WS-RETURN-STATUS 
         READ INFILE INTO WS-INF-REC
       END-IF
     END-IF
     .

这篇关于嵌套条件语句中的点规则-COBOL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆