Codey question: setting to lower case

psymann
28 Apr 2013, 22:56
Hello clever coders, :o

I've got a switch case statement, which runs on 'text'.

But if the text is "Yes" or "yes" or "YES", I don't want to have to put three different cases on the switch statement just because some are upper/lowercase.

Is there a built-in command that would do something like:

Switch SET_TO_LOWERCASE(text)

CASE: yes
Run script... etc


psy

psymann
28 Apr 2013, 23:03
Also, is there a way to do CONTAINS, eg to test whether 'text' contains the word "yes" anywhere?


(I should probably add - if there's no easy way, then never mind, it's not a huge problem, more of a 'nice to have' for my game, so don't bust a gut trying to get some complicated workaround solution on my behalf!)

Sora574
28 Apr 2013, 23:31
This should turn everything into lowercase, no matter what:
quest5.net/wiki/LCase wrote:LCase ( string input )

As for searching for a specific phrase in a string, you could try this:
quest5.net/wiki/Instr wrote:Instr ( string input , string search )

Then, to put it all together:
// Either this...
switch (LCase(text)) {
case ("yes") {
// Run script
}
}

// Or something like this...
if (Instr(LCase(text), "yes") > 0) {
// Run script
}

Hope that helps

EDIT: Fixed a lot of mistakes -- sorry about that :?

psymann
06 May 2013, 22:31
Sora, that's great, thanks :-)

I used your second "if" version rather than the switch case one, since then it meant I could do the search, and it works just right, just gets through a lot of "else if" statements when I fill it out with all the options I wanted to include! :-D

psy