numbering backgrounds (was: background owners)
Wilhelm Sanke
sanke at hrz.uni-kassel.de
Thu May 22 15:43:00 EDT 2003
On Wed, 21 May, Dar Scott <dsc at swcp.com> wrote:
> > I wrote "Indeed, Dave´s "number of cards" suggestion did the trick
> > immediately."
>
>
> But. But. His script controls the loop with "number of backgrounds"
> and then refers to each one using "background x". If I understood you
> correctly (always a dangerous assumption), then there is a potential
> problem.
>
> Suppose card "A" has group "Alpha" placed on it and group "Alpha"
> contains group "Beta". Suppose group "Gamma" is unplaced. There are
> no other groups.
>
> If I understand this, "number of backgrounds" would return 2. However,
> numbering might be like this:
>
> Alpha 1
> Beta 2
> Gamma 3
>
> Group "Gamma" would be missed in the loop, if "background x" could
> refer to groups in that manner.
>
> (A consequence of your observation is that "background" now has _three_
> meanings. Sigh.)
>
> Dar
>
Excuse me for taking so long to respond, (happily) there were things to
attend to outside the computer world.
I put Dave´s solution inside my "counter" script that I had already used
earlier. This combination solves the involved problems - as it were
"unbalances" of the engine - for all practical purposes.
Here is the core of the script:
put the name of the topstack into SName
put empty into BList
put 0 into counter
repeat
add 1 to counter
if there is a background counter of stack SName then
put the name of background counter of stack SName into BName
if the number of cards of background counter of stack SName = 0
then
put " (unplaced)" after last char of BName # or do something
else
end if
put BName into line counter of BList
else
exit repeat
end if
end repeat
After some more scripting the final result is a hierachically indented
list of backgrounds and subgroups.
When you click at one of the lines, all the controls of the respective
background/group are shown in another window, which can then be edited
using the script editor or the properties palette.
Even the script of the unplaced backgrounds or their controls can be
edited using the the script editor. However, you cannot edit the
properties of unplaced backgrounds or objects.
If the user of card "Background Browser" wants to edit the properties
of an unplaced background - he is asked about that in a dialog -, the
unplaced background will be placed onto the current card for editing
(and removed afterwards, if the user wishes).
For this the information was needed whether an object is "unplaced" -
not on any card - in a stack. The very quick way to get this information
was Dave Cragg's solution.
The slower solution I had already implemented was to go to all cards of
a stack first because only after that the owners of backgrounds are
returned correctly.
Regards,
Wilhelm Sanke
More information about the use-livecode
mailing list