in reply to My first module
The OP calls for a scalar value. Your suggested correction using an array rather than a scalar is either only a partial answer, or is wrong. Look at the other replies to see better solutions to OP's problem.