> > <cfset x = getValues[colname][rownum]>
> 
> This'll work with Access? 

Since it's referring to a recordset, or Query object, in CF, the source of
that Query object is irrelevant. Yes, it'll work with Access, in that sense.

> I've been reading that evaluate is a bad idea, but 
> I'm still not clear on what to do instead - if you 
> could explain it, or suggest a webpage, it'd be great.

Use Evaluate when you've got a string, and you want to treat that string as
an expression and evaluate it. If there's any way you can avoid using
Evaluate, by referencing a variable using array syntax, do so.

For example, let's say you've got a form. In the action page, you might not
know what form variables exist exactly - perhaps your action page can handle
any number of variables within the form based on a naming scheme within the
form. In your form, you might have something like this:

<input type="text" name="Name1"> ...
<input type="text" name="Name2"> ...
..
<input type="text" name="Name42">

In your action page, you might want to do something with each of these
variables, but you might not know ahead of time how many there are - perhaps
the form itself is dynamically generated. So, in your action page, you might
loop from 1 to N, where N is the maximum number of form fields (perhaps N is
discovered through another form field):

<cfloop index="i" from="1" to="#Form.NumberOfNames#">
        <cfset ThisName = Evaluate("Form.Name" & i)>
        ... 
</cfloop>

In the above example, you're building a string with "Form.Name" and the
number in the index counter. Then, you're evaluating that string, which
returns the value of the expression Form.Name1 or Form.Name42 based on the
current index value. However, Ray's point is that, because the Form scope is
a structure - and because structures can be enumerated and their members can
be referenced by array syntax - you don't have to use Evaluate:

<cfloop index="i" from="1" to="#Form.NumberOfNames#">
        <cfset ThisName = Form["Name" & i]>
        ... 
</cfloop>

Because taking a string and evaluating it is a relatively expensive
operation, in CF or most other languages I'd expect, it's best to avoid it
whenever possible.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444

______________________________________________________________________
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to