Okay I updated the function to return an array to account for properties that
are in array form. It returns a numbered array with two keys, the long ID of
the object, and the property of each object you passed as an argument. I had to
remove the sorting though because I am not about to sort an array. So far as I
know sorting does not work with arrays. There should be some kind of form of
sort for arrays like:
sort the keys of myArrayA by myArray[id] of each -- or maybe by element 2 of
each
but of course there is not. At any rate sorting arrays is too much trouble, and
I digress.
Here's the updated function:
function objectList theType, theProp
if the last char of theType is "s" then put char 1 to -2 of theType into
theType
if theSort is empty then put "ascending" into theSort
try
do "get the " & theProp & " of " & theType & " 1 of this card"
catch theError
if item 1 of the last line of theError is "166" then
return "Error: Invalid type"
else
return "Error: " & the last line of theError
end if
end try
put empty into theObjectList
put empty into theObjectListA
put 1 into theLineNum
put theType & "s" into thePluralType
put the name of this card into theStartCard
lock screen
lock messages
repeat with theCardNum = 1 to the number of cards of this stack
go card theCardNum
try
do "put the number of " & thePluralType & " of this card into
theTypeCount"
repeat with theObjectNum = 1 to theTypeCount
do "put the long ID of " & theType && theObjectNum & " into
theObjectID"
do "put the " & theProp & " of " & theType && theObjectNum & "
into theValue"
if theValue is not in theObjectList then
put theObjectID into theObjectListA[theLineNum][LongID]
put theValue into theObjectListA[theLineNum][theProp]
put theValue into line 1 of theObjectList
add 1 to theLineNum
end if
end repeat
catch theError
breakpoint
end try
end repeat
go card theStartCard
return theObjectListA
end objectList
The results for a call like put objectList("images", "short name") into
theArrayA returns a result (in printKeys() format) like this:
1
short name: imgLogonsHi
LongID: image id 10101 of card id 1002 of stack
"/Users/bobsneidar/Documents/LiveCode Stacks/Conference Scheduler/CSL
Main.livecode"
2
short name: barpattern.png
LongID: image id 9999 of card id 1002 of stack
"/Users/bobsneidar/Documents/LiveCode Stacks/Conference Scheduler/CSL
Main.livecode"
<snip>
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode