I suppose i could adopt the benmisters method of XML menus and use this method ie;

http://www.macromedia.com/devnet/mx/coldfusion/extreme/xml_menu.html

Everytime you update the "category" sytem, you write to an xml file and read from it 
in an ordered way. If you wanted to then bolt on an Object onto a branches properties 
it could contain a simple "load this component" style of instruction?

I'll shutup now and try these methods out and when i come up with what i think is my 
solution, i'll post it for all to code review :D 

The overall goal is to limit the need for a data layer per say, in that I don't want 
to be locked into a specific data layer.. I'm finding XML to be an easier solution as 
its not really a enterprise level application.

Scott




-----Original Message-----
From: Scott Barnes 
Sent: Monday, 7 April 2003 1:42 PM
To: [EMAIL PROTECTED]
Subject: RE: [CFCDev] Arrays passed by value to a cffunction?!?


Hey Sam,

Suprisingly I found this:
http://webforums.macromedia.com/coldfusion/messageview.cfm?catid=7&threadid=306238&highlight_key=y&keyword1=category

I think thats it, i have had a quick glance and won't be able to put it into play 
until tonight, but i think thats what i am after?

The general problem isn't the heirachy as in a nutshell if the data where to be sorted 
by:
Parent,Level,Label

and the array stayed in that format, i could easily convert that single array into a 
tree system, as most of the legwork in nesting is handeled by the "level" at which the 
branch is located.

ie if the array stayed in this format:

parent a
parent b
-- child a
-- child b
--- sib a
--- sib b
--- sib c
-- child c
parent c
parent d

It could easily be visually nested through various presentation layers (flashmx, 
jscript etc). As you could simply state <cfloop index="i" from="1" 
to"LevelAmt">--</cfloop> Label (for this example).

Hardest part is sorting a jumbled array into that format:

[1][1]Label = parent a
[1][2]OtherProps = etc..

[2][1]Label = parent b
[2][2]OtherProps = etc..

[3][1]Label = child a
[3][2]OtherProps = etc..

[4][1]Label = child b
[4][2]OtherProps = etc..

[5][1]Label = sib a
[5][2]OtherProps = etc..

[6][1]Label = sib b
[6][2]OtherProps = etc..

[7][1]Label = sib c
[7][2]OtherProps = etc..

[8][1]Label = child c
[8][2]OtherProps = etc..

[9][1]Label = parent c
[9][2]OtherProps = etc..

[10][1]Label = parent d
[10][2]OtherProps = etc..

Scott.


-----Original Message-----
From: Samuel Neff [mailto:[EMAIL PROTECTED]
Sent: Monday, 7 April 2003 1:29 PM
To: [EMAIL PROTECTED]
Subject: [CFCDev] Arrays passed by value to a cffunction?!?


When putting together some code for the post I made a few minutes ago I
ran into trouble manipulating arrays with a cffunction.  It appears that
arrays are being passed by value.  Specifically, I originally wrote the
example with this code:


<cfset sortIdArray(rootArray)>

<cffunction name="sortIdArray" returnType="void">
        <cfargument name="arrayToSort" type="Array" required="true">
        
        <cfset var i=0>
        <cfset var j=0>
        <cfset var a = arguments.arrayToSort>
        <cfset var al = arrayLen(a)>
        <cfset var t="">
        
        <cfloop index="i" from="1" to="#al-1#">
                <cfloop index="j" from="#i+1#" to="#al#">
                        <cfif recStruct[a[i]] GT recStruct[a[j]]>
                                <cfset t = a[i]>
                                <cfset a[i] = a[j]>
                                <cfset a[j] = t>
                        </cfif>
                </cfloop>
        </cfloop>
        
</cffunction>


But it didn't work.  The sortIdArray ran, it seemed to do the proper
sorting, but later uses of the array were not sorted.  So, I changed it
to this:

<cfset rootArray = sortIdArray(rootArray)>

<cffunction name="sortIdArray" returnType="Array">
        <cfargument name="arrayToSort" type="Array" required="true">
        
        <cfset var i=0>
        <cfset var j=0>
        <cfset var a = arguments.arrayToSort>
        <cfset var al = arrayLen(a)>
        <cfset var t="">
        
        <cfloop index="i" from="1" to="#al-1#">
                <cfloop index="j" from="#i+1#" to="#al#">
                        <cfif recStruct[a[i]] GT recStruct[a[j]]>
                                <cfset t = a[i]>
                                <cfset a[i] = a[j]>
                                <cfset a[j] = t>
                        </cfif>
                </cfloop>
        </cfloop>
        
        <cfreturn a>
        
</cffunction>

and it worked fine.  Changes were in first cfset, returnType, and added
cfreturn.

This seems to indicate Arrays are passed by value.  I didn't check if
it's a deep copy (duplicate) or if it's just a first level copy.  Is
this expected/correct behavior?

Sam



----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).



Be seen on Australia's premier travel website - http://www.australia.com 
List your product on the Australian Tourism Data Warehouse.  
For further information: http://www.tq.com.au/atdw 

 

 ********************* Disclaimer ********************* 

The information contained in this email is intended only for the 
addressee and may contain privileged or confidential information. If 
you are not the addressee, you are notified that any transmission, 
distribution, downloading, printing or photocopying of the contents 
of this message or attachments is strictly prohibited. The privilege 
of confidentiality attached to this email is not waived, lost or 
destroyed by reason of mistaken delivery to you. If you receive this 
message in error please notify the sender by return e-mail or telephone. 

This email is also subject to copyright. No part of it should be 
reproduced, adapted or transmitted without the written consent of the 
copyright owner. 

This e-mail message has been checked for the presence of computer 
viruses.  However, Tourism Queensland provides no warranty that 
all possible viruses have been detected and cleaned during this process. 



----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).



Be seen on Australia's premier travel website - http://www.australia.com 
List your product on the Australian Tourism Data Warehouse.  
For further information: http://www.tq.com.au/atdw 

 

 ********************* Disclaimer ********************* 

The information contained in this email is intended only for the 
addressee and may contain privileged or confidential information. If 
you are not the addressee, you are notified that any transmission, 
distribution, downloading, printing or photocopying of the contents 
of this message or attachments is strictly prohibited. The privilege 
of confidentiality attached to this email is not waived, lost or 
destroyed by reason of mistaken delivery to you. If you receive this 
message in error please notify the sender by return e-mail or telephone. 

This email is also subject to copyright. No part of it should be 
reproduced, adapted or transmitted without the written consent of the 
copyright owner. 

This e-mail message has been checked for the presence of computer 
viruses.  However, Tourism Queensland provides no warranty that 
all possible viruses have been detected and cleaned during this process. 



----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

Reply via email to