PeopleCode Check Number and Check Letter Functions

Your rating: None Average: 5 (2 votes)

Couple PeopleCode functions I came across. One insures a string consists of numbers and one insures a string consists of letters.

Function Check_Number(&STR) Returns boolean;
   &LEN = Len(&STR);
   If &LEN = 0 Then
      Return False;
   End-If;
   For &I = 1 To &LEN;
      &CODE = Code(Substring(&STR, &I, 1));
      If (&CODE < 48 Or
            &CODE > 57) Then
         Return False;
      End-If;
   End-For;
   Return True;
End-Function;

Function Check_Letter(&STR) Returns boolean;
   &LEN = Len(&STR);
   If &LEN = 0 Then
      Return False;
   End-If;
   For &I = 1 To &LEN;
      &CODE = Code(Upper(Substring(&STR, &I, 1)));
      If (&CODE < 65 Or
            &CODE > 90) Then
         Return False;
      End-If;
   End-For;
   Return True;
End-Function;

Please try to help out with unanswered topics on the forum. Chances are you have had the same issue/question some time in your IT career!

Comments

Have a question? Please ask it on the forum instead.

Post new comment

CAPTCHA
The question below is to prevent automated spam submissions.
3 + 17 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.