Chinaunix首页 | 论坛 | 博客
  • 博客访问: 25030
  • 博文数量: 7
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 25
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-17 14:30
文章分类

全部博文(7)

文章存档

2013年(7)

我的朋友

分类:

2013-04-03 11:28:26

原文地址:extproc和extpgm的区别 作者:niuhua77

1.调用对象

       Extprocmain proceduresubprocedure

       ExtpgmOPMILE *pgm

 

2.调用性质:

       Extproc:静态调用

       Extpgm:动态调用

 

3.传参方式:

       Extprocby referenceby read-only referenceby value

       Extpgmby referenceby read-only reference

 

4.示例:

Extpro Demo:

 

pass1.rpgle

HNOMAIN                                           

 /INCLUDE QCPYSRC,PASSBY                   

P BYVALUE         B                   EXPORT     

D BYVALUE         PI            40A              

D  PARM1                            2P 0            

D  PARM2                            20A   VALUE      

C                   IF        PARM1 = 1          

C                   RETURN    PARM2+'LIKE RPG III'

C                   ELSE                         

C                   EVAL      PARM2 = 'LIKE RPG' 

C                   RETURN    PARM2+'LIKE RPG IV'

C                   ENDIF                        

P                 E                              

 

pass2.rpgle

D AAA             PR            40A   EXTPROC('BYVALUE') 

D  A1                            2P 0                    

D  A2                           20A   VALUE            

D NUM             S              2P 0                    

D STRING          S             20A   INZ('KKK')         

D RESULT1         S             30A                      

C                   EVAL      NUM = 1                 

C                   EVAL      RESULT1 = AAA(NUM:STRING)

C     RESULT1       DSPLY                             

C                   EVAL      *INLR = *ON   

C                   RETURN                         

 

 

Extpgm Demo

 

DDS CODE:

A..........T.Name++++++RLen++TDpB......Functions+

A          R ABCR                               

A            F1            10A                  

 

 

RPG CODE

FFilenameIPEAF........L..I........Device+......KExit++Entr

FABC     O   E                    DISK                    

C           *ENTRY    PLIST                              

C                     PARM           MLNAME 10           

C                     MOVELMLNAME    F1                  

C                     WRITEABCR                          

C                     SETON                     LR       

C                     RETRN                              

 

 

RPGLE CODE

DTESTADD          PR                  EXTPGM('ADD')           

D                               10A                           

D PASSSTYLE       PR                                          

D  P2                           10A                                             

D PASSSTYLE       PI                                          

D P2                            10A                           

D P1              S             10A                                            

C                                                              

C                   CALLP     TESTADD(P2)                     

C                   EVAL      *INLR = *ON                     

C                   RETURN                                    

 

阅读(834) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~