Difference between revisions of "Is Digits"

From MidrangeWiki
Jump to: navigation, search
(Created page with "Category:Service Procedures == Summary == The following are the RPG/LE fully free-form definitions and instructions needed for using the {{AN}} service procedure. This se...")
 
(Summary)
Line 1: Line 1:
 
[[Category:Service Procedures]]
 
[[Category:Service Procedures]]
 
== Summary ==
 
== Summary ==
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, 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—or not.
  
 
== Service Procedure ==
 
== Service Procedure ==

Revision as of 20:16, 12 December 2018

Summary

The following are the RPG/LE fully free-form definitions and instructions needed for using the Is Digits service procedure. This service procedure simply allows the caller to validate that a character string is all numeric digits—or not.

Service Procedure

**free

//==============================================================================
// Validates variable-length character string for digits only.
//   Returns a Boolean true/false value as a result.
//==============================================================================
dcl-pr GenUtl_isDigits  ind;
  pString               varchar(50) const;
end-pr;

//==============================================================================
// Validates variable-length character string for digits only.
//   Returns a Boolean true/false value as a result.
//==============================================================================
dcl-proc GenUtl_isDigits export;
  dcl-pi *n             ind;
    pString             varchar(50) const;
  end-pi;

  dcl-c GenUtl_Digits   '0123456789';

  if %len(pString) = *zero;            // if no supplied value
    return *off;                       // indicate not numeric
  endif;

  return (%check(GenUtl_Digits: pString) = *zero); // return result of check
end-proc;