Hey Matt,

I'd do the following:

<cfset client.foo = 4 />
<!--- Create the client-specific struct in application --->
<cfif not structKeyExists("application", "mystruct_" & client.foo)>
  <cfset application[mystruct_#client.foo#] = structNew()  />
</cfif>

<!--- Create a reference to it --->
<cfset myClientStruct = application["mystruct_"&client.foo] />

<!--- Now, do whatever you want to it --->
<cfset myClientStruct.title = "TITLE" />
<cfset myClientStruct.foo = "BAR" />

<!--- Destroy a member --->
<cfset structDelete(myClientStruct, "title") />

<!--- Destroy the whole thing --->
<cfset structDelete(application, "mystruct_" & client.foo) />

----- Original Message -----
From: Matt Robertson <[EMAIL PROTECTED]>
Date: Fri, 13 Aug 2004 11:06:53 -0700
Subject: Deleting a dynaically-named struct: Brain Freeze!
To: CF-Talk <[EMAIL PROTECTED]>

This can't be difficult, but I'm not getting it this morning.

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>
<cfif not IsDefined ("#variables.myname#")>
    <cfset "#variables.myname#"=StructNew()>
    <cfset variables.myTitle=variables.myname&".title">
    <cfset "#variables.myTitle#"="TITLE">
    <cfset variables.myTitle=variables.myname&".text">
    <cfset "#variables.myTitle#"="TEXT">
</cfif>
<cfdump var="#application#">
<cfdump var="#variables#">
<cfset temp=structdelete("#variables.myname#","True")>
<cfabort>

--
--Matt Robertson--
MSB Designs, Inc.
mysecretbase.com________________________________
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to