comparing values

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
ajazza
Posts: 1
Joined: Sat Sep 29, 2007 1:04 am

comparing values

Post by ajazza » Sat Oct 13, 2007 12:49 am

Hi Guys,
Please take a look at this example.
I have 2 variables:

1. gVariable1["values"] = "1 2 3 4"
2. gVariable2["values"] = "4 5 6 7"

How can I check each value of gVariable1 and see if it is in gVariable2?

Kind Regards
Adam

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Sat Oct 13, 2007 8:30 am

HI Adam,

coming up with something effective here, requires to see some real world data. Is your data really structured the way you described above? All values seperated by spaces? Also, are your variables really arrays?

All the best,

malte

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Contact:

Post by Mark Smith » Sun Oct 21, 2007 12:22 am

Adam, I think Malte is right to ask about the real data, but given what you posted, as a starting point, I might do something like:

Code: Select all

function commonValuesPresent array1, array2
  repeat for each word w in array1["values"]
    if w is among the words of array2["values"] then return true
  end repeat
  return false
end commonValuesPresent
Best,

Mark

Post Reply