You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request: AddParameterInd() - for indicator parameters. #221
If you use AddParameterZoned() when the parameter is a zoned field, and you use AddParameterChar() when the parameter is a character field, doesn't it make sense that when adding a Parameter that is an indicator (boolean), you use AddParameterInd() function?
This would be especially useful for functions in a *SRVPGM that have an indicator return value (e.g. to indicate success or not).
I think this code might work and allow flexibility for what values you use to set the value. It would even allow for passing an array of indicators.
I'd be happy to create the pull request, etc. if somebody was willing to help me do that (I've never done it before).
staticfunctionAddParameterInd($io, $comment, $varName = '', $value = '', $dimension = 0,
$by = '', $isArray = false, $ccsidBefore = '', $ccsidAfter = '', $useHex = false
) {
// on/*on/yes/true/1/'1' becomes '1'// off/*off/no/false/0/'0' and anything else (e.g. 'x') becomes '0'// trim off any leading "*" character, and convert to lower-case, then let `filter_var` set the value$value = (filter_var(
ltrim( strtolower( (string) ($value ) ), '*' ),
FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE
) ?? false) ? '1' : '0';
// these two parms are needed for CharParam, but are removed from param list for this function$varying = 'off'; // can't have a varying indicator$size = '1'; // indicator is always '1' or '0' returnnewCharParam(
$io, $size, $comment, $varName, $value, $varying, $dimension, $by,
$isArray, $ccsidBefore, $ccsidAfter, $useHex
);
}
Activity
alanseiden commentedon May 5, 2025
Thank you. This suggestion would make it easier for people using the indicator type.