2 Replies Latest reply on Oct 21, 2008 3:47 PM by Newsgroup_User

# Get a  property value in a list of lists

Hello:
I need to get this value "Gb" from this list

a=[["Gb":114,"E":10],["Ab":243]]

When I write this I get an error

put a.getPropAt(1)

thank you.

• ###### 1. Re: Get a  property value in a list of lists
put a[1].getPropAt(1)
• ###### 2. Re: Get a  property value in a list of lists
I have a suspicion that Rob's answer isn't going to work for you,
because it depends on you knowing that "Gb" is the first element of the
first list. If you do in fact know this, then your lists should just be
regular linear lists, the "Gb": part serves no purpose.

Unless I am mistaken, what you have is not even a correctly formed
property list, so you won't be able to use any of the property list
functions anyway. A property list would look like this:

a=[[#Gb:114,#E:10],[#Ab:243]]

In this case you could easily write a handler that searches for the
first occurrence of #Gb. It wouldn't matter which list it was in, or in
which position within the property list it was located. This function
will return the value of the property passed (or VOID if it isn't found).

-------------
on getPropValueFromListofPropLists myProp, myListOfPropLists
returnValue = VOID
repeat with x in myListOfPropLists
if x.findPos(myProp) then
returnValue = x.getProp(myProp)
exit repeat
end if
end repeat
return returnValue
end
----------------------

a=[[#Gb:114,#E:10],[#Ab:243]]

put getPropValueFromListofPropLists(#Gb,a)
-- 114

put getPropValueFromListofPropLists(#Ab,a)
-- 243

put getPropValueFromListofPropLists(#XXX,a)
-- <Void>

I strongly recommend you use a correct property list. Using the symbol()
function you can turn strings like "Gb" into symbols (#Gb)

Arielle wrote:
> Hello:
> I need to get this value "Gb" from this list
>
> a=[["Gb":114,"E":10],["Ab":243]]
>
> When I write this I get an error
>
> put a.getPropAt(1)
>
> Can you help me please?
>
>
> thank you.
>
>