bugs in union and intersect?

Pete pete at mollysrevenge.com
Tue Jul 12 14:22:21 EDT 2011


Just catching up with some posts....

It's true that casesensitive only applies to text comparisons, specifically
those listed in the dictionary, but the dictionary also claims that keys to
arrays and custom property names are affected by the casesensitive setting,
which confuses things in my mind.  I'd be tempted to put in an enhancement
request for this - it seems like union and intersect must do text
comparisons under the covers so it's reasonable that they should obey the
casesensitive setting.

I guess you could implement case sensitive versions of union and intersect
with a repeat loop on the keys of one array, testing if it was "among" the
lines of the keys of the other array, since "among" does obey the case
sensitive setting, something like:

command myUnion @parray,ptestarray
  put the keys of ptestarray into myKeys
  set the casesensitive to true
  repeat for each line myKey in myKeys
    if myKey is not among the lines of the keys of parray then
      put ptestarray[myKey] into parray[myKey]
    end if
  end repeat
end myUnion

I tried that on Dick's test case and it produced the right results.


Pete
Molly's Revenge <http://www.mollysrevenge.com>




On Tue, Jun 28, 2011 at 6:24 AM, Ken Ray <kray at sonsothunder.com> wrote:

> > They both fail with caseSensitive true.
> >
> > on mouseUp
> >    local a,b,c,d
> >    set the caseSensitive to "true"
> >    put 1 into a["a"]
> >    put 2 into b["b"]
> >    put 3 into b["B"]
> >    union a with b
> >    -- missing a["b"]
> >
> >    put 1 into c["c"]
> >    put 2 into c["C"]
> >    put 3 into d["c"]
> >    intersect c with d
> >    -- should not have c["C"]
> > end mouseUp
> >
> >
> > Confirmation?
> >
> > Bug report?  Enhancement request?  Warnings in documentation?
>
> Confirmed, but caseSensitive is only used for text comparisons (as stated
> in
> the docs), and the key to an array is apparently not "text" so it has no
> effect. So if anything I'd say "warning in documentation"...
>
> Ken Ray
> Sons of Thunder Software, Inc.
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>



More information about the use-livecode mailing list