If I want to check for the presence of one of several values in a variable, is it OK to do something like:
if variable contains "ABC" or XYZ" then ....
Pete
Checking for multiple values
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
Nope, you'll have to spell them out as independent contains comparisons. One options is something like this:
This approach is dynamic, in that you can easily extend the criteria to whatever length suits you; and the exit repeat ensures that your code is only called once.
HTH,
Jan Schenkel.
Code: Select all
put "ABC,XYZ" into tContainCriteria
repeat for each item tContainCriterion in tContainCriteria
if variable contains tContainCriterion then
-- do your thing
exit repeat
end if
end repeat
HTH,
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com