Re: CFLoop: Problem with variable wrapped in double quotes

2009-09-23 Thread Azadi Saryev

use associative array notation:

cfset variables['varMergerFile'  i] =
c:\inetpub\uploads\pdf\resume_#i#.pdf

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/


On 24/09/2009 04:44, Dakota Burns wrote:
 I have the following code below (codeblock 01), which outputs the following
 three lines correctly:
   CFSET varMergeFile1 = c:\inetpub\uploads\pdf\resume_1.pdf
   CFSET varMergeFile2 = c:\inetpub\uploads\pdf\resume_2.pdf
   CFSET varMergeFile3 = c:\inetpub\uploads\pdf\resume_3.pdf

 [CODEBLOCK 01: BEGIN]
 !--- GET LIST LENGTH ---
 cfset printIt = 1212,1549,2003
 cfset listLength = ListLen(#printIt#)
 !--- DISPLAY EVERY ELEMENT IN LIST ---
 cfset x = 1
 cfloop index=i from=#x# to=#listLength# step=1
 cfoutputCFSET varMergeFile#i# =
 c:\inetpub\uploads\pdf\resume_#i#.pdf/cfoutputbr /
 /cfloop
 [CODEBLOCK 01: END]

 When I activate the cfset tag with angle brackets: CFSET varMergeFile#i# =
 c:\inetpub\uploads\pdf\resume_#i#.pdf, I get this error: Invalid CFML
 construct found on line 11 at column 38. ColdFusion was looking at the
 following text: #

 I then wrap double quotes around varMergeFile#i#, and receive no error,
 but the file I'm outputting is invalid and I believe that variable is not
 being defined correctly.

 Is their another way to write the above where varMergeFile#i# is not
 required to be wrapped by double quotes?

 Thanks,
 Dakota


 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326560
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: CFLoop: Problem with variable wrapped in double quotes

2009-09-23 Thread Rick Root

If you're trying to dynamically generate code to put in a file, you
can't do it that way.

Do this instead:

!--- GET LIST LENGTH ---
cfset printIt = 1212,1549,2003
cfset listLength = ListLen(#printIt#)
!--- DISPLAY EVERY ELEMENT IN LIST ---
cfset x = 1
cfset out = 
cfloop index=i from=#x# to=#listLength# step=1
  cfset out = out  'CFSET varMergeFile#i# =
c:\inetpub\uploads\pdf\resume_#i#.pdf'
/cfloop
cfoutput#out#/cfoutput

Of course you won't see the output because it won't render ... but you
can write the contents of the out variable to a file or put it in a
DB or whatever.

ALTERNATIVELY, if what you're actually tring to do is set the
variables, do this:

!--- GET LIST LENGTH ---
cfset printIt = 1212,1549,2003
cfset listLength = ListLen(#printIt#)
!--- DISPLAY EVERY ELEMENT IN LIST ---
cfset x = 1
cfset out = 
cfloop index=i from=#x# to=#listLength# step=1
  CFSET variables[varMergeFile#i#] = c:\inetpub\uploads\pdf\resume_#i#.pdf
  !--- or, god forbit ---
  cfset setVariable(varMergeFile#i#,
c:\inetpub\uploads\pdf\resume_#i#.pdf)
/cfloop


-- 
Rick Root
CFFM - Open Source Coldfusion File Manager
http://www.opensourcecf.com/cffm

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326561
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: CFLoop: Problem with variable wrapped in double quotes

2009-09-23 Thread Dakota Burns

Excellent advise -- thank you both for taking the time to respond.

Best Regards,
Dakota


On Wed, Sep 23, 2009 at 4:11 PM, Rick Root rick.r...@webworksllc.comwrote:


 If you're trying to dynamically generate code to put in a file, you
 can't do it that way.

 Do this instead:

 !--- GET LIST LENGTH ---
 cfset printIt = 1212,1549,2003
 cfset listLength = ListLen(#printIt#)
 !--- DISPLAY EVERY ELEMENT IN LIST ---
 cfset x = 1
 cfset out = 
 cfloop index=i from=#x# to=#listLength# step=1
   cfset out = out  'CFSET varMergeFile#i# =
 c:\inetpub\uploads\pdf\resume_#i#.pdf'
 /cfloop
 cfoutput#out#/cfoutput

 Of course you won't see the output because it won't render ... but you
 can write the contents of the out variable to a file or put it in a
 DB or whatever.

 ALTERNATIVELY, if what you're actually tring to do is set the
 variables, do this:

 !--- GET LIST LENGTH ---
 cfset printIt = 1212,1549,2003
 cfset listLength = ListLen(#printIt#)
 !--- DISPLAY EVERY ELEMENT IN LIST ---
 cfset x = 1
 cfset out = 
 cfloop index=i from=#x# to=#listLength# step=1
   CFSET variables[varMergeFile#i#] =
 c:\inetpub\uploads\pdf\resume_#i#.pdf
  !--- or, god forbit ---
  cfset setVariable(varMergeFile#i#,
 c:\inetpub\uploads\pdf\resume_#i#.pdf)
 /cfloop


 --
 Rick Root
 CFFM - Open Source Coldfusion File Manager
 http://www.opensourcecf.com/cffm

 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326565
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4