Perfect, Brian. I do indeed have to save more than 2 items to each row. I was trying
ArrayDeleteAt but screwing up the syntax. Thanks very much for your help yesterday
and today nursemaiding me thru this.
In case its useful to anyone poking around in the archives some day, here's the
template I used to test the creation and deletion of 2d array items.
<cflock scope="APPLICATION" type="EXCLUSIVE" timeout="10">
<cfparam name="url.row" default="1">
<cfset client.UserID=url.Row>
<cfparam default="N" name="url.Delete">
<cfif not isdefined ("application.myArray")>
<cfset application.myArray=ArrayNew(2)>
</cfif>
<cfif url.Delete is "Y">
<cfloop
from="1"
to="#ArrayLen(application.myArray)#"
index="ArrayRows">
<cfif not Compare(application.myArray[ArrayRows][2],client.UserID)>
<cfset arrayDeleteAt(application.myArray,ArrayRows)>
<cfbreak>
</cfif>
</cfloop>
<cfelse>
<cfset start=ArrayLen(application.myArray)+1>
<cfset stop=ArrayLen(application.myArray)+1>
<cfloop from="#start#" to="#stop#" index="i">
<cfset application.myArray[i] = arrayNew(1)>
<cfset trash=arrayAppend(application.myArray[i],i)>
<cfset trash=arrayAppend(application.myArray[i],i)>
<cfset trash=arrayAppend(application.myArray[i],now())>
</cfloop>
</cfif>
<html><head><title></title></head><body>
Click Plain to add array items<hr>
<cfoutput>
<cfloop from="1" to="10" index="i">
<A href="#cgi.script_name#?Delete=Y&Row=#i#">del #i#</A>
</cfloop>
<A href="#cgi.script_name#">Plain</A>
</cfoutput>
<cfdump var="#application#" label="application variables">
</body></html>
</cflock>
-------------------------------------------
Matt Robertson, [EMAIL PROTECTED]
MSB Designs, Inc. http://mysecretbase.com
-------------------------------------------
---------- Original Message ----------------------------------
From: Bryan Love <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Date: Tue, 10 Jun 2003 15:28:02 -0700
>Here you go. By the way, if you are only storing two values you would be
>much better off using a single array where, say, odd indices are the userID
>and even indices are the username. Then you could do something like this
>(it doesn't buy you much here, but if you do other manipulations it could
>save you some headaches):
>
><cfloop
> from="1"
> to="#ArrayLen(LoginArray)#"
> index="ArrayRows"
> step="2">
> <cfif not Compare(LoginArray[ArrayRows],client.UserID)>
><!--- delete array row code goes here --->
> <cfset arrayDeleteAt(LoginArray,ArrayRows)>
> <cfset arrayDeleteAt(LoginArray,ArrayRows+1)>
> <cfbreak>
> </cfif>
></cfloop>
>
>
>
>but here is the answer to your original question:
><!---
>LoginArray[1]=Username
>LoginArray[2]=User ID #
>--->
>
><cfloop
> from="1"
> to="#ArrayLen(LoginArray)#"
> index="ArrayRows">
> <cfif not Compare(LoginArray[ArrayRows][2],client.UserID)>
><!--- delete array row code goes here --->
> <cfset arrayDeleteAt(LoginArray,ArrayRows)>
> <cfbreak>
> </cfif>
></cfloop>
>
>+-----------------------------------------------+
>Bryan Love
> Database Analyst
> Macromedia Certified Professional
> Internet Application Developer
>TeleCommunication Systems
>[EMAIL PROTECTED]
>+-----------------------------------------------+
>
>"...'If there must be trouble, let it be in my day, that my child may have
>peace'..."
> - Thomas Paine, The American Crisis
>
>"Let's Roll"
> - Todd Beamer, Flight 93
>
>
>
>-----Original Message-----
>From: Matt Robertson [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, June 10, 2003 2:50 PM
>To: CF-Talk
>Subject: ArrayDeleteAt for a 2d array?
>
>
>How do you loop over a *2d* array and delete a single row (and all its
>elements), where that row is determined by a test of the contents. Like so:
>
><!---
>LoginArray[1]=Username
>LoginArray[2]=User ID #
>--->
>
><cfloop
> from="1"
> to="#ArrayLen(LoginArray)#"
> index="ArrayRows">
> <cfif not Compare(LoginArray[ArrayRows][2],client.UserID)>
><!--- delete array row code goes here --->
> <cfbreak>
> </cfif>
></cfloop>
>
>I've been fighting a losing battle with this all afternoon.
>
>-------------------------------------------
> Matt Robertson, [EMAIL PROTECTED]
> MSB Designs, Inc. http://mysecretbase.com
>-------------------------------------------
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Host with the leader in ColdFusion hosting.
Voted #1 ColdFusion host by CF Developers.
Offering shared and dedicated hosting options.
www.cfxhosting.com/default.cfm?redirect=10481
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4