Difference between revisions of "Is Numeric"
From MidrangeWiki
DaveLClarkI (talk | contribs) |
DaveLClarkI (talk | contribs) (→Summary) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
The following are the RPG/LE fully free-form definitions and instructions needed for using the {{AN}} service procedure. This service procedure simply allows the caller to validate that a character string is all numeric digits, decimal, and/or sign characters—or not. | The following are the RPG/LE fully free-form definitions and instructions needed for using the {{AN}} service procedure. This service procedure simply allows the caller to validate that a character string is all numeric digits, decimal, and/or sign characters—or not. | ||
{| class="wikitable" | {| class="wikitable" | ||
− | |+Rule of Thumb | + | |+ style="padding-left:6px;text-align:left;"|Rule of Thumb |
|- | |- | ||
|Sometimes, having a service procedure is simply a means of making code more self-documenting (i.e., easier for others to understand). | |Sometimes, having a service procedure is simply a means of making code more self-documenting (i.e., easier for others to understand). | ||
|} | |} | ||
+ | |||
+ | By [[User:DaveLClarkI|Dave Clark]] | ||
== Service Prototype == | == Service Prototype == | ||
Line 27: | Line 29: | ||
<pre> | <pre> | ||
**free | **free | ||
+ | ctl-opt NoMain AlwNull(*UsrCtl) Debug Option(*SrcStmt:*NoDebugIo) | ||
+ | DatFmt(*ISO) TimFmt(*ISO); | ||
//============================================================================== | //============================================================================== |
Latest revision as of 16:35, 17 December 2018
Summary
The following are the RPG/LE fully free-form definitions and instructions needed for using the Is Numeric service procedure. This service procedure simply allows the caller to validate that a character string is all numeric digits, decimal, and/or sign characters—or not.
Sometimes, having a service procedure is simply a means of making code more self-documenting (i.e., easier for others to understand). |
By Dave Clark
Service Prototype
Place the following in a separate copybook for inclusion in both the caller and the service program source members.
**free //============================================================================== // Validates variable-length character string for numerics only. // Returns a Boolean true/false value as a result. //============================================================================== dcl-pr GenUtl_isNumeric ind; pString varchar(50) const; end-pr;
Service Procedure
Place the following in a service program source member.
**free ctl-opt NoMain AlwNull(*UsrCtl) Debug Option(*SrcStmt:*NoDebugIo) DatFmt(*ISO) TimFmt(*ISO); //============================================================================== // Validates variable-length character string for numerics only. // Returns a Boolean true/false value as a result. //============================================================================== dcl-proc GenUtl_isNumeric export; dcl-pi *n ind; pString varchar(50) const; end-pi; dcl-c GenUtl_Numeric '0123456789.+-'; if %len(pString) = *zero; // if no supplied value return *off; // indicate not numeric endif; return (%check(GenUtl_Numeric: pString) = *zero); // return result of check end-proc;