xml or other complete text representation of a control?

Doug Lerner doug at webcrossing.com
Tue Feb 17 20:49:38 EST 2004


On 2/14/04 5:26 PM, "Brian Yennie" <briany at qldlearning.com> wrote:

> Doug,
> 
> "the properties" returns an associative array, perhaps you were
> treating it as a string?

I was trying 

    put the properties of graphic "Tao2"

that returns nothing.

    put the keys of the properties of graphic "Tao2"

is a syntax error it seems.

I'll take a look at your script.

Thanks,

doug


> 
> Check out the following- with the recent CVS thread going on here, I
> banged out this script to convince myself that textual representations
> of stacks weren't too bad. There's a bunch of stuff in here, including
> customProperties and escaping property values so they'll all fit on one
> line, etc, etc.
> 
> But mostly, per your question you basically have a couple of options
> for dealing the "the properties" array- use combine (but watch out for
> property values that might contain your delimiter string inside of
> them, esp. with custom properties), or loop through the individual
> elements of the array using either: "repeat for each element e in
> propArray" or "repeat for each line tKey in keys(propArray)".
> 
> HTH,
> Brian
> 
> ####################
> 
> ## DEFINE SOME CONSTANTS
> constant kNONE = 0
> constant kSTACK = 1
> constant kCARD = 2
> constant kPART = 3
> constant kTYPENAMES = "stack,card,part"
> 
> on mouseUp
>  ## CHOOSE A FOLDER TO EXPORT THIS STACK TO
>  answer folder "Please select a folder to export to."
>  if (the result is "Cancel") then exit mouseUp
>  exportStack it, the short name of this stack
> end mouseUp
> 
> on exportStack theDir,whichStack
>  put the directory into saveDir
>  put the defaultStack into saveDefault
> 
>  set the directory to theDir
>  set the defaultStack to whichStack
> 
>  ## EXPORT THE STACK OBJECT
>  textExport kSTACK, the short name of this stack,kNONE,0
> 
>  ## LOOP THROUGH EACH CARD AND EXPORT EACH OF ITS PARTS
>  ## NOTE:: GROUPS SHOW UP AS THEIR OWN 'PART' ON EACH CARD THEY BELONG
> TO
>  repeat with i=1 to (number of cds in this stack)
>    exportCard theDir,whichStack,the id of cd i of this stack
>  end repeat
> 
>  ## RESTORE THE CURRENT DIRECTORY
>  set the directory to saveDir
>  set the defaultStack to saveDefault
> end exportStack
> 
> on exportCard theDir,whichStack,cardID
>  put the directory into saveDir
>  put the defaultStack into saveDefault
> 
>  set the directory to theDir
>  set the defaultStack to whichStack
> 
>  textExport kCARD, cardID,kSTACK,the short name of this stack
>  repeat with j=1 to number of cd parts of cd id cardID of this stack
>    exportPart theDir,whichStack,cardID,the id of part j of cd id
> cardID of this stack
>  end repeat
> 
>  set the directory to saveDir
>  set the defaultStack to saveDefault
> end exportCard
> 
> on exportPart theDir,whichStack,cardID,partID
>  put the directory into saveDir
>  put the defaultStack into saveDefault
> 
>  set the directory to theDir
>  set the defaultStack to whichStack
> 
>  textExport kPART,partID,kCARD,cardID
> 
>  set the directory to saveDir
>  set the defaultStack to saveDefault
> end exportPart
> 
> 
> on textExport objectType, objectID, parentType, parentID
>  ## FIGURE OUT THE RELATIVE LOCATION OF THE FILES
>  switch (objectType)
>  case kSTACK
>    put (the directory)&"/stack_"&objectID&"/" into parentDir
>    break
>  case kCARD
>    put (the directory)&"/"&(item parentType of
> kTYPENAMES)&"_"&(parentID)&"/card_"&objectID&"/" into parentDir
>    break
>  case kPART
>    put (the directory)&"/"&("stack_"&(the short name of this
> stack))&"/"&(item parentType of
> kTYPENAMES)&"_"&(parentID)&"/part_"&objectID&"/" into parentDir
>    break
>  end switch
> 
>  ## CREATE A FOLDER FOR THIS OBJECT
>  create folder parentDir
> 
>  if (objectType = kSTACK) then
>    put "stack"&&quote&objectID&quote into objectDesc
>  else
>    put ((item objectType of kTYPENAMES)&" id "&objectID) into
> objectDesc
>    put the long id of objectDesc into objectDesc
>  end if
> 
>  put (parentDir)&(item objectType of kTYPENAMES)&"["&(objectID)&"]"
> into fName
> 
>  ## EXPORT THE SCRIPT
>  put the script of objectDesc into tScript
>  put tScript into url ("file:"&fName&".sct")
> 
>  ## EXPORT THE ORDINARY PROPERTIES
>  put the properties of objectDesc into tProps
>  put extractProps(tProps) into url ("file:"&fName&".prp")
>  if (word 1 of the long id of objectDesc is "image") AND (the fileName
> of objectDesc is empty) then
>    put compress(the imageData of objectDesc) into url
> ("file:"&fName&".image")
>    put compress(the alphaData of objectDesc) into url
> ("file:"&fName&".alpha")
>    put compress(the maskData of objectDesc) into url
> ("file:"&fName&".mask")
>  end if
> 
>  ## EXPORT THE CUSTOM PROPERTIES
>  put empty into tCustomProps
>  put the customPropertySet of objectDesc into savePropertySet
>  repeat for each line tPropertySet in the customPropertySets of
> objectDesc
>    set the customPropertySet of objectDesc to tPropertySet
>    put the customProperties of objectDesc into tProps
>    put tPropertySet&colon&cr&extractProps(tProps)&cr after tCustomProps
>  end repeat
>  put tCustomProps into url ("file:"&fName&".cst")
>  set the customPropertySet of objectDesc to savePropertySet
> end textExport
> 
> function extractProps @tPropArray
>  local tPropData
>  repeat for each line tKey in keys(tPropArray)
>    put tPropArray[tKey] into tValue
>    replace "\" with "\\" in tValue
>    replace return with "\r" in tValue
>    put tKey&colon&tValue&cr after tPropData
>  end repeat
>  return tPropData
> end extractProps
> 
>> I don't get any result from "the properties" when I try this with
>> graphic or
>> field objects. Maybe that only works for custom properties?
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution



More information about the use-livecode mailing list