A problem with replicating a subgroup

Andre.Bisseret Andre.Bisseret at inria.fr
Thu Jan 21 10:37:38 EST 2010


Le 21 janv. 10 à 13:28, planix a écrit :

>
> Hi,
>
> The issue I have is a bit complicated to explain so I have uploaded an
> example stack ("A Group Replication Problem") to revOnline. You  
> should find
> it if you search for me or look for a stack tagged 'Test'.
>
> Basically, I have a scrolling group set up with a subgroup which I  
> want to
> be able to replicate as many times as I need. Each replication is  
> managed by
> a button ("New Case Plan") which clones the subgroup, changes some  
> custom
> properties, and then places the cloned subgroup a certain distance  
> beneath
> the previous subgroup. I can delete each replication in sequence  
> back to the
> first subgroup which is not deleteable as I use it as the 'template'  
> for
> replication.
>
> This all works fine. I can press the "New Case Plan" button as many  
> times as
> I like and all the replicant subgroups all line up nicely in the  
> scrolling
> group. I can also delete any new replicant as expected. So, what I  
> am saying
> is that the code works as expected. Though I am betting that it is  
> clumsy-
> so any thoughts on how to make the code itself more efficient or  
> elegant
> would be welcomed.
>
> The problem is this. All of the above works fine so long as I don't  
> scroll
> to the bottom of the group, so that the last replication is showing,  
> before
> I press the "New Case Plan" button. If I do that the next  
> replication is
> displaced well away from the previous one and is not the neat and tidy
> separation that I expected. If I keep on doing that the distance  
> between
> replication becomes increasingly larger.
Bonjour Alistair,
Try the following modifications to the script of button "New Client  
Plan"
-------------------------
   put the cpCurrentGrpNum of grp "grpCarePlan" into theNumber
    --set up to track and record the new subgroup location
    put item 1 of the cpCurrentGrpLoc of grp "grpCarePlan" into theLeft
    --add a constant displacement to the down item of loc to ensure  
the fields do not overlap
    put item 2 of the cpCurrentGrpLoc of grp "grpCarePlan" + 57 into  
theDown
    --make the copy of the orginal subgroup
    clone group "grpPlan1" --invisible group "grpPlan1" SEEMS THAT  
CLONING INVISIBLE IS NOT NECESSARY
    --note that cantDelete is set to true to stop this subgroup from  
being deleted by "btnDeletePlan"
    --need to change this so that all replicants can be deleted
    set the cantDelete of it to false
    --set the name and location of the replicant and then show it
    --------------------------------HERE ARE THE MODIF I AM SUGGESTING
    put "grpPlan" & theNumber into lastName
    put "grpPlan" & theNumber + 1 into newName
    set the name of it to newName
    set the topLeft of grp newName to the bottomLeft of grp lastName   
-- THIS IS THE PRINCIPAL MODIFICATION
    --------------------------------
    --set the name of it to "grpPlan" & theNumber +1
    --set the loc of it to theLeft, theDown
    set the cpCurrentGrpLoc of grp "grpCarePlan" to the loc of it
    --show it
    --update the property which keeps track of the number of replicants
    set the cpCurrentGrpNum of grp "grpCarePlan" to theNumber +1
---------------------------

Seems that it solves your problem: the next replication is not  
displaced any more)

Best regards from Grenoble
André






More information about the use-livecode mailing list