If Command Question

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
warrenk
Posts: 110
Joined: Sun Sep 21, 2008 5:39 am

If Command Question

Post by warrenk » Tue Sep 30, 2008 5:47 pm

If tColor = 'RED' or tColor = 'BLUE' or tColor = 'Green', etc.

Is there a way to change the above if statement when I can give a list or values?

I know the syntax is not correct, but something like this...

If tColor = ('RED', 'BLUE', 'GREEN') then...

Thanks!
Warren

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Tue Sep 30, 2008 6:17 pm

if tColor is among the items of "red,green,blue" then

watch out to not include spaces thoug ("green" <> " green")
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Tue Sep 30, 2008 6:18 pm

Code: Select all

if tColor is among the items of "RED,BLUE,GREEN" then...
should be what you need.
(Although you could spell tColour properly :wink: )

or

Code: Select all

if tColor is among the words of "RED BLUE GREEN" then...
Look up "is among" anyway.

warrenk
Posts: 110
Joined: Sun Sep 21, 2008 5:39 am

Post by warrenk » Tue Sep 30, 2008 6:21 pm

Thanks again SparkOut!

Had to laugh at the Color comment. Coming from Canada, we spell it either Color or Colour...both are correct in Canada.

Since I now live in the USA...I guess I am incorrect with the spelling. :oops:

Jerry Daniels
Posts: 10
Joined: Sat Mar 11, 2006 5:11 pm
Contact:

a color is not always a color name when tested

Post by Jerry Daniels » Tue Sep 30, 2008 7:02 pm

Sometimes I've set the forecolor of something to "red" and then when I test it later, it's 255,0,0, not "red".
[img]http://daniels-mara.com/hosted_images/dm_logo.png[/img]
[b]Jerry Daniels[/b]
[size=92]Daniels & Mara, Inc.[/size]
[size=84]Creator of [url=http://glx2.com][b]GLX2 Tools[/b][/url]
Host of [url=http://revmentor.com][b]Rev Mentor[/b][/url][/size]

Post Reply