Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1062012
  • 博文数量: 106
  • 博客积分: 9093
  • 博客等级: 中将
  • 技术积分: 2770
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-01 17:22
文章分类

全部博文(106)

文章存档

2014年(1)

2012年(29)

2011年(32)

2010年(20)

2008年(24)

分类: 系统运维

2012-08-03 14:05:38

RPGLE的分支语句有If- ElseIf- Else-EndIf, Select-When-Other-EndSl。 还有几个只能用在RPGLE固定格式中的分支语句:CABxxCABxxTAG结合使用;CASxxCASxx和子程序(Subroutine)一起使用。

    RPGLE的循环语句有Do-EndDofree格式不支持Do循环,使用For来代替),DoW(xx)-EndDoDoU(xx)-EndDoFor-EndFor。跳出循环的语句有LeaveIterLeave就是跳出整个循环,而Iter是跳出本次循环。

EX10

0001.00 D True            S               N   Inz('1')                 

0002.00 D i               S              5U 0 Inz(1)                   

0003.00 D Result          S             10A   Inz                       

0004.00 D Wait            S              1A                            

0005.00 C*                                                             

0006.00 C                   DoW       True                             

0007.00 C                   If        i = 1                            

0008.00 C     'One'         Dsply                                      

0009.00 C                   ElseIf    i = 2                            

0010.00 C     'Two'         Dsply                                       

0011.00 C                   else                                       

0012.00 C                   Eval      Result = %char(i) + ' leave'     

0013.00 C     Result        Dsply                                      

0014.00 C                   Leave                                      

0015.00 C                   EndIf                                      

0016.00 C                   Eval      i = i + 1                        

0017.00 C                   EndDo                                       

0018.00 C*                                                             

0019.00 C                   For       i = 1 to 5                       

0020.00 C                   Select                                     

0021.00 C                   When      i = 3                            

0022.00 C     'Three'       Dsply                                      

0023.00 C                   When      i = 4                            

0024.00 C     'Four'        Dsply                                       

0025.00 C                   Other                                      

0026.00 C                   Eval      Result = %char(i) + ' iter'      

0027.00 C     Result        Dsply                                      

0028.00 C                   Iter                                       

0029.00 C                   EndSl                                      

0030.00 C                   EndFor                                     

0031.00 C*                                                              

0032.00 C     'Complete'    Dsply                   Wait               

0033.00 C*                                                             

0034.00 C                   Eval      *inlr = *on                      

0035.00 C                   Return   


EX10F

0001.00 D True            S               N   Inz('1')   

0002.00 D i               S              5U 0 Inz(1)     

0003.00 D Result          S             10A   Inz        

0004.00 D Wait            S              1A              

0005.00  /free                                           

0006.00    DoW True;                                     

0007.00      If i = 1;                                   

0008.00        Dsply 'One';                              

0009.00      ElseIf i = 2;                               

0010.00        Dsply 'Two';                              

0011.00      Else;                                       

0012.00        Result = %char(i) + ' leave';             

0013.00        Dsply Result;                             

0014.00        Leave;                                    

0015.00      EndIf;                                      

0016.00      i = i + 1;                                   

0017.00    EndDo;                                        

0018.00                                                  

0019.00    For i = 1 to 5;                               

0020.00      Select;                                     

0021.00        When  i = 3;                              

0022.00          Dsply 'Three';                          

0023.00        When  i = 4;                              

0024.00          Dsply 'Four';                           

0025.00        Other;                                     

0026.00          Result = %char(i) + ' iter';            

0027.00          Dsply Result;                           

0028.00          Iter;                                   

0029.00      EndSl;                                       

0030.00    EndFor;                                       

0031.00                                                  

0032.00    Dsply 'Complete' '' Wait;                     

0033.00                                                  

0034.00    *inlr = *on;                                  

0035.00    return;                                       

0036.00  /end-free 

你应该看到的内容

加分练习

1.      在分支语句中如何测试多个判断子句,试一试And(xx), Or(xx)

2.      验证一下CABxxCASxxDoU(xx)的用法

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