Caching?

Wilhelm Sanke sanke at hrz.uni-kassel.de
Sat Jul 23 14:40:31 CDT 2005


On Fri, 22 Jul 2005 Tariel Gogoberidze <tariel at mac.com> wrote:

> I guess, first I should explain why I used the "weird" script below..
>
> It seems engine has a bug or at least inconsistency where
>
> Put number of bgs would ignore nested grps but, in "repeat with j= 1 to
> number of bgs" the count WILL go through nested grps. So, if you have
> lets's say 4 bgs and bg # 3 has nested grp, above repeat loop would not
> count bg # 4 and would return bg 1, bg 2, bg3 and sub group of bg3
> leaving bg 4 out in cold.


Hi Tariel,

The docs of Rev are more precise here. From the "comments" of 
"backgroundnames":

"If a group in the stack contains groups, only the top-level groups are 
reported."

I wish we had a function that would return all backgrounds - including 
nested ones - without scripting a workaround.

> So, I had to work around this behavior with the following script
>
> on mouseUp
>    put the short name of this stack into pSrcStack
>    repeat forever
>      add 1 to count
>      if there is no bg count of stack pSrcStack then exit repeat
>      put word 1 of the owner of bg count of stack pSrcStack into
> tWhichOwner
>      if tWhichOwner = "Stack" then
>        put the name of bg count of stack pSrcStack & cr after tBgNames
>      end if
>    end repeat
>    answer tBgNames
> end mouseUp


I did something similar (first) when encountering  exactly the same 
problem while I tried to update my MC- and RevBrowsers, see my script 
farther down.

> Now the caching? issue that puzzles me
>
> If you create stack with 2 cards and 2 grps (I created both groups with
> background behavior "on") and remove both groups from card 1 and remove
> grp 1 from card 2 (so, now grp 1 is "unplaced" and grp 2 is only placed
> on card 2).
>
> Note: Stack has "destroy stack" and "destroy window" set to true.
>
> With this settings, if you run script above on just launched stack, the
> script would return
>
> group "BG1"
> group "BG2"
>
> But if you go to next card and back and run script again it would return
>
> group "BG1"
>
> Only.
>
> (snip)
>
> best regards
> Tariel


I observed the same behavior, i.e. if a card has not yet been opened 
during a session then "stack" will be returned as the owner - even when 
the background in question is indeed owned by the card. In the 
discussion we had on this list (or the Run list) one or two years ago I 
had proposed  to introduce something like "the effective owner of 
background x".

Two solutions to the problem are possible - as far as I know:

1. Loop through (open) all cards of the stack before you run the above 
script

2. Ask for the "number of cards" a background has (see script below). 
Someone recommended this to me during the previous discussion., I forget 
who.

Here is the script I used to get placed and unplaced backgrounds of a 
stack, which I just found in one of my test stacks. I am not sure if it 
is the latest version - so no guarantee comes with the script

"on mouseUp
  put the name of the topstack into SName
  put empty into BList
  put empty into SortList
  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
      put the owner of background counter of stack SName into item 2 of 
BName
      if word 1 of the owner of background counter of stack SName is 
"group" then put Space before BName
      #===============
      if the number of cards of background counter of stack SName = 0 
and word 1 of the owner of background counter of stack SName <> "group" then
        put " (unplaced)" after last char of BName
      end if
      #=================
      put BName into line counter of BList
      put item 1 of BName into line counter of SortList
    else
      exit repeat
    end if
  end repeat
  put Blist into fld "Blist"
  put the number of lines of BList into Zahl
  repeat with i = 1 to Zahl
    put  line i of BList into Zeile
    put line i of SortList into SZeile
    if char 1 of Zeile is " " then
      put item 2 of Zeile into Eigner
      put lineoffset(Eigner,BList) into GroupEigner
      put line Groupeigner of BList into Beigner
      put empty into pad
      repeat while char 1 of Beigner is Space
        put Space after last char of pad
        delete char 1 of Beigner
      end repeat
      put pad&Zeile into line i of BList
      put pad&SZeile into line i of SortList
    end if
  end repeat
  put SortList into fld "Backgrounds"
 
end mouseUp"

Regards,

Wilhelm Sanke
<http://www.sanke.org/MetaMedia>



More information about the metacard mailing list