Advertisement
jbocook

ColdFusionLocalLoop

May 5th, 2015
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //I did a cfdump, and the keys all dump properly, so I tried to loop setting LOCAl.variable
  2.  
  3. <cfloop collection="#jsonData#" item="key">
  4.     <cfdump var="#key#">
  5. </cfloop>
  6.  
  7. //I tried to loop the json data, and create local variables these different ways:
  8.  
  9. <cfloop collection="#jsonData#" item="key">
  10.     <cfset LOCAL.#key# = 'foo'>
  11. </cfloop>
  12.  
  13. <cfloop collection="#jsonData#" item="key">
  14.     <cfset LOCAL[key] = 'foo'>
  15. </cfloop>
  16.  
  17. <cfloop collection="#jsonData#" item="key">
  18.     <cfset LOCAL.[key] = 'foo'>
  19. </cfloop>
  20.  
  21. <cfloop collection="#jsonData#" item="key">
  22.     <cfset LOCAL[#key#] = 'foo'>
  23. </cfloop>
  24.  
  25. <cfloop collection="#jsonData#" item="key">
  26.     <cfset "LOCAL." & #key# = 'foo'>
  27. </cfloop>
  28.  
  29. <cfloop collection="#jsonData#" item="key">
  30.     <cfset VARIABLES["LOCAL.#key#"] = 'foo'>
  31. </cfloop>
  32.  
  33. <cfloop collection="#jsonData#" item="key">
  34.     <cfset VARIABLES[LOCAL."#key#"] = 'foo'>
  35. </cfloop>
  36.  
  37. <cfloop collection="#jsonData#" item="key">
  38.     <cfset VARIABLES["LOCAL."#key#] = 'foo'>
  39. </cfloop>
  40.  
  41. <cfloop collection="#jsonData#" item="key">
  42.     <cfset "LOCAL." & #key# = 'foo'>
  43. </cfloop>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement