Display of groups in Control Browser
Wouter
wouter.abraham at scarlet.be
Mon Nov 29 18:02:40 EST 2004
Ok and now for the 1 liner solutions:
on refresh
local l, pad, cname, groupcontrols, isvis, nopw, nlines
lock screen
set the defaultStack to the label of button "Stack Name"
put empty into l
put empty into pad
put 0 into groupcontrols
put the passkey of this stack is empty into nopw
repeat with i = 1 to the number of controls
if the visible of control i then put empty into isvis else put "+"
into isvis
if nopw then put the number of lines in the script of control i
into nlines
if nlines is 0 then put empty into nlines
put pad & line 1 of the name of control i into cname
if the length of cname > 30
then put "..." into char 28 to -1 of cname
put cname & tab & nlines & tab & isvis & return after l
if word 1 of the name of control i is "group" then
if pad is empty
then put the number of layers in control i into groupcontrols
else
--subtract the number of layers in control i from the last
item of groupcontrols ###
### the change
put last item of groupcontrols - the number of layers in
control i into groupcontrols
###
put comma & the number of layers in control i after
groupcontrols
end if
put " " after pad
end if
if pad is not empty then
repeat while pad is not empty and last item of groupcontrols <= 0
delete last item of groupcontrols
delete char 1 to 2 of pad
end repeat
--if pad is not empty then subtract 1 from the last item of
groupcontrols ###
### the change
if pad is not empty then put last item of groupcontrols - 1 into
groupcontrols
###
end if
end repeat
delete last char of l
put the id of this card into cardid
set the defaultStack to the owner of me
set the defaultStack to "Control Browser"
put l into field "Controls"
if the selObj is not empty
then get the name of the selObj
else get empty
if it is empty or word 1 of it is "stack" \
or (word 1 of it is "card" and (word 2 of it is "id" or char 1
of word 2 of it is quote)) then
disablecontrols
set the hilitedLine of field "Controls" to empty
else
set the hilitedLine of field "Controls" to the layer of the selobj
enablecontrols
else
end if
unlock screen
end refresh
Beware of the mail line wraps
Greetings,
WA
On 27 Nov 2004, at 18:00, metacard-request at lists.runrev.com wrote:
> Message: 5
> Date: Sat, 27 Nov 2004 00:40:03 +0100
> From: Wouter <wouter.abraham at scarlet.be>
> Subject: Re: Display of groups in Control Browser
> To: metacard at lists.runrev.com
> Message-ID: <7EAE0F63-4004-11D9-A869-003065CC999E at scarlet.be>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
>
> Hi all,
>
> The problem is in : subtract ... from last item of groupcontrols
> which the engine won't execute anymore (in this case) if there is only
> 1 item in groupcontrols.
> (sometimes it does, but I couldn't pinpoint the reason yet why it
> doesn't in this case)
>
> Here is a work around for the "subtract from last item" problem, which
> i use for the refresh handler in the "control browser",
> (### the changes)
>
> on refresh
> local l, pad, cname, groupcontrols, isvis, nopw, nlines
> lock screen
> set the defaultStack to the label of button "Stack Name"
> put empty into l
> put empty into pad
> put 0 into groupcontrols
> put the passkey of this stack is empty into nopw
> repeat with i = 1 to the number of controls
> if the visible of control i then put empty into isvis else put "+"
> into isvis
> if nopw then put the number of lines in the script of control i
> into nlines
> if nlines is 0 then put empty into nlines
> put pad & line 1 of the name of control i into cname
> if the length of cname > 30
> then put "..." into char 28 to -1 of cname
> put cname & tab & nlines & tab & isvis & return after l
> if word 1 of the name of control i is "group" then
> if pad is empty
> then put the number of layers in control i into groupcontrols
> else
> --subtract the number of layers in control i from the last
> item
> of groupcontrols ###
> ### the change
> if the num of items in groupcontrols = 1 then subtract the
> number of layers in control i from groupcontrols
> else subtract the number of layers in control i from last
> item
> of groupcontrols
> ###
> put comma & the number of layers in control i after
> groupcontrols
> end if
> put " " after pad
> end if
> if pad is not empty then
> repeat while pad is not empty and last item of groupcontrols <=
> 0
> delete last item of groupcontrols
> delete char 1 to 2 of pad
> end repeat
> --if pad is not empty then subtract 1 from the last item of
> groupcontrols ###
> ### the change
> if pad is not empty then
> if the num of items in groupcontrols = 1 then subtract 1 from
> groupcontrols
> else subtract 1 from last item of groupcontrols
> end if
> ###
> end if
> end repeat
> delete last char of l
> put the id of this card into cardid
> set the defaultStack to the owner of me
> set the defaultStack to "Control Browser"
> put l into field "Controls"
> if the selObj is not empty
> then get the name of the selObj
> else get empty
> if it is empty or word 1 of it is "stack" \
> or (word 1 of it is "card" and (word 2 of it is "id" or char 1
> of
> word 2 of it is quote)) then
> disablecontrols
> set the hilitedLine of field "Controls" to empty
> else
> set the hilitedLine of field "Controls" to the layer of the selobj
> enablecontrols
> else
> end if
> unlock screen
> end refresh
>
> Greetings,
> WA
More information about the metacard
mailing list