Q: I am writing procedures to look up and return names and so forth, based on a customer number that is passed in. Here's my problem: When I define the procedure interface, I want to define the return value with LIKE so that if the field definition changes all I have to do is recompile the programs. Otherwise, I have to go in and change the hardcoded return lengths. Can I use LIKE or something similar so that I don't have to modify the code for file changes?
I've tried LIKE and the compiler says "not expecting a return value for procedure." I copied a working procedure and prototype and then changed to LIKE, so I'm pretty sure I have everything-besides the LIKE part-defined correctly.
A: If I understand your problem, you have a procedure called, say, RtvName defined as in Figure 6, and you would like to use it as shown in Figure 7. To replace the 50A definition with LIKE(CustName), an alternative approach is to define RtvName as illustrated in Figure 8. Then, use RtvName as seen in Figure 9.
- John V. Thompson
Figure 6: Procedure RtvName
D RtvName PI 50A
D Cust# 7P 0 value C eval CustName = RtvName(Cust#)
D RtvName PI
D CustName@ * value
Figure 7: The way you want to use RtvName
Figure 8: An alternative method of defining RtvName
D Cust# 7P 0 value *
* Local variables
D Name S like(CustName) based(CustName@)
C callp RtvName(%addr(CustName):Cust#)
LATEST COMMENTS
MC Press Online