`
cuiyadll
  • 浏览: 203915 次
文章分类
社区版块
存档分类
最新评论

COBOL PERFORM A THRU A EXIT笔误 COMPUTE +或- 笔误 结果分析

阅读更多
1、COMPUTE A = + B,A = - B 一般为笔误,执行结果:A的值等于|B|。
测试:
MOVE 5 TO WK-INPUT
MOVE 5 TO WK-OUTPUT
或者
MOVE -5 TO WK-INPUT
MOVE -5 TO WK-OUTPUT
COMPUTE WK-OUTPUT = + WK-INPUT
执行结果:WK-OUTPUT结果为5.
COMPUTE WK-OUTPUT = - WK-INPUT
执行结果:WK-OUTPUT结果为5.

2、THRU笔误:编译测试均通过
以下包括THRU执行流程、THRU笔误执行测试。
如下笔误:
……                                                          ==> 该部分代码正常执行
PERFORM XXXX-TEST-PREFORM
   THRU XXXX-TEST-PREFORM EXIT  ==> 红色字为COBOL关键字 不执行XXXX-TEST-PROFORM-EXIT
……                                                          ==> 该部分代码正常执行
XXXX-TEST-PROFORM-EXIT.
    EXIT.
上述语句编译成功,不影响正常程序流,程序执行步骤完全一致,所有测试全部通过。
EXIT语句,其实就是标识而已,不起作用。

若XXXX-TEST-PROFORM-EXIT写法如下,执行结果会有很大不同。若写法如下,可能是程序退出点,但因为未正确书写“THRUXXXX-TEST-PROFORM-EXIT”,则程序不会执行该段,导致程序无法退出。
XXXX-TEST-PROFORM-EXIT.
    GOBACK./STOP RUN.

测试程序如下:
PROCEDURE DIVISION.                                       
*                                                          
MAIN-ROUTINE.                                             
*                                                          
     DISPLAY 'MAIN ROUTINE START'.                         
*                                                          
     PERFORM A-ROUTINE                                     
        THRU A-ROUTINE-EXIT                                
*                                                          
     DISPLAY '== START EXEC A-C ROUTINE =='.               
     PERFORM A-ROUTINE                                     
        THRU C-ROUTINE-EXIT                                
     DISPLAY '== END EXEC A-C ROUTINE =='.                 
*                                                          
     PERFORM B-ROUTINE                                     
        THRU B-ROUTINE-EXIT                                
*                                                          
     PERFORM C-ROUTINE                                     
        THRU C-ROUTINE EXIT                                
     DISPLAY 'C-ROUTINE EXIT IN MAIN'.                     
*                                                          
     PERFORM C-ROUTINE                                     
        THRU C-ROUTINE-EXIT                                
     DISPLAY 'C-ROUTINE-EXIT IN MAIN'.                
*                                                     
     PERFORM D-ROUTINE                                
        THRU D-ROUTINE-EXIT                           
*                                                     
     DISPLAY 'MAIN ROUTINE END'.                      
MAIN-ROUTINE-EXIT.                                   
     STOP RUN.                                        
*                                                     
A-ROUTINE.                                           
     DISPLAY 'EXEC A ROUTINE'.                        
A-ROUTINE-EXIT.                                      
     DISPLAY 'EXEC A ROUTINE EXIT'.                   
     EXIT.                                            
*                                                     
B-ROUTINE.                                           
     DISPLAY 'EXEC B ROUTINE'.                        
B-ROUTINE-EXIT.                                      
     DISPLAY 'EXEC B ROUTINE EXIT'.                   
     EXIT.                                            
*                                                     
C-ROUTINE.                                           
     DISPLAY 'EXEC C ROUTINE'.                        
C-ROUTINE-EXIT.                        
     DISPLAY 'C-ROUTINE-EXIT IN C'.     
     EXIT.                              
*                                       
D-ROUTINE.                             
     DISPLAY 'EXEC D ROUTINE'.          
D-ROUTINE-EXIT.                        
     DISPLAY 'EXEC D ROUTINE EXIT'.     
     EXIT.                              
*                                      

执行结果如下:
MAIN ROUTINE START         
EXEC A ROUTINE             
EXEC A ROUTINE EXIT        
== START EXEC A-C ROUTINE ==
EXEC A ROUTINE             
EXEC A ROUTINE EXIT        
EXEC B ROUTINE             
EXEC B ROUTINE EXIT        
EXEC C ROUTINE             
C-ROUTINE-EXIT IN C        
== END EXEC A-C ROUTINE == 
EXEC B ROUTINE             
EXEC B ROUTINE EXIT        
EXEC C ROUTINE             
C-ROUTINE EXIT IN MAIN     
EXEC C ROUTINE             
C-ROUTINE-EXIT IN C        
C-ROUTINE-EXIT IN MAIN     
EXEC D ROUTINE             
EXEC D ROUTINE EXIT        
MAIN ROUTINE END          

转自:http://hi.baidu.com/clisdena/item/01857711271c686c70d5e8d0

3,
       IDENTIFICATION DIVISION.
       PROGRAM-ID. PGM012.
       AUTHOR. MAINFRAMEWIZARD.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 WS-SUB PIC 9(3) VALUE ZEROS.
       PROCEDURE DIVISION.
       10000-MAIN-PARA.
             PERFORM 20000-FIRST-PARA THRU 30000-THIRD-PARA
             DISPLAY 'DEPICTING PERFORM THRU BY MAINFRAMEWIZARD.COM'
             DISPLAY 'PARA NAME IS  10000-FIRST-PARA'
             STOP RUN.
       20000-FIRST-PARA.
             DISPLAY 'PARA NAME IS  20000-FIRST-PARA'.
       25000-SECOND-PARA.
             DISPLAY 'PARA NAME IS  25000-SECOND-PARA'.
       30000-THIRD-PARA.
             DISPLAY 'PARA NAME IS  30000-THIRD-PARA'


Output of the above program is as below



PARA NAME IS  20000-FIRST-PARA                                                                                          
PARA NAME IS  25000-SECOND-PARA                                                                                         
PARA NAME IS  30000-THIRD-PARA                                                                                          
DEPICTING PERFORM THRU BY MAINFRAMEWIZARD.COM                                                                           
PARA NAME IS  10000-FIRST-PARA                                     
- See more at: http://www.mainframewizard.com/content/cobol-perform-thru#sthash.SBBE20eI.dpuf
分享到:
评论

相关推荐

    Cobol程序实例运用

    - **显示结果**:排序后,通过`PERFORM A-ST THRU A-SE VARYING Q FROM 1 BY 1 UNTIL P = 0`循环显示删除后的链表。 **2. 关键代码解释** - **PERFORM DEL THRU E-D UNTIL DEL-DATA = 99**:用于从链表中删除元素...

    MS-COBOL2.1

    6. **控制流程**:COBOL提供了一系列控制流程语句,如IF-THEN-ELSE、PERFORM、THRU等,用于实现条件判断、循环和其他控制逻辑。 7. **子程序与链接**:MS-COBOL 2.1 支持子程序(Subprogram)的概念,可以通过`...

    谭浩强COBOL_A

    谭浩强COBOL_A 谭浩强COBOL_A谭浩强COBOL_A谭浩强COBOL_A谭浩强COBOL_A谭浩强COBOL_A

    后端研发-Notepad++-高兼容的代码编辑及查看工具

    Notepad++自带中文,支持众多计算机程序语言: C,C++,Java,pascal,C#,XML,SQL,HTML,PHP,ASP, 汇编, DOS批处理, Caml, COBOL, Cmake, CSS,ActionScript, Fortran, Gui4Cli, Haskell, INNO, JSP, KIXtart, LISP, Lua, ...

    cobol语言入门------

    cobol语言入门cobol语言入门------------

    cobol学习资料

    - IF...THEN...ELSE、PERFORM、THRU、WHEN、AT...OF等语句用于流程控制。 - GOTO语句虽然存在,但在现代编程实践中不推荐使用,因为它可能导致难以维护的代码。 5. **文件操作** - 在COBOL中,文件处理是核心...

    c++和Java和C#和Cobol代码规范

    | | +-- BPublicClass.h | +-- module2 |-- src | |-- module1 | | |-- Makefile | | |-- BPublicClassImpl.h | | |-- BPublicClassImpl.cc | | +-- BPublicClass.cc | +-- module2 |-- test | |-- module1 | | +-- ...

    cobol常见面试题

    `IF`、`EVALUATE`和`WHENEVER`用于条件控制,`GOTO`用于无条件跳转,`EXIT`语句用于提前退出程序段或循环。 5. **字符串操作**: - `STRING`指令用于将一个字符串复制到另一个字符串,支持指定起始位置和长度。`...

    cobol 考试题

    - **(1)** `MOVE -1 TO WK-A`:将-1移动到`WK-A`中,由于`WK-A`定义为`Z99`,所以`WK-A`的值为`-01`。 - **(2)** `MOVE 7890 TO WK-A`:尝试将7890移动到`WK-A`中,但`WK-A`只能容纳两位数字,因此溢出,实际...

    cobol语言----总结篇

    COBOL,全称Common Business Oriented Language,是一种专门针对商业应用设计的编程语言,尤其在数据管理和商业数据处理领域有着广泛的应用。由于其语法结构接近英语,理解相对容易,因此也被誉为“用于管理的语言”...

    COBOL-85简明教程

    "COBOL-85简明教程" COBOL-85 简明教程是 COBOL 编程语言的入门指南,旨在帮助读者快速掌握 COBOL 编程的基础知识。下面是该教程的概要: COBOL 语言简介 COBOL 语言的历史可以追溯到 1960 年,最初是由 CODASYL...

    Cobol冲入门到精通代码

    - Cobol有丰富的流程控制语句,如IF-THEN-ELSE,PERFORM,THRU,GOTO等,以及条件和循环结构。 - 使用WORKING-STORAGE SECTION来声明和管理临时变量。 6. **文件操作** - Cobol在数据处理上表现出色,支持顺序...

    COBOL-学习-总结

    ### COBOL学习总结 #### 一、简介 近期为了更好地进行后台编程工作,我们开始深入研究COBOL语言的相关知识,并对其中一些实用的语法进行了归纳总结。本文旨在帮助团队成员快速掌握这些要点,从而在实际编程过程中...

    cobol

    5. **控制流程**:COBOL支持条件语句(IF-THEN-ELSE)、循环(PERFORM)和分支(GO TO)。例如,一个简单的条件判断: ```cobol IF EMPLOYEE-AGE > 60 DISPLAY "Employee is eligible for retirement." ELSE ...

    cobol教程--总结篇

    ### COBOL教程知识点详述 #### COBOL语言概览 COBOL,全称Common Business Oriented Language,是一种面向商业数据处理的高级编程语言。由于其在数据管理和处理领域的广泛应用,COBOL也被誉为“管理者的语言”。该...

    1cobol案例分析

    【Cobol案例分析】——银行计算机系统建设 在银行计算机系统建设中,Cobol(COmmon Business Oriented Language)是一种常见的编程语言,因其在处理事务处理系统(如银行系统)上的强大功能和稳定性而被广泛使用。...

    CHAPTER 9 COBOL-II 编程规范

    - 利用COBOL的内置功能,如使用COMPUTE或MOVE CORRESPONDING简化操作。 8. **测试与调试**: - 编写单元测试,确保每个模块的功能正确。 - 使用调试工具,如IBM的TDA(Transaction Development Assistant),...

    COBOL85日文版本

    4. **输入/输出(I/O)处理**:COBOL85提供了丰富的I/O语句,如ACCEPT和DISPLAY,用于从终端接收用户输入或者将结果显示在终端上。此外,还可以通过FILE-CONTROL和FILE-STATUS来管理文件的打开、关闭和错误处理。 5...

Global site tag (gtag.js) - Google Analytics