Game Maker Games, Articles, Tutorials & More

Game Maker Network


Howdy, Guest! Please sign in or register an account.

Print

string_invert_case

By Daniel · January 11, 2009

Inverts the case of some string, making all the lowercase letters uppercase and vice-versa.

/* string_invert_case(str)
 *
 * Inverts the case of some string, making all the lowercase letters
 * uppercase and vice-versa.
 */

var out, len, i, c, o;

out = '';
len = string_length(argument0);

for (i = 1; i <= len; i += 1) {
  c = string_char_at(argument0, i);
  o = ord(c);
  if (o >= ord('a') && o <= ord('z'))
    out += string_upper(c);
  else
    out += string_lower(c);
}

return out;

Categories: String handling

Comments

There are no comments to display.

Post a Comment

You must be signed in to post comments.

Advertisement