Page 1 of 1

comparing values

Posted: Sat Oct 13, 2007 12:49 am
by ajazza
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

Posted: Sat Oct 13, 2007 8:30 am
by malte
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

Posted: Sun Oct 21, 2007 12:22 am
by Mark Smith
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