RE: Help w/ Dynamic Structure Creation

2000-11-14 Thread Dan G. Switzer, II

Alex,

The session scope is also a structure, so you can use the StructInsert on
the Session scope as well. You can also use the format:

CFSET Session[idx] = StructNew()

which is a little easier to read.

-Dan
++---+
|   name | Dan G. Switzer, II|
|company | PengoWorks.com|
|www | http://www.pengoworks.com |
| mailto | [EMAIL PROTECTED]   |
++---+


-Original Message-
From: Alex Sherwood [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 14, 2000 9:24 AM
To: CF-Talk
Subject: Help w/ Dynamic Structure Creation

I am trying to create a series of structures.

The name of each is contained in a list, and I want to concatenate the word
"session." with the name to create a structure that resides in the SESSION
scope. I have session variables enabled and verified its works with a
regular CFSET for a session variable.

Here is the code that sets the variable:

cfscript

masterList = "sessionData,accountData,modifiedAccountData";
sessionData = "ID,IP,startTime,endTime,browser";
accountData =
"firstName,lastName,address1,address2,city,state,zip,phone";

/cfscript

Here's the code that sets the struct names. Loop through MASTERLIST in the
outerloop, then loop over the current index in the inner loop, setting the
items in the list as keys in the struct:

cfset Loopvar = 1
cfloop list=#masterList# index="idx"

cfset var1 = idx
cfset session.var1 = StructNew()


cfloop list=#Evaluate(ListGetAt(Masterlist, LoopVar))#
index="idx2"
cfset foo = StructInsert(session.var1, idx2, "",
1)
/cfloop
cfset LoopVar = LoopVar + 1

/cfloop



The inner loop seems to work just fine, adding the keys to the struct.
Can anyone offer a solution to successfully dynamically create the
structure as a session variable with the name equal to the index of the
outer loop?

Thanks!

Alex Sherwood



Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a
message with 'unsubscribe' in the body to [EMAIL PROTECTED]


Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]



RE: Help w/ Dynamic Structure Creation

2000-11-14 Thread Simon Horwith

Try session[#var1#]

~Simon

 Simon Horwith
 Certified ColdFusion Developer
 Fig Leaf Software
 1400 16th St NW, # 220
 Washington DC 20036
 202.797.6570 (direct line)
 www.figleaf.com
 


-Original Message-
From: Alex Sherwood [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 14, 2000 9:24 AM
To: CF-Talk
Subject: Help w/ Dynamic Structure Creation


I am trying to create a series of structures.

The name of each is contained in a list, and I want to concatenate the word 
"session." with the name to create a structure that resides in the SESSION 
scope. I have session variables enabled and verified its works with a 
regular CFSET for a session variable.

Here is the code that sets the variable:

cfscript

masterList = "sessionData,accountData,modifiedAccountData";
sessionData = "ID,IP,startTime,endTime,browser";
accountData =
"firstName,lastName,address1,address2,city,state,zip,phone";

/cfscript

Here's the code that sets the struct names. Loop through MASTERLIST in the 
outerloop, then loop over the current index in the inner loop, setting the 
items in the list as keys in the struct:

cfset Loopvar = 1
cfloop list=#masterList# index="idx"

cfset var1 = idx
cfset session.var1 = StructNew()


cfloop list=#Evaluate(ListGetAt(Masterlist, LoopVar))#
index="idx2"
cfset foo = StructInsert(session.var1, idx2, "",
1)
/cfloop
cfset LoopVar = LoopVar + 1

/cfloop



The inner loop seems to work just fine, adding the keys to the struct.
Can anyone offer a solution to successfully dynamically create the 
structure as a session variable with the name equal to the index of the 
outer loop?

Thanks!

Alex Sherwood



Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a
message with 'unsubscribe' in the body to [EMAIL PROTECTED]

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]



RE: Help w/ Dynamic Structure Creation

2000-11-14 Thread Alex Sherwood

At 09:39 AM 11/14/2000 -0500, you wrote:
Alex,

The session scope is also a structure, so you can use the StructInsert on
the Session scope as well. You can also use the format:

CFSET Session[idx] = StructNew()

which is a little easier to read.

Thanks!

You know, I was staring right at the solution too. I was using 
CF_OBJECTDUMP to look at the session struct to see what was being added! I 
never though to add it to the session struct!

But, I still don't know the proper way to concatenate the word "session." 
and a variable name, and then use the resulting variable name as the name 
of a struct. It should work, but I haven't been able to get it to work 
properly.

Thanks for your help!

--
Alex Sherwood


Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]



RE: Help w/ Dynamic Structure Creation

2000-11-14 Thread Alex Sherwood

At 09:41 AM 11/14/2000 -0500, you wrote:
Try session[#var1#]

~Simon

  Simon Horwith
  Certified ColdFusion Developer
  Fig Leaf Software
  1400 16th St NW, # 220
  Washington DC 20036
  202.797.6570 (direct line)
  www.figleaf.com
 


Thanks!


Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]