Thanks to Dave Watts and Joseph Thompson for
providing keys to the solution to this problem.
As I learned with Dave's help, arrays are
passed by value, not by reference to custom
tags. Thus a pointer to the array on the
calling page is not passed and the custom tag
can not modify the array.
I wound up solving the problem by creating a
structure of arrays to contain the various
arrays the custom tag was supposed to modify.
I then passed the structure and the key for
the array element in that structure to the
custom tag. Since structures ARE passed by
reference, I was able to modify the array
embedded in the structure inside the custom
tag. The request scope solution offered by
Joseph Thompson would also have solved the
problem.
Thanks again.
Joe Tartaglia
High Caliber Systems
>Date: Thu, 07 Jun 2001 10:26:14 -0700
>From: "Joseph Thompson" <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: Passing an array to a custom tag
>Message-ID: <018f01c0ef76$f4154d30$[EMAIL PROTECTED]>
>If you scope that array to "Request" it will simply be available to the
>custom tag...
>http://cfhub.com/advanced/customtags/request.cfm
>>
> I am trying to write a custom tag that
>> will, among other things, add an element
>> to an array whose name can vary from situation
>> to situation. This array is always stored as a
>> session variable. I have been trying to pass
>> the name of the array as a character string
>> and then manipulate it in the custom tag
>> with no luck.
>>
>> Here is how I call the tag:
>>
>> ( session.aDirectoryClicked array is created in Application.cfm
>> and initialized earlier )
>>
>> <CFMODULE template="../BumpHitCounter.cfm"
>> aIDs="aDirectoryClicked"
>> nNumIDs=#ArrayLen( session.aDirectoryClicked )#
>> ThisID=#URL.DirectoryID#>
>>
>> =====
>>
>> Here is a snippet from BumpHitCounter.cfm that does not work:
>>
>> <CFLOOP INDEX="n" FROM="1" TO="#Attributes.nNumIDs#">
>> <CFIF "Caller.#Attributes.aIDs# [n]" EQ Attributes.ThisID>
>> <CFSET Variables.WasClicked = "Yes">
>> <CFSET n = Attributes.nNumIDs + 1>
>> </CFIF>
>> </CFLOOP>
>>
>> <CFIF Variables.WasClicked EQ "No">
>> <CFSET Variables.tmp = ArrayAppend( "Caller.#Attributes.aIDs#",
>> #Attributes.ThisID# )>
>> </CFIF>
>>
>
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists