Search a character in a string in rpgle

1400 pts.
Tags:
RPGLE opcode
Hi I have a character filed and and i dont want to allow special character and digits how can i solve My code is Dscan             s             50    inz('0123456789+         D                                       `~!@#$%¢&*()_+|=-¦¬}{ + D                                       :/.,?:"><.,') d@scan            s              5u 0                        dstr              s             10    inz('am$%@shukl')                                                                   c*                  eval      scan=%trimr(scan)              c                   eval      @scan=%check(scan :%trim(str)) c     @scan         dsply                                    c                   eval      @scan=%scan(str : scan)        c*                  eval      @scan=%check(str :%trim(scan)) c     @scan         dsply                                    c                   return                                             

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hello I am pretty,prettyshina74@yahoo.com

I guess you will not surprise to receive my mail? i saw your profile and it
sound well.I will like us to exchange good relationship.I am pretty

by name,No kid and never marry.from here you can contact me at this
email address(prettyshina74@yahoo.com )so that i can send you my

pictures and also tell you more about myself,have a nice day
and i am waiting to hear from you snoonest,

Remeber the distance or colour does not matter but love and concern matters alot in life

(prettyshina74at ya hoo dot com)
Yours
pretty

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    i dont want to allow special character and digits What do you want to do if you find them? Tom
    125,585 pointsBadges:
    report
  • 9783444184
    if i found my screen field then validate it if there any other option for it please tel me
    1,400 pointsBadges:
    report
  • BigKat
    For a simple validation test, translate any forbidden characters (to anything else, doesn't matter as long as each translated character is different than the forbidden one it replaces) and if the translated string is not equal to the compare string, then there are forbidden characters in the compare string
    d goodChar        s              3a   inz('___')                                   
    d forbidden       s              3a   inz('1 $')                                   
    d compareStr      s             50a   inz('ABCDEFG1HIJK LMN$OP')                   
                                                                                       
     /free                                                                             
         if compareStr <> %xlate(forbidden:goodChar:compareStr);                       
           // forbidden characters in field                                            
         endif;                                                                        
         *inlr = *on;                                                                  
     /end-free
    
    8,350 pointsBadges:
    report
  • TomLiotta
    If all you want to do is check to see if you only have letters, no special characters or digits), then simply check for letters:
         D string1         s             50a   varying
         D                                     inz( 'ABCDEFG1:' )
         D string2         s             50a   varying
         D                                     inz( 'ABCDEFGHI' )
    
         D chars           C                   'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    
          /free
    
           if 0 <> %check( chars : string1 ) ;
              dsply 'string1 has junk' ;
           endif ;
    
           if 0 <> %check( chars : string2 ) ;
              dsply 'string2 has junk' ;
           endif ;
    
           *inlr = *on ;
           return ;
    
          /end-free
    That has two string variables -- string1 and string2. And it has a constant that contains only letters -- chars. It first checks string1 to see if there's anything that doesn't match between chars and string1. If it finds any position in string1 that doesn't match, the %check() function will return the position of the mismatched character. So if it returns anything but zero, it will display the message 'string1 has junk'. Then it checks string2. If it finds anything but letters, it will display the message 'string2 has junk'. Because string1 has "1:" at the end, you should get the 'string1 has junk'. And because string2 only has letters, you won't get a message for string2. Tom
    125,585 pointsBadges:
    report
  • 9783444184
    Hi TomLiotta Thanks for your valuable example
    1,400 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following