> I have a dynamically-named application-scope struct.  I can
> create it just fine, and put stuff in it, but when I'm done I
> can't get the structdelete() syntax right. What am I doing
> wrong?  Code below.
>
> <cfset client.foo=4>
> <cfset variables.myname="application.mystruct_"&client.foo>
> ...
> <cfset temp=structdelete("#variables.myname#","True")>

Well, it looks like you have two problems. The first is that StructDelete
needs you to specify two arguments - the structure and the key which you
want to delete. The optional third (Boolean) argument lets you control
whether you get an error if the key doesn't exist, if I recall correctly.
So, if you had a structure named "foo" with a key named "bar", and you
wanted to delete "bar", your code would look like this:

<cfset temp = StructDelete(foo, "bar")>

The second problem is that you're dynamically naming your structure.
Honestly, I doubt that's really necessary, but if you want to continue down
that path, try this:

<cfset temp = Evaluate("StructDelete(" & Variables.myname & ", ""mytitle"",
""true"")")>

Yecch.

Alternatively, why not just take advantage of the fact that your struct is
inside the Application scope, which is itself a struct? You don't need to
use another name for your structure in that case.

<cfset temp = StructDelete(Application["mystruct_" & client.foo],
"mytitle")>

Or, you can just pass the structure by reference into your local variable,
and do away with this dynamic naming stuff that way.

At least, that's what strikes me after perusing this very quickly. I don't
guarantee my suggestions will work, as I'd have to take a little more time
than I have to do that.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
phone: 202-797-5496
fax: 202-797-5444
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to