AVEVA Community
AVEVA Community
  • Site
  • User
  • Site
  • Search
  • User
PDMS/E3D Forum
  • AVEVA World
PDMS/E3D Forum
Beginners Check string for any letter
  • Forums
  • Resources
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Replies 4 replies
  • Subscribers 1 subscriber
  • Views 43 views
  • Users 0 members are here
Options
  • Share
  • More
  • Cancel
Related

Check string for any letter

Lauri Lahtiranta
Lauri Lahtiranta over 4 years ago
 
  • Sign in to reply
  • Cancel
  • Lauri Lahtiranta
    Lauri Lahtiranta over 4 years ago
    Hiya!

    Is there a way for checking is string contains alphabets?
    Meaning I want to check if the string has any letters in it and if it does then reject it.

    Thanks for any help!
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Shrivallabha Sharad Redij
    Shrivallabha Sharad Redij over 4 years ago
    Not sure if I have seen a default pml function for testing presence of a letter in a string but if you create a code like below and put it inside a function then it can work.
    !teststring = '100 hours'
    !sourcestring = 'abcdefghijklmnopqrstuvwxysz'
    !matchfound = false
    do !i from 1 to !sourcestring.Length()
        If !teststring.match(!sourcestring.substring(!i,1)).gt(0) or !teststring.match(!sourcestring.substring(!i,1).upcase()).gt(0) then
            !matchfound = true
            break
        endif
    enddo
    If !matchfound.eq(true) then
       $P !teststring contains an alphabet!
    else
       $P !teststring doesn't contain an alphabet!
    endif
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Matts Nordman
    Matts Nordman over 4 years ago
    The string object also has a .IsDigits() and a .IsLetters() method, so you could simply do "q var !string.isdigits()" which will return TRUE if the string is only digits  and FALSE otherwise, or "q var !string.isletters()" which will return TRUE if the string is only letters and FALSE otherwise.
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Lauri Lahtiranta
    Lauri Lahtiranta over 4 years ago
    Thanks for the help!
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel