[Xerte] Accessing associative arrays via variable?
Dave Burnett
d_b_burnett at hotmail.com
Wed Dec 30 16:31:26 GMT 2009
Yes, as I discovered. :/
I was trying to make it easy on myself by passing a parameter which doubled as a link which doubled as a title which keyed the definition, etc.
I've gotten around it by using underscores for spaces and stripping the underscores where needed for display.
Subject: RE: [Xerte] Accessing associative arrays via variable?
Date: Wed, 30 Dec 2009 16:24:30 +0000
From: Julian.Tenney at nottingham.ac.uk
To: xerte at lists.nottingham.ac.uk
I wouldn't use spaces in names at all
From: xerte-bounces at lists.nottingham.ac.uk on behalf of Dave Burnett
Sent: Wed 30/12/2009 14:23
To: Xerte list
Subject: RE: [Xerte] Accessing associative arrays via variable?
For the archives, something that is probably obvious to OOP aware folks, but tripped me up good:
myObject = new Object();
myObject.My Property = "rooster";
debug(myObject.My Property); // gives "rooster"
debug(myObject["My Property"]); // gives undefined
No spaces in object properties allowed when using non dot syntax.
=====================================
b = new Object();
b.blah = 'value';
v='blah';
debug(b[v]); //works for me
From: xerte-bounces at lists.nottingham.ac.uk on behalf of Dave Burnett
Sent: Sun 27/12/2009 21:49
To: Xerte list
Subject: RE: [Xerte] Accessing associative arrays via variable?
help_defs = new Object();
helps_defs.Atomic = "Roosters are atomic";
debug(helps_defs.Atomic); // gives me "Roosters are atomic"
myVar = 'Atomic';
debug(help_defs[myVar]); // gives me undefined.
Subject: RE: [Xerte] Accessing associative arrays via variable?
Date: Sun, 27 Dec 2009 21:23:56 +0000
From: Julian.Tenney at nottingham.ac.uk
To: xerte at lists.nottingham.ac.uk
myVar = 'Atomic';
debug(help_defs[myVar]);
From: xerte-bounces at lists.nottingham.ac.uk on behalf of Dave Burnett
Sent: Sun 27/12/2009 18:05
To: Xerte list
Subject: [Xerte] Accessing associative arrays via variable?
help_defs = new Object();
helps_defs.Atomic = "Roosters are atomic";
debug(helps_defs.Atomic); // gives me "Roosters are atomic"
Can I sub a variable into the place of .Atomic in that last statement?
Sort of like in AW, to call a value from a property list using a variable for the property name I'd use:
Trace(my_prop_list[Symbol("a"^some_variable)])
Hotmail: Trusted email with Microsoft’s powerful SPAM protection. Sign up now.
Hotmail: Powerful Free email with security by Microsoft. Get it now.
Hotmail: Trusted email with Microsoft’s powerful SPAM protection. Sign up now.
Hotmail: Free, trusted and rich email service. Get it now.
Hotmail: Trusted email with powerful SPAM protection. Sign up now.
_________________________________________________________________
Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141664/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20091230/34191d5a/attachment.html
More information about the Xerte
mailing list