I want to scan a character string to see if the string contains any letters of the alphabet. Is there a way to do this without doing %SCAN 26 times using a different letter each time
Announcement
Collapse
No announcement yet.
%scan
Collapse
X
-
Re: %scan
Hi Gregwga50:
Give this a try:
If you need lower case add to the a2z and blnk fields.Code:D A2Z C CONST('ABCDEFGHIJKLMNOPQRST+ D UVWXYZ') D blnk C CONST(' + D ') d testfld s 15a inz('1234567890ABCDE') D WRKFLD S LIKE(TESTFLD) D OK S 1 /FREE WRKFLD = %XLATE(A2Z : BLNK : TESTFLD) ; IF WRKFLD <> TESTFLD ; DSPLY 'YOU HAVE ALPHA' '' OK ; ELSE ; DSPLY 'NOALPHA DETECTED' '' OK ; ENDIF ; *INLR = *ON ; /END-FREE
Best of Luck
GLSThe problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln
-
Re: %scan
To be more specific, here is what I am trying to do:
We have an alpha field, I'll call DESCRP. Sometimes it contains customer number (%trimmed) followed by a space and then a name, other times, it just contains customer#. I want to detemine when it contains a name
Comment
-
Re: %scan
How about:
Given the assumption that DESCRP starts with customer number with optional customer name following. The %CHECK will return the first character that isn't in the first string - which is 0-9 and a blank. If all it has is blanks and numbers it will return 0 to reflect that. If something is found use %Subst to extract it.Code:Namepos = %CHECK('0123456789 ' : [COLOR=#000000]DESCRP); [/COLOR]CustName = ''; If Namepos > 0; CustName = %Subst(DESCRP : Namepos); Endif;
Comment




Comment