Tony �str�m wrote:
> I want to do this (if the "text articles" are more then one specified
> word) but how !!
> on checkArt
>   if member("text_articles").text contains "G44", "H55", "I66" and
> sprite(21).member.name = "p44b", "p55b", "p66b" then
>     if gLang = "eng" then
>       alert "OOPS!"
>     end if
>   end if
> end


Hi Tony,

You could use a hard-coded nested case statement:

on CheckArt
  case member("text_articles").text of
    "G44", "H55", "I66":
    case sprite(21).member.name of
      "p44b", "p55b", "p66b":
         alert "OOPS!"
    end case
  end case
end CheckArt


You could use lists.  List operations are fast but case-sensitive, so you
need to be sure that you have the right case for each string:


global gTexts, gNames

on startMovie
  gTexts = ["G44", "H55", "I66"]
  gNames = ["p44b", "p55b", "p66b"]
end startMovie

on CheckArt
  if gTexts.getPos(member("text_articles").text) then
    if gNames.getPos(sprite(21).member.name) then
      alert "OOPS!"
    end if
  end if
end CheckArt


The advantage of using lists is that you can modify them on the fly.

If you need to change the data on the fly AND you need to avoid
case-sensitivity, you can work with strings (but this is slower):


global gTexts, gNames

on startMovie
  gTexts = " G44 H55 I66 "
  gNames = " p44b p55b p66b "
end startMovie

on CheckArt
  if gTexts contains " "&member("text_articles").text&" " then
    if gNames contains " "&sprite(21).member.name&" " then
      alert "OOPS!"
    end if
  end if
end CheckArt


Note that I place a space at the beginning and end of the global strings,
and also at the beginning and end of the strings I check against them.  You
can use gNames.word[x] to access a particular word (the .word property will
ignore the initial space).

Cheers,

James

[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to