- 论坛徽章:
- 0
|
回复 15# passthru
一
这里说,FILE,I-SPEC,DATA AREA等都是可以在subprocedure中使用的。只不过要在main section中定义。”
这里main procedure就不是subprocedure。subprocedures是nomain。
我之前没说清楚。我想说的是F表要在main source section中有定义,并没说一定要在main procedure中定义。main source section和main procedure是两码事。
main source section是指H表和P表之间的内容,按照H, F, D, I, C, O的顺序依次定义的各表。如果定义H NOMAIN的话,那么这个module就没有main procedure。在main source section定义的各表,就可以被module中所有的subprocedure使用。
再贴一段red book的解释:
The NOMAIN keyword on the H spec is used if there is no mainline logic in this
module. That is to say that the only C specs are those in the subprocedures.
Note that the F specs always go at the beginning of the member, just after the
H spec. These files can be used, either by the mainline code and/or by the
subprocedures. Even if there is no main line logic, the F specs must always be
defined at the beginning of the module. By definition then, all fields defined in
files are global in nature.
二。我之前说的《A Sorcerer’s Guide to System Access andMore》应该算作IBM 官方的red book吧,因为我是从IBM官方网站上下的。
全称叫做:《Who Knew You Could Do That with RPG IV? A Sorcerer’s Guide to System Access and More》
三 贴一段代码,我今天测试的,可以正常调用,并且15编译没有报10级错误。
- H NOMAIN
- FABC O E DISK
- D SUBF PR
- D 10A
- P SUBF B EXPORT
- D SUBF PI
- D P1 10A
- C IF NOT %OPEN(ABC)
- C OPEN ABC
- C ENDIF
- C EVAL F1 = P1
- C WRITE ABCR
- C EVAL *INLR = *ON
- C CLOSE ABC
- C RETURN
- P E
-
- DDS:
- A R ABCR
- A F1 10A
复制代码
以上只是想弄清楚subprocedure的用法,欢迎交流。
谢谢
|
|