《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的设置这个位置的作用是返回调用程序一个例外信息。
阅读(990) | 评论(0) | 转发(0) |