0

Ok so what im trying to do here is set putme to be coding so that when the test.txt is read it replaces <!--ReplaceMe --> with the contents of putme. How do i get putme to just store it at text instead of coding?

<!-- Start putme -->
<cfset putme = "<cfelseif #GetFiles.Name# contains #GetFiles.Name#>
  <cfset #Property# = #GetFiles.Property#>
    <cffile action="rename"
        source="D:/home/wwwroot/technet/Uploads/#GetFiles.Name#"
        destination="D:/home/wwwroot/technet/property/#property#/temp/#DateFormat(DateAdd('d', -1, MyDateTime),'mm dd, yyyy')# #Name#">
 <!--ReplaceMe -->
">
<!-- End putme -->

    <cffile action="read"
            file="D:/home/wwwroot/technet/test.txt"
            variable=contents>
    <cfset #contents# = #Replace(contents, "<!--ReplaceMe -->", "#putme#", "all")#>
    <cfset #indexfile# = #dirname# & "\test.txt">
    <cffile action="write"
            file=#indexfile#
            output=#contents#>

Edited by mike_2000_17: Fixed formatting

3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by arrgh
0

The only way I know of is to use CFSAVECONTENT. But IIRC you have to escape CF tags. Otherwise, they're evaluated immediately instead of being treated as a plain string.

<cfsavecontent variable="putme">
.. whatever code you want here. 
...tags will be evaluated unless they're escaped 
</cfsavecontent>
<!--- see what the contents look like ... --->
<cfdump var="#putme#">

<cfset #contents# = #Replace(contents, "<!--ReplaceMe -->", "#putme#", "all")#>

Btw: You don't need all those excess # signs!

<cfset contents = Replace(contents, "<!--ReplaceMe -->", putme, "all")>

Edited by mike_2000_17: Fixed formatting

0

ok this one has me its still trying to evual the cfif

Could you please code this for me so it might work Iam am having a hard time with this one..

<cfsavecontent variable="putme">

<cfelseif #GetFiles.Name# contains 'AB'>
  <cfset #Property# = 'ABC'>
  	<cffile action="rename"
  	    source="D:/home/catalinasecurity.com/wwwroot/technet/Uploads/#GetFiles.Name#"
		destination="D:/home/catalinasecurity.com/wwwroot/technet/property/#property#/temp/#DateFormat(DateAdd('d', -1, MyDateTime),'mm dd, yyyy')# #Name#">

</cfsavecontent>
0

Like I said, I think have to html escape the tags to preven them from being evaluated
ie < becomes &lt; and > becomes &gt;

But I'm not sure even that would work. What are you trying to do exactly?

0

Hi axgold472,

Did you get this one figured out?
Here is an example of what you are trying to do:

<cfset putme = "
	<cfelseif ##GetFiles.Name## contains 'AB'>
	  <cfset ##Property## = 'ABC'>
		<cffile action='rename'
		    source='D:/home/catalinasecurity.com/wwwroot/technet/Uploads/##GetFiles.Name##'
			destination='D:/home/catalinasecurity.com/wwwroot/technet/property/##property##/temp/01 12, 2011 ##Name##'>
" >

<cffile action="write" file="#ExpandPath('/abc.cfm')#" output="#putme#" >
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.