Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1270423
  • 博文数量: 287
  • 博客积分: 11000
  • 博客等级: 上将
  • 技术积分: 3833
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-16 08:43
文章分类
文章存档

2013年(15)

2012年(17)

2011年(17)

2010年(135)

2009年(85)

2008年(18)

分类: 系统运维

2009-04-05 21:29:12

《RPGIV编程问题百解(7)-原型参数传递问题》
 
 
提问:
I have a procedure that had a parameter defined using OPTIONS(*varsize) and a
length of 10.  If the calling program passed a value in a field that is 10-
bytes long it worked, but if the program passed a 1-byte field it passed the
value followed by a bunch of garbage.
 
I added the VARYING keyword and that seemed to fix it.  However, now it blows
up when another program passes a 1-byte value in a 20-byte field. 
 
Should I have used the *TRIM option to fix the original problem?  I have not
used this option since it was added to the last release.
 
答案:
 
答1)
P Testprc         B
D                 PI
D   Testvar            30    Const Option(*VarSize:*omit:*OpDesc)
 
答2)   
P Testprc         B                
D                 PI         OPDESC
D   Testvar            30    Const Option(*VarSize)
 
要点:
1)如果用*VARSIZE,需用const选项;

2)如果用*VARSIZE,原型参数多于设置的长度,需用OPDESC选项;

3)如果使用*omit选项用在PI中的原型参数中,当传递参数少于设定的原型参数的长度,*omit的设置这个位置的作用是返回调用程序一个例外信息。
阅读(959) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~