I'm making a little skin that use lua scripting and I would like to know is there where any ways to have a "if" test that is case-insensitive. Something like this :
if Var1 (=case insensitive test) 'string' then
It is currently April 25th, 2024, 5:39 pm
Case insensitive "if"
-
- Posts: 60
- Joined: November 5th, 2016, 12:15 pm
-
- Rainmeter Sage
- Posts: 16169
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Case insensitive "if"
Yeah, there is: if string.upper(Var1) == 'THE-UPPERCASE-STRING' then. Here the Var1 variable is converted to uppercase (by the string.upper(Var1) function), then this string is compared with the THE-UPPERCASE-STRING variable. If you have the same strings, no matter which characters of the Var1 variable are upper- and which ones are lowercase, the if condition will be true.
Similarly you can use the string.lower(Var1) function, to convert the uppercase characters, to lowercase.
Similarly you can use the string.lower(Var1) function, to convert the uppercase characters, to lowercase.
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Case insensitive "if"
if string.lower(Var1) == 'hello world' then
or if you prefer:
if string.upper(Var1) == 'HELLO WORLD' then
Edit: Balala beat me again....
or if you prefer:
if string.upper(Var1) == 'HELLO WORLD' then
Edit: Balala beat me again....
-
- Posts: 60
- Joined: November 5th, 2016, 12:15 pm
Re: Case insensitive "if"
Thank you very much guys
It's working well.
It's working well.
-
- Developer
- Posts: 22629
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Case insensitive "if"
Glad to help. BTW, for completeness sake:LGP123 wrote:Thank you very much guys
It's working well.
if Var1:lower() == 'hello world' then
also works.