From: Darrel Hoffman on
Okay, say I have a property list:

Names = [#Alice: 13, #Bob: 24, #Carol: 41]

If I want to access #Bob, it's as easy as saying:

put Names.Bob
-- 24

Yay. So, say I have a variable that I want to use as the property to check:

var = "Bob"

How do I make it check that property in the list? I can't use "Names.var",
because "var" isn't a property on that list. "getAt" and "getOne" return
nothing. "getProp", "getaProp", and "getPropAt" just error. There's got to
be some simple way to do this that I'm overlooking...


From: takekha on
On Apr 13, 1:10 am, "Darrel Hoffman" <no.addr...(a)all.com> wrote:
> Okay, say I have a property list:
>
> Names = [#Alice: 13, #Bob: 24, #Carol: 41]
>
> If I want to access #Bob, it's as easy as saying:
>
> put Names.Bob
> -- 24
>
> Yay. So, say I have a variable that I want to use as the property to check:
>
> var = "Bob"
>
> How do I make it check that property in the list? I can't use "Names.var",
> because "var" isn't a property on that list. "getAt" and "getOne" return
> nothing. "getProp", "getaProp", and "getPropAt" just error. There's got to
> be some simple way to do this that I'm overlooking...

How about using bracket ,instead of dot syntax?

Names = [#Alice: 13, #Bob: 24, #Carol: 41]
Var = #bob
Names[Var]
-------------------------------


From: Ideas Live on
put Names[var]

-- Brian

"Darrel Hoffman" <no.address(a)all.com> wrote in message
news:ftqqdt$9uu$1(a)forums.macromedia.com...
> Okay, say I have a property list:
>
> Names = [#Alice: 13, #Bob: 24, #Carol: 41]
>
> If I want to access #Bob, it's as easy as saying:
>
> put Names.Bob
> -- 24
>
> Yay. So, say I have a variable that I want to use as the property to
> check:
>
> var = "Bob"
>
> How do I make it check that property in the list? I can't use
> "Names.var", because "var" isn't a property on that list. "getAt" and
> "getOne" return nothing. "getProp", "getaProp", and "getPropAt" just
> error. There's got to be some simple way to do this that I'm
> overlooking...
>


From: Darrel Hoffman on
> put Names[var]

*sputters* Dammit, I thought I tried that! And wait - yes, yes as a matter
of fact I did try that, except I believe I've stumbled onto the one and only
case where Director is actually case-sensitive.

Names = [#Alice: 13, #Bob: 24, #Carol: 41]
put Names.Bob
-- 24
put names.bob
-- 24
put nAmEs.BOB
-- 24
put Names["Bob"]
-- 24
put Names["bob"]
-- <VOID>

*slaps self on forehead and wanders off muttering...*


From: Mike Blaustein on
Director is always case sensitive when it comes to symbols (the hash
sign in front of the name). It is supremely annoying when you are not
expecting it.

You actually should be using

put names[#Bob]

but Director is letting you get away with being sloppy with strings. If
you want to use a variable, then it should be

var=#Bob

or

var ="Bob"
put names[symbol(var)]
 |  Next  |  Last
Pages: 1 2
Prev: Newbie lost
Next: Behavior keeps dying...