On Jul 5, 2008, at 11:36 AM, John Weinshel wrote:
What do you mean by 'comparing'? If you merely need to know if one is
different in any way from another, you can just use the
ValueListItems()
function for each, testing their equality. Be mindful of using that
function
in a stored calculation, as it can create very large indices,
particularly
with large value lists. Better, if your situation allows it, to use
a script
that sets two variables to the lists' contents, and then test the
equality
of those variables.
I'm afraid it's a tad more complicated than that.
I need to know what items in two different ValueLists (VLs) match and
what items there are in each that do not have an EXACT match in the
other.
If you want to know which is longer, you can just count the
returns. But if
you want to know exactly how their contents differ, you will need
to either
use a script that walks through each, comparing them line by line,
or a
recursive custom function that does something similar.
Such a script would set a counter to a starting number (zero or one,
depending on how you parse the lists), and then run a loop that
parses out
one line of each list with each increment of the counter, putting the
results of each parsing into a separate script variable. Whenever
the two
variables do not match, their contents can be captured and appended
to a
list (another variable or global field), so that you might end up with
something like:
3 apple <> orange
7 peach<> pear
The number on the left would be pulled from the counter (perhaps
adding or
subtracting 1, depending on how you start the counter and how
you're parsing
the lists), and indicate the list row number.
That will still not tell you if 'peach' does actually appear in the
second
list, but on a different line. In other words, if the answer to the
question
'what do you mean by "comparing"' is that you want to know whether
or not
the overall contents are the same, even if the order is not, then
you will
need a more elaborate version of what I described above, where you
walk the
lists and compare the values in each line.
In this harder case, you would need to check the variable-- the
contents of
one line in one list-- against a PatternCount() for it in the other
list.
Depending, again, on the full answer to my original question, you
may need
to run that comparison twice, once for each list.
THIS is more like what I'm attempting.
And that will get harder still if you may have comparisons like
'apple' and
'apple pie'. In that case, PatternCount() would return a positive
value for
looking for 'apple' in a list containing 'apple pie', but not the
other way
'round.
Indeed....
On Jul 5, 2008, at 10:46 AM, Steve B. Gerow wrote:
Ideas: use the ValueListItems function to set the value lists into
two separate fields or variables, then filter one by the other and
compare numbers of paragraph returns using the ValueCount function.
You can also use the FilterValues function.
This is what I was thinking, but the use of FilterValues looked
potentially useful for what I was attempting. Unfortunately, it only
does one of the two essential tasks for my activity; it only reports
what is in VL2 that matches items in VL1. I also need to know what is
in VL2 that IS NOT in VL1.
So....
....guess I need to add another item to the WishList discussion of
last month.
AND I need to develop a convoluted script to do what I need to have
done.
Thanks for all your advice. Now to try to digest and act on it.
Regards,
Chuck