groups and background

Geoff Canyon gcanyon at inspiredlogic.com
Sat Dec 28 17:13:01 EST 2002


On Saturday, December 28, 2002, at 08:58 AM, Dar Scott wrote:

> I got numbers that are not consistent with this.  (see my mail 
> yesterday)  I think "the number of backgrounds" refers to total number 
> of groups directly on or placed on cards of the stack.  I suspect that 
> nested groups are not counted.  I will have to run more tests to be 
> sure.

This is exactly correct. I agree that it might be a bit confusing, but 
I think the rationale is this: a background is a group that can be 
placed onto a card. A nested group cannot be placed onto a card, except 
if its owner is placed onto the card (which will include any nested 
groups). A group that is enclosed in another cannot be used as a 
background, and therefore is not a background.

On Saturday, December 28, 2002, at 09:34 AM, Dar Scott wrote:

> I apologize.  I didn't mean to ignore your suggestion.  I was aware of 
> the behavior of "there is a group" and "there is a background".  I 
> went on to show that "the number of" had the same problems and both 
> were not consistent with "the groups of" and "the backgrounds of".

I don't think there is a "the groups of" construct. You can get the 
groupnames of a card, and the backgroundnames of a stack.

> But are people confused by this?
>
> I would guess that some people are under the impression that "there is 
> a background" means that there is a group with background behavior set 
> somewhere in the stack by that name.  That would not be the case.

You're right above. "there is a background" means there is a 
non-enclosed group of that name somewhere in the stack.

> I would guess that some people are under the impression that "there is 
> a background" means that there is a group somewhere in the stack by 
> that name.  But, it doesn't work that way on my system.

"there is a background" _does_ mean there is a group somewhere in the 
stack by that name. However, the reverse is not true: there can be a 
group named "bob" in a stack, and 'there is a background "bob"' could 
still return false. This would be the case if group "bob" were enclosed 
in (a part of) group "sally"

> I would guess that some might think that if 'there is a group "alpha"' 
> is true, then 'there is a background "alpha"' is true.  I see 
> counterexamples.

Same as above. If group "alpha" is part of group "omega" then group 
"alpha" cannot be a background -- it cannot be "placed onto" a card.

> I would guess that some might expect "the number of lines in the 
> backgrounds" to be the same as "the number of backgrounds".  This is 
> not the case.

If you're referring to the backgroundNames or the backgroundIDs, you're 
right and I agree with you. The backgroundNames and backgroundIDs 
return a subset of the backgrounds: the ones that have the 
backgroundBehavior set to true. I agree that's confusing. But you can 
easily write:

function myBackgroundNames()
   put empty into tReturnList
   repeat with i = 1 to the number of backgrounds of this stack
     put the short name of background i & cr after tReturnList
   end repeat
   return tReturnList
end myBackgroundNames

> I would guess that some might think that 'there is a background 
> "alpha"' is the same as '"alpha" is among the lines of the 
> backgrounds'.  I would guess otherwise.

See above.

> This is in addition to confusion areas.  We have these three (at 
> least):
>
> 1) The use of "background" in background behavior vs. "background" in 
> some subset of groups associated with a stack.

I agree that backgroundBehavior can be misleading. But it would be 
misleading to use a name that didn't include "background" since its 
function is to make groups/backgrounds work like backgrounds in 
HyperCard. Maybe change it to HCBackgroundBehavior ;-)

> 2) The inconsistent use of "background" in the subsets of groups 
> associated with a stack.  (As described above)
>
> 3) The inconsistent path for groups that do not have background 
> behavior set.

The inconsistency is the result of attempted HyperCard compatibility. I 
never set backgroundBehavior to true, so I'm not too familiar with any 
issues it might cause.

Somewhere along the way you asked what others call these things. I 
always think of them as groups. I only use the term background when I'm 
placing one onto a card. I think Ken pointed out the syntax supports 
this as well. If you put the name of a background, you'll get group 
"whatever"

regards,

Geoff Canyon
gcanyon at inspiredlogic.com




More information about the Use-livecode mailing list