Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
vayumahesh #1
Creating Dynamic Structure
Hi,
I want to create a dynamic structure of structures. I wrote the following code
but I am getting errors with that.
I have three entities department, plant and PCP. There are multiple plants for
a PCP specific to a department. PCP-Department-Plant combination is unique.
User selects multiple departments, corresponding PCPs on the form. Here is my
code ....
<cfset deptPlantPCP = StructNew()>
<cfloop list="#form.department#" index="deptId">
<cfset deptPlantPCP.#deptId# = StructNew()> (Getting error with '.' here)
<cfloop list="#form.pcp#" index="pcpId">
<!--- plants Query for plant_num based on PCP and Department --->
<cfloop from="1" to="#plants.recordcount#" index="pCtr">
<cfset deptPlantPCP.#deptId#.#plants.plant_num[pCtr]# = "#pcpId#">
</cfloop>
</cfloop>
</cfloop>
Thanks for your help.
-vmrao.
vayumahesh Guest
-
Class::Struct - want to access structure within structure
I want to access a structure within a structure. Below is what I had in mind. Please help. #!/perl/bin/perl use Class::Struct; struct Step... -
Dynamic Structure Question?
Hi, I wanted to know if possible. Can I have a dynamic structure name? some generic query <cfquery name="qryTest"... -
Creating new table with same structure as existing one
I need to create "archive" table that will have the same structure as "production" one. When I run my program it have to create table named... -
Input form for creating hierarchy structure
Hi I'm trying to create an input screen that allows users to create a hierarchical structure as the one below, but have no clue where to start or... -
#24993 [NEW]: Suggestion for DOM - creating XML documents with structure from a recordset
From: kris_beyers at hotmail dot com Operating system: WindowsXP PHP version: 4.3.2 PHP Bug Type: DOM XML related Bug... -
mxstu #2
Re: Creating Dynamic Structure
Try using array notation
<!--- not tested --->
<cfset deptPlantPCP[deptId] = StructNew()>
mxstu Guest
-
-
vayumahesh #4
Re: Creating Dynamic Structure
How to check if a particular element like deptPlantPCP[deptId][plantId] exists ?
For example, the created structure is
deptPlantPCP[2][25] = 111
deptPlantPcp[1][10] = 118
and I want to check if deptPlantPCP[3][22] exists ? If Yes, get the
corresponding value.
Thanks,
vmrao
vayumahesh Guest
-
BSterner #5
Re: Creating Dynamic Structure
This should do it...
<cfscript>
deptPlantPCP = StructNew();
deptPlantPcp[1] = StructNew();
deptPlantPcp[2] = StructNew();
deptPlantPCP[2][25] = 111;
deptPlantPcp[1][10] = 118;
if (StructKeyExists(deptPlantPCP, 3) and StructKeyExists(deptPlantPCP[3], 22))
{
writeoutput("yup");
} else {
writeoutput("nope");
}
</cfscript>
BSterner Guest



Reply With Quote

