Scripts:String is uppercase

From OHRRPGCE-Wiki
Jump to navigation Jump to search

This script returns true if all of the letters in the string are uppercase. it it returns false if any lowercase letters exist, or if the string has no letters at all.

script, string is uppercase, strnum, begin
  variable(i, ch, letters, upper)
  for(i, 1, string length(strnum)) do(
    ch := ascii from string(strnum, i)
    if(ch >= 65 && ch <= 90) then(
      letters += 1
      upper += 1
    )
    if(ch >= 97 && ch <= 122) then(
      letters += 1
    )
  )
  if(letters >= 1 && upper == letters) then(
    exit returning(true)
  )
  exit returning(false)
end

Here is a usage example, which checks if the hero in slot 3 has an uppercase name

# store the name of the hero in slot 3 in string 1
get hero name(1, 3)
if(string is uppercase(1)) then(
  show text box (5) # WHY is your NAME SO LOUD!??
)