Copying customPropertySet with associated customKeys

Ken Ray kray at sonsothunder.com
Wed Jun 22 11:47:58 EDT 2005


On 6/22/05 9:12 AM, "Glen Bojsza" <gbojsza at gmail.com> wrote:

> Again, I am trying to dig deeper into custom properties.
> 
> I am trying to store the customPropertySet with associated customKeys
> and the associated property contents of the keys into another object's
> custom properties.
> 
> I have , thanks to Dan and Scott, been able to store an image and the
> associated customKeys but now I want to do more ... actually all of
> it.
> 
> Do you need to create an array of an object's customPropertySet ,
> customKeys  and property contents and then store it? Or is there more
> a direct method?

Glen, here's what I use - pass "all" for pSetName if you want all the sets
copied:

on stsCopyCPSet pSourceObj,pDestObj,pSetName
  if pSetName = "" then put "all" into pSetName
  if pSetName = "all" then
    put the customPropertySets of pSourceObj into tSets
    set the customPropertySets of pDestObj to tSets
  else
    put the customPropertySets of pDestObj into tSets
    if tSets = "" then put pSetName into tSets
    else put tSets & cr & pSetName into tSets
    set the customPropertySets of pDestObj to tSets
  end if
  repeat for each line tSet in tSets
    if pSetName <> "all"  and tSet <> pSetName then next repeat
    set the customPropertySet of pSourceObj to tSet
    set the customPropertySet of pDestObj to tSet
    set the customKeys of pDestObj to the customKeys of pSourceObj
    put the customKeys of pSourceObj into tKeys
    repeat for each line tKey in tKeys
      do "set the" && tSet & "[" & q(tKey) & "] of" && pDestObj && "to the"
&& tSet & "[" & q(tKey) & "] of" && pSourceObj
    end repeat
  end repeat
  set the customPropertySet of pSourceObj to ""
  set the customPropertySet of pDestObj to ""
end stsCopyCPSet

HTH,

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com



More information about the use-livecode mailing list