Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Variable Names 2

Status
Not open for further replies.

rdiller

Programmer
Sep 13, 2000
9
US
Need a set of variables...
d1_name --> d42_name

They will be defined by Records being exported out of the Database.

<CFQUERY NAME=&quot;driver&quot; DATASOURCE=&quot;#dsn#&quot;>
SELECT *
FROM driver
WHERE member_id = #Session.member_id#
</CFQUERY>

This could return any amount of records... determining the user's policy.

Right now I'm doing this...

<CFLOOP QUERY=&quot;driver&quot;>
<CFIF driver.CurrentRow eq 1>
<CFSET d1_name = &quot;#name#&quot;>
</CFIF>
<CFIF driver.CurrentRow eq 2>
<CFSET d2_name = &quot;#name#&quot;>
</CFIF>
<CFIF driver.CurrentRow eq 3>
<CFSET d3_name = &quot;#name#&quot;>
</CFIF>

... etc etc
</CFLOOP>

There has to be an easier way for me to do this... These params are then read into a fdf text file for merging with a PDA, and all the variables are currently hard coded... I would just bite the bullet and hardcode all this crap but for this little portion there are 8 variables per record and 42 possible slots... therefor 336 variables... lots of fricken code.. (I'm pushing like 1040 lines for this one little area of a script... not good... and I have to do the same thing again for something else)

Any response is appreciated.

Ryan
 
Hey Ryan,

You can create dynamic variables like this:

<CFSET &quot;d#driver.CurrentRow#_name&quot; = &quot;#name#&quot;>

and check for them like this:

<cfif isdefined(&quot;d#driver.CurrentRow#_name&quot;)>

and use them like this:

#evaluate( &quot;d#driver.CurrentRow#_name&quot;)#

Hope this helps,
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top