Re: has option in system attributes
Re: has option in system attributes
- Subject: Re: has option in system attributes
- From: "John W. Baxter" <email@hidden>
- Date: Sat, 10 Apr 2004 13:32:54 -0700
On 4/10/2004 12:37, "trinko" <email@hidden> wrote:
>
I was looking at system attributes and i'm wondering if anyone has a
>
quick explination for how the has clause works.
>
>
for example
>
>
system attribute "sysv" has 4148
>
>
returns true even though the value of the attribute is 4147
>
>
for fun i checked which intergers return true and which return false
>
for 4148 93 of the integers 1-100 return true. i thought that the has
>
clause may be converting the value into hex and comparing but i don't
>
think that would be true with so many different value returning true.
>
I 'm also confused that values larger than the returned value can
>
return true. in fact most of the integers between 4748 and 10000
>
return true.
>
>
Thanks for any help.
If I remember correctly, has causes the returned value from system attribute
to be treated as a bitmap. The parameter to has is also treated as a bit
map, and ANDed with the system attribute value. The result is true if the
result of the AND has any 1 bits.
Thus:
(one line)
{system attribute "sysv", system attribute "sysv" has 1, system attribute
"sysv" has 8, system attribute "sysv" has 9}
yields the list {4147, true, false, true}
since 4147, 1, and 9 all have the low order bit set, but 8 does not.
Now to look at the dictionary...which seems to agree with my memory.
4147 decimal is 1033 hex. Half of all integers have the low order bit
set...half of the integers which don't have the low order bit set have the
next bit leftward set, so even ignoring the other three bits in 1033 hex,
3/4 of all integers (in the range of interest) will return true when tested
that way against 4147.
--John
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.