|
Not directly - there is no equivalent to the %parms built-in-function. However, there may be an MI eqivalent. Another option is to attempt to do something with each parameter and MONMSG for the relevant MCH* error (MCH3601? I can't remember)...
The problem with this is that you're expecting memory that your program doesn't own or control to always be *NULL.
Remember, the caller doesn't actually know how many parameters you're expecting. It sends you a number to indicate the number of parameters, and it sends you addresses of each parameter. It doesn't set the address of your optional parameters to *NULL. Why? Because it doesn't know how many parameters it's supposed to give you. (Unless, of course, you specify *OMIT for them all)
If your program expects 4 parameters, and the caller only passed 3 of them, what it does is pass you the number 3, followed by 3 addresses. What happens if you try to read the 4th parameter? Hard to say, because there ISN'T a 4th parameter. You'll be accessing whatever happened to be in memory after the 3rd one.
It _might_ be null, and it might not be. It might be a valid address, and it might not be.
You should never reference parameters past the number that were passed to you. If there's no way to find out how many parms were passed to a CL program (which, so far, seems to be the consensus) then either add code that solves that problem (such as passing the number of parms as an additional parameter) or always call it with all of the parameters.
RPG programs are exactly the same, with the single exception that you cal check %parms in RPG to find out how many you received.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.