dick scherrer wrote:w does this "solution" help if the requirement is Easytrieve?
It is an Easytrieve Plus macro.
%MOD whole-number base-to-divide-by(also whole number) remainder (also whole number, so actually modulus) QUOTIENT what-the-quotient-was
This is if you named it "MOD" when putting it in the macro library.
It has three positional parameters and one keyword parameter. With a keyword parameter, you can specify a default on the macro definition.
The macro can be used at more than one location in the code, despite the fact that it DEFINEs some storage (outside of the "library" part of the program). The first physical occurence of the MACRO in the source is the one where the definition of the storage actually takes place (check on the DMAP, if requested on the PARM).
You don't have to be in a MACRO to DEFINE storage, by the way, but obviously outside a MACRO it should be used with some care, as it may not be apparent to the person stuck with maintaining the program where the field is...
Of course, you could screw it up if you give it decimal numbers with non-zero decimal parts, but that would just be abusing the whole concept (modulus would only mean modulus in whole-number arithmetic). Thus, some argument for "bullet-proofing" in the macro, so you could check for non-zero decimal part... and then what, well, abend if you wanted to I suppose. I think the macro is fine like this as long as its use is documented, which would be enough CYA.
Nice, Zio69.