在非循环程序中设置 *inlr 有什么影响吗?

Does seting *inlr in non-cycle programs has any effect?

我最近偶然发现了一个服务程序,其中 *inlr = *on 在显式关闭文件后使用(下面的代码)。对我来说感觉有点过分了。据我发现,处理资源释放的是 rpg 循环。因此,如果没有循环(即在具有 main/nomain h-specs 的程序中),则 *inlr = *on 无法产生任何效果,但是......我无法找到任何确认,由于与周期相关的问题对我来说很新,我可能会遗漏一些东西...

if %open(file);      
  close file;        
endif;                  
*inlr = *on;            
return *on; 

简而言之

"last record" 指标仅供周期使用。它不用于 NOMAIN 服务程序或线性 MAIN 程序。

RPG IV Programmer's Guide 表示

Note No cycle code is generated for subprocedures or when MAIN or NOMAIN is specified on the control specification.

其他参考文献
IBM 的 Barbara Morris(RPGLE 编译器开发人员,post to the RPG mailing list

The linear-main procedure will just end when it gets to the end of the calculations. You can set on *INLR if you want, but it won't do any of the cycle-related things like closing files.

Here is a comparison of a cycle-main module and a linear-main module.http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=%2Frzasd%2Fsc09250802.htm "

在线性主模块或 nomain 模块中,*inlr 无效。据我所知,没有关于此的明确文档,但第 4 页的 ILE RPG Programmer's Guide 指出

Note: No cycle code is generated for subprocedures or when MAIN or NOMAIN is specified on the control specification.

由于检查 *inlr 是循环的一部分,因此推断没有功能

试试这个:

cl程序调用rpg程序

    pgm
    call testlrr
    call testlrr
    call testlrr
    endpgm

那么这个是角色扮演游戏

    ctl-opt  dftactgrp(*no) actgrp('QILE');

    dcl-pr TESTLRR   extpgm('TESTLRR');
    end-pr;

    dcl-pi TESTLRR;
    end-pi;

    dcl-s counter      zoned(5:0);

    counter = counter + 5;

    dsply counter;

    return;            

您会看到变量的值在后续调用中继续递增。

是的...您可以通过激活组、inz 语句等来处理它...但是 *inlr 非常便宜且非常简单。