>What's the most efficient way of determining the parent of any item in the
> list and determining that item1 has no parent

perhaps im missing something here, but:

mylist = "item1,item2,item3,item4";

for(i=1; i lte ListLen(mylist);i=i+1){

        WriteOutput("I am: "&ListGetAt(mylist,i));

        if(i eq 1){
                WriteOutput(" and I am the root");
        }else{
                WriteOutput(" and my parent is: 
"&findparent(mylist,ListGetAt(mylist,i)));
        }

        WriteOutput("<br>");
}

function findparent(nlist,me){
        var myparent = "root";
        var myindex = ListFind(nlist,me);

        if(myindex gt 1){
                myparent = ListGetAt(nlist,myindex-1);
        }

        return myparent;
}

-----Original Message-----
From: Jerry Barnes [mailto:[EMAIL PROTECTED]
Sent: 02 June 2005 15:36
To: CF-Talk
Subject: Re: get parent items from list?


Sounds like an adjaceny list model.

Does the list contain the whole tree or does a list only contain a path from
one node to another while other lists contain other paths?



On 6/2/05, Emmet McGovern <[EMAIL PROTECTED]> wrote:
>
> Brain Meltdown. Maybe someone can help.
>
> I have a list such as (item1,item2,item3,item4,item5). The list can be any
> length. Item1 would be the parent of item2 and item2 would be the parent
> of
> item3 and so on.
>
> What's the most efficient way of determining the parent of any item in the
> list and determining that item1 has no parent?
>
> Thanks,
> Emmet
>
>
>
>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:208383
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to